Includes revealing with Fortran preprocessor

后端 未结 1 1747
猫巷女王i
猫巷女王i 2021-01-21 03:10

I would like to understand how the preprocessor inlines includes into the code in Fortran. With C, it\'s pretty simple:

Test.c:

#include         


        
相关标签:
1条回答
  • 2021-01-21 03:21

    Fortran has its own include directive which must not be confused with the preprocessor directive #include. As far as I understand it, the included code is not embedded into the master file, but the compiler instead continues to compile from the include file, and returns to the master file at the end of that file. From here:

    The INCLUDE statement directs the compiler to stop reading statements from the current file and read statements in an included file or text module.

    Also, included files are not preprocessed further, while #included ones are.

    Note, that there is also a naming convention that enables the preprocessor only on files with capital suffixes *.F and *.F90. If you want to preprocess *.f or *.f90 files, you need to specify that in a compile option, e.g. -cpp for gfortran, and -fpp for ifort.

    0 讨论(0)
提交回复
热议问题