3
在Fortran中,是否有通过包装函数传递语句标签的方法?包装函数中的语句标签
为了详细说明,我写的包装为open()
,像这样:
program test
contains
subroutine my_open(unit, file, err)
integer, intent(in) :: unit
character(*), intent(in) :: file
integer, intent(in), optional :: err
if (present(err)) then
open(unit, FILE=file, ERR=err)
else
open(unit, FILE=file)
end if
end subroutine my_open
end program test
(当然我的实际过程包含更多的逻辑......)。但gfortran
抱怨
open(unit, FILE=file, ERR=err)
1
Error: Invalid value for ERR specification at (1)
有没有办法做到这一点?