apple
apple

Reputation: 127

Include statement in a Fortran file

I had a Fortran module file (filename.F), which contains a line of statement:

#include "module_io_domain_defs.inc"

which I don't quite understand. Why is a "#" symbol. Should not be just

include "module_io_domain_defs.inc"

I know during the compilation process, the *.F file becomes *.f90 file. How to understand the above statement and how dose the compilation process work?

Upvotes: 3

Views: 1605

Answers (1)

The # designates a C preprocessor directive. Therefore the #include is not processed by the Fortran compiler but by a C preprocessr (cpp, ). The capital .F instead of f typically tells the compiler to run cpp before compiling.

The main difference is that the file included by #include will again be processed by cpp, whereas a file included just by include will not be processed by anything before compiling.

The preprocessor can also be requested by passing a flag such as -cpp or -fpp if the compiler does not recognize the capital F in the suffix.

Upvotes: 4

Related Questions