Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
gfortran-std=f2008如果存在调用fseek,则编译标志错误_Fortran_Gfortran - Fatal编程技术网

gfortran-std=f2008如果存在调用fseek,则编译标志错误

gfortran-std=f2008如果存在调用fseek,则编译标志错误,fortran,gfortran,Fortran,Gfortran,我正试图用gfortran执行fortran2008一致性检查。当我使用-std=f2008编译时,我得到以下错误: Undefined symbols for architecture x86_64: "_fseek_", referenced from: _MAIN__ in ccJtOcKa.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status

我正试图用gfortran执行fortran2008一致性检查。当我使用-std=f2008编译时,我得到以下错误:

Undefined symbols for architecture x86_64:
  "_fseek_", referenced from:
      _MAIN__ in ccJtOcKa.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
下面的简单测试程序显示了该问题。它在没有-std=f2008的情况下编译并运行良好,但在设置此标志时不编译

program main
  implicit none
  integer :: i
  open(unit=10, file='test.bin', access='stream')
  write(10) 100

  !fseek works, but will not compile with -std=f2008
  call fseek(10, -4, 1)
  read(10) i
  print *, i
end program
这项工作:
gfortran main.f90

这会产生以下错误:
gfortran-std=f2008main.f90

我正在使用gfortran 8.2的MacPorts版本

GNU Fortran (MacPorts gcc8 8.2.0_3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

fseek不是fortran 2008标准的一部分吗?如果是这样的话,是否有其他方法来实现这一点?

FSEEK
是流访问不需要的扩展内在子例程。你可以从你想要的任何位置阅读

read(10, pos=42) i
您还可以使用
inquire
语句获取当前位置

inquire(unit=10, pos=current_pos)

正如其他人所指出的,
FSEEK
不在Fortran标准中。然而,Fortran标准允许处理器提供额外的内部函数子程序。为了避免出现问题,可以使用
-fall intrinsics
选项。因此,
gfortran-std=f2008-fall intrinsics将尝试遵守Fortran 2008标准,例外情况是gfortran提供的所有内部子程序都可用。

fseek
。如果您想更早地(在链接之前)捕获错误,可以尝试尽早添加
内在fseek
语句。如果打开手册,它会清楚地表明这是一个“GNU扩展”(对于GNU编译器)