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

Method of ignoring compiler directives?

murpup
Beginner
673 Views
Hi all,

I was just curious if there would happen to be a command line option for intel 9.0 on linux that instructs the compiler to treat all cDEC$ directives as comments? I searched the man page and manual and didn't see anything that looked promising, but just thought I'd inquire in case there is some hidden option or method for doing this.

We use some of these directives on Windows to control mixed language issues related to calls to C routines compiled with VC++, but need to force the compiler not to use them when on linux and linking against gcc-built objects.

Thanks in advance,
Chris
0 Kudos
4 Replies
jim_dempsey
Beginner
673 Views

I am not aware of such an option but you could try enabling the preprocessor FPP and then declare a preprocessor macro DECdollar as either cDEC$ or ccDEC$ depending on requirements.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
673 Views
No, sorry, but why not add conditional directives that cause these directives to be compiled only for Windows? I think you can use the _WIN32 predefined symbol to test.
0 Kudos
jim_dempsey
Beginner
673 Views

You are correct. I should have run a test first. It is interesting though that if I run FPP to parse the file I do get a valid cDEC$ ... and at column 1 (although the !DEC$ does get stripped as ! can be used to comment macros).

I personaly use preprocess file and #ifdef _WIN32 or some similar conditions.

Jim

0 Kudos
jim_dempsey
Beginner
673 Views

From the .html readme for .025

Choice of Comment Style in fpp-Preprocessed Source

The /allow:[no]fpp_comments switch has been introduced in order to allow the user to control how the fpp preprocessor treats Fortran end-of-line comments in preprocessor directive lines. Consider for example the following source line:

#define MAX_ELEMENTS 100 ! Maximum number of elements

How is the preprocessor supposed to treat the text "! Maximum number of elements"? Is it treated as a Fortran comment and therefore ignored, or is it part of the value for the MAX_ELEMENTS definition? Given that the functionality of fpp is essentially that of the C preprocessor cpp, and on many platforms, a cpp itself is used to provide Fortran preprocessing, to cpp, this would just be text that is part of the value being defined..

The Intel Fortran Compiler default, specified by /allow:fpp_comments, is to recognize Fortran-style end-of-line comments on preprocessor lines. Therefore, by default, the line above would define MAX_ELEMENTS to be simply "100". If /allow:nofpp_comments is specified, then Fortran end-of-line comment conventions are not used and "!" has no special meaning. An example of where you may want to use /allow:nofpp_comments is to have a Fortran directive as a define value, for example:

#define dline(routname) !dec$ attributes alias:"__routname":: routname

Please note that there is not widespread agreement among Fortran vendors for this behavior.

If you are using the Visual Studio IDE, you must enter this switch manually under Command Line in the Fortran project property page.

0 Kudos
Reply