How to use include statement in Fortran 90?

10,900

I think you may be mixing the free format program and the fixed format include files. You will have to have both files in the same format, or in the "intersection format" from http://fortranwiki.org/fortran/show/Continuation+lines

Another cause of an error would be using the include statement in the wrong part of the file. It must be placed in the right place according of the content of the file, i.e. executable code; variable and type definitions (specification expressions) or procedure definitions have all their appropriate place.

Share:
10,900
ziulfer
Author by

ziulfer

Updated on June 04, 2022

Comments

  • ziulfer
    ziulfer almost 2 years

    I have some .h files that are used for some modules in FORTRAN 77 (which I haven't written myself). I want to write a new routine in Fortran 90 and use such .h files. I've tried to use include 'foo.h', when I try to compile ( using ifort Version 13.0.0.079 Build 20120731) I get the following error:

    Syntax error, found IDENTIFIER 'FOO' when expecting one of: ( % [ : . = => C FOO COMMOM

    I've also tried to use include foo.h, what gives me the following errors: 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 --^

    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 -----------------^

    error #6252: This format specifier is invalid. [FOO] INCLUDE foo.h

    I guess include doesn't exist in F90. Is there something similar that allows one to use .h files?