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

Using the Fortran PreProcessor (FPP) with compiler directives

Ilie__Daniel
Beginner
892 Views

Hello Fortran Enthusiasts!

I want to compile a file using the FPP. The file contains a compiler directive. This is what happens:

If I type: fpp preproc1.for preproc1.i the intermediate file is generated correctly. However, if I type ifort /fpp /Qsave-temps preproc1.for, the intermediate file is truncated in the free form section. The same happens when I compile through the Visual Studio 2005.

What can I do to make this work through VS2005?

I attached a zip file containg the example. I have VS 2005 Standard and IVF 10.0.011.

Thank you for your time,

Daniel I.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
892 Views
Ok, what I see is that the fpp preprocessor is not honoring the !DEC$ FREEFORM directive, and I'm not sure that it should. This directive is generally meant for use in INCLUDE files (and I don't mean #include!) to allow a freeform source to be included into a fixed-form source. In general, though, this is a bad idea. It's far better to write INCLUDE files in a format acceptable in both source forms (instructions for doing that are in the Language Reference.)

On the other hand, this illustrates an ongoing gripe I have had with our fpp in that it effectively "lexes" (separates out tokens and keywords) the Fortran statement and reassembles it, rather than doing a strict line-by-line replacement. Most of the time this is not noticeable. One might argue that if it's going to do this then it ought to honor directives that change how lexing works. I'll bring this to the attention of the developers.

Still, my advice would be "don't do that". My general advice is to not use fixed-form at all, but if you must, do not play tricks with !DEC$ FREEFORM.
0 Kudos
Ilie__Daniel
Beginner
892 Views

Steve,

Thank you for answering so quickly and for raising this with the developers.

I have just the right example that shows the lexing in action.

Original code (all freeform):

write(message,fmt="(a)")"This should be &

only one line"

PreProcessed:

write(message,fmt="(a)")"This should be only one line"

So basically, the leading blanks are inserted into the message.

Granted this is bad coding. The better version is:

write(message,fmt="(a)")"This should be " // &

"only one line"

Thank you for your help Steve!

Daniel I.

0 Kudos
Steven_L_Intel1
Employee
892 Views
Well, no. You want:

write(message,fmt="(a)")"This should be &

&only one line"


0 Kudos
Reply