Preprocessor Directive Problems

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Fri Jun 10 18:56:00 GMT 2005


Richard Haney wrote:
> I am new to fortran and am having some problems with a file. Whenever I try 
> to compile the file "clump.f90" using gfortran I get warnings about 
> preprocessor directives. I am using gFortran version 4.0.0. 20041001 on a 
> Linux Cluster.
> 
> The following is a short copy of my input and output:
> 
> % gfortran -c clump.f90
> 
> output: > "Warning: clump.f90:65 Unknown preprocessor directive"
> 
> When I open the file up, the line that gives the warning is "#ifdef  DEBUG".

The error message is probably misleading.  What's going on is that your source
file contains C preprocessor instructions, and hence needs to be preprocessed
before it's valid Fortran.

You have two choices: either rename your file to clump.F90 (with a capital F),
then gfortran will automatically invoke the preprocessor when compiling the
file.  Alternatively you can pass the intuitively named option '-x
f95-cpp-input' to the compiler.

- Tobi



More information about the Fortran mailing list