首页 > 解决方案 > pgf90 在使用可选逻辑参数时导致分段错误

问题描述

只需看以下简单代码:

program hello

  call foo()

contains

  subroutine foo(bar)

    logical, intent(in), optional :: bar

    if (present(bar) .and. bar) then
      print *, 'hello'
    end if

  end subroutine foo

end program hello

编译的时候pgf90报错Segmentation fault: 11,使用的时候没问题gfortran。问题应该在 处present(bar) .and. bar,但bar没有给出时,present(bar)将被评估为.false.,并且bar不应评估以下内容,在这种情况下为空。

标签: fortranpgi

解决方案


推荐阅读