Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28454 Discussions

About "illegal token on preprocessor directive line"

goldfox001
Beginner
974 Views
Hi,everyone,
When I compile fixed format fortran source file with 9.x or 10.x,I get the warnings:illegal token on preprocessor directive line.
These warnings occured as the follow source preprocess lines:
#ifndef MPP1 BDYIN.34
BDYIN.34 is the notes after 72 column
It seems the compiler can't identify the notes after 72 column in fixed format.
How can I solve the warning problems?
0 Kudos
6 Replies
jimdempseyatthecove
Honored Contributor III
974 Views

try FPP -help

I think you may want to add -e80 to the fpp options

Jim Dempsey

0 Kudos
Ron_Green
Moderator
974 Views
I have reproduced this issue. FPP does seem to 'do the right thing' after complaining about the syntax.

It seems FPP is source form agnostic and doesn't understand why you would have extra tokens on a FPP line (the comment out in columns 73+).

-extend-source 72 has no affect, since FPP runs before the compiler is invoked.

We're looking into this and should have a response soon. The temporary work around is to use 'cut' to chop off everything in the far right columns.

ron
0 Kudos
jimdempseyatthecove
Honored Contributor III
974 Views

You also might experiment using FPP -noC ...

and changing your "comment" format to use C style "//"

#ifndef MPP1// BDYIN.34

This might work. If it does then you can move the "comment" leftwards more for more readability. (so you have a better chanch to see it in the IDE/Editor)

#ifndef MPP1// BDYIN.34

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
974 Views
In my opinion the preprocessor's behavior here is correct. preprocessor directives are not Fortran source statements and do not have Fortran rules such as column 72 applied to them. Clearly, if you are using column 72 through 80 for notes then you do not want to use options that will extend the source width to column 80 or 132.

However, there is one way in that preprocessor directives do look like Fortran source statements in that regards what is considered a comment delimiter. In no case are two slashes, as would be used in C, recognized as a comment; this is the Fortran character concatenation operator. The default is to allow use of an exclamation point to delimit a comment. If you use the- allow nofpp_comments switch then Fortran comments are not recognized in pre-processor directives and are treated as text.

So one solution here is to use the Fortran comment delimiter before the note.
0 Kudos
goldfox001
Beginner
974 Views
It's OK when I add "!" before the comments and no warning again when compiling. But I have so many sunch source files.

And also simply I can use ifort -w to omit these warnings, the warnings do not affect the final executable.

By the way, these fortran source files are compiled correctly with no warnings with f90 in SGI IRIX.
0 Kudos
Steven_L_Intel1
Employee
974 Views
There is no standard for Fortran preprocessing, at least the style you're using. (There is actually a standard way of doing Fortran preprocessing that was published as an optional part of Fortran 95. Nobody implements it that I know of and it is very different from the CPP style that almost everybody uses.)

The problems start when you make assumptions about how directive lines should be treated as Fortran and what we have found is that each vendor makes their own decisions leading to incompatibilities. My advice is to not assume anything about preprocessor directives regarding comments and to leave comments or notes off of the directive lines.
0 Kudos
Reply