我有一些 .h 文件,用于 FORTRAN 77 中的某些模块(我自己没有编写)。我想在 Fortran 90 中编写一个新例程并使用此类 .h 文件。
我尝试使用 include 'foo.h'
,当我尝试编译(使用 ifort Version 13.0.0.079 Build 20120731)时,出现以下错误:
Syntax error, found IDENTIFIER 'FOO' when expecting one of: ( % [ : . = =>
C FOO COMMOM
我还尝试使用 include foo.h
,这给了我以下错误:
ojit_代码
error #5082: Syntax error, found IDENTIFIER 'FOO' when expecting one of: <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT>
INCLUDE FOO.h
----------^
error #6274: This statement must not appear in the specification part of a module
INCLUDE foo.h
--^
error #6236: A specification statement cannot appear in the executable section.
!$ use omp_lib
---^
error #6236: A specification statement cannot appear in the executable section.
implicit none
--^
ojit_代码 -----------------^
error #6456: This name must be a RECORD name. [FOO]
INCLUDE FOO.h
----------^
我猜 error #6460: This is not a field name that is defined in the encompassing structure. [H]
INCLUDE foo.h
在 F90 中不存在。是否有类似的东西允许人们使用 .h 文件?
最佳答案
我认为您可能混合了自由格式程序和固定格式包含文件。您必须使两个文件具有相同的格式,或者采用 http://fortranwiki.org/fortran/show/Continuation+lines 中的“交集格式”。
导致错误的另一个原因是在文件的错误部分使用了 include 语句。必须根据文件内容(即可执行代码)放置在正确的位置;变量和类型定义(规范表达式)或过程定义都有其适当的位置。
关于fortran - 如何在Fortran 90中使用include语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15478401/