Software Archive
Read-only legacy content
17061 Discussions

Defines and FPP

Intel_C_Intel
Employee
767 Views
Is there a way to do text substitution similar to a #define in C++? For example in C++,
#define somevar someothervar
replaces all instances of somevar with the string someothervar. Trying the same thing in Fortran seems to have no effect.
The documentation for FPP says ?FPP is a modified version of the ANSI C preprocessor and supports ? #define , #elif, #else, ??. Is preprocessor text substitution possible in Fortran?
0 Kudos
5 Replies
Steven_L_Intel1
Employee
767 Views
In the Fortran Project Options, change /fpp to /fpp:"/m" to enable macro substitution.

Steve
0 Kudos
Intel_C_Intel
Employee
767 Views
Thanks Steve. That works well in the source file. It doesn't work if the #define occurs in an included file. Is this supported?
0 Kudos
Steven_L_Intel1
Employee
767 Views
It is if you use #include. fpp doesn't process Fortran INCLUDE.

Steve
0 Kudos
Intel_C_Intel
Employee
767 Views
Thanks Steve. This works well until you have an array index, e.g.:
type(sometype) somevar
#define myindex somevar.myindex

integer someArray(5), i
...
myindex = 5
i = someArray(myindex)

The first instance of myindex is substitued nicely, but the second instance (used as the index of someArray) doesn't get substituted.
Any way to do this? The command line help for fpp doesn't seem to mention anything.

Thanks,
Brad
0 Kudos
Steven_L_Intel1
Employee
767 Views
Please send an example to vf-support@compaq.com - our fpp expert (not me!) will look at it.

Steve
0 Kudos
Reply