fortran - 如何在Fortran 90中使用include语句?

标签 fortran fortran90 intel-fortran fortran77

我有一些 .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/

相关文章:

fortran - 我可以用数字调用 fortran 日志函数吗?

fortran - 数组构造函数中的不同字符长度(3/4),如何修剪字符串 - fortran

fortran - 如何使循环计数器不大于最终值?

windows - forrt1 : severe (170): Program Exception - stack overflow

c - Windows 中的混合编程

python - 如何知道 .f90 文件安装在哪里?

performance - Fortran:32 位/64 位性能可移植性

python - 如何获取有关使用 f2py 构建的 Python 模块的运行时错误的信息

c - C++/Fortran 中贝塞尔函数的集成

multidimensional-array - 如何确定文本文件中多个矩阵的维数