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

Conditional Compilation

ronan2010
Einsteiger
3.846Aufrufe
hi all,

Trying to compile one of the open source projects related with FEM(Elmer). I'm facing with very annoying hurdle. The project is comprised from many packages some of them individual some of them are well known e.g. LAPACK etc.. and everything is bundled intocorresponding folderwhere some kind of Linux-like script is need to be run to compile all of them (plenty of makefile, config. etc..).

Thereare a Fortranfiles which solves the equations in "fem" named subfolder, what I want to achieve is to compile just only these Fortran codes. Since I couldn't locate any file starting with program prefixI couldn't even guess what it's suposed to create after compilation (exe. lib. dll etc..).

I tried my chance, but it seems that Fortran compiler doesn't detect the conditional compilation. The form is like thatand there are many of conditional statements. Those ARCH_32_BITS is defined in config.h files.

#ifdef (ARCH_32_BITS)
INTEGER, PARAMETER :: AddrInt = SELECTED_INT_KIND(9)
#else
INTEGER, PARAMETER :: AddrInt = SELECTED_INT_KIND(18)
#endif

and Fortran compiler complains with taht "Error 7 error #6418: This name has already been assigned a data type."

Regards,
0 Kudos
5 Antworten
mecej4
Geehrter Beitragender III
3.846Aufrufe
Use the /fpp option to process a source file with C-style preprocessor directives.
ronan2010
Einsteiger
3.846Aufrufe

But exactly where to set that ?

Project->Fortran->Preprocessor =Processor DEfinition to FFP only

Tried that w/o succes

mecej4
Geehrter Beitragender III
3.845Aufrufe
I assumed that you were using the command line. With the IDE, I'd play with the innumerable options until the command line looked correct. In this case, the /fpp option should be set, and whatever preprocessor definitions are needed should be specified (/D).

Set Project:Fortran:Preprocessor:Preprocess_Source_File to Yes (/fpp), and
Set Project:Fortran:Preprocessor:Preprocessor_Definitions to whatever you need.
Wendy_Doerner__Intel
Geschätzter Beitragender I
3.845Aufrufe
You can add a command line option to the IDE through the following window in Microsoft Visual Studio:
Right click on the Project => select Properties => select Fortran => add to command line window options
The Fortran Preprocessor does not support all features that the C preprocessor does, but it does support ifdef. See more details hereand the following excerpt from that page on fpp from the documenation.

Running fpp to Preprocess Files

You can explicitly run fpp in these ways:

  • On the ifort command line, use the ifort command with the -fpp (Linux OS and Mac OS X) or /fpp (Windows OS) option. By default, the specified files are then compiled and linked. To retain the intermediate (.i or .i90) file, specify the -save-temps (Linux OS and Mac OS X) or /Qsave-temps (Windows OS) option.

  • On the command line, use the fpp command. In this case, the compiler is not invoked. When using the fpp command line, you need to specify the input file and the intermediate (.i or .i90) output file. For more information, type fpp -help (Linux OS and Mac OS X) or fpp /help (Windows OS) on the command line.

  • In the Microsoft Visual Studio* IDE, set the Preprocess Source File option to Yes in the Fortran Preprocessor Option Category. To retain the intermediate files, add /Qsave-temps to Additional Options in the Fortran Command Line Category.

JVanB
Geschätzter Beitragender II
3.846Aufrufe
Why insert C into your Fortran? There is a standard way (F2003):

USE, INTRINSIC :: ISO_C_BINDING, ONLY: AddrInt => C_INTPTR_T

There is also an Intel extension, compatible with CVF:

INTEGER, PARAMETER :: AddrInt = INT_PTR_KIND()

For pre-F2003 compilers but with Cray pointers there is:

LOGICAL :: DONT_USE_ME
POINTER(DONT_USE_ME_EITHER,DONT_USE_ME)
INTEGER, PARAMETER :: AddrInt = KIND(DONT_USE_ME_EITHER)
Antworten