- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
#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?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the Fortran Project Options, change /fpp to /fpp:"/m" to enable macro substitution.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve. That works well in the source file. It doesn't work if the #define occurs in an included file. Is this supported?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is if you use #include. fpp doesn't process Fortran INCLUDE.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please send an example to vf-support@compaq.com - our fpp expert (not me!) will look at it.
Steve
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page