- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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?
Lien copié
5 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
In the Fortran Project Options, change /fpp to /fpp:"/m" to enable macro substitution.
Steve
Steve
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks Steve. That works well in the source file. It doesn't work if the #define occurs in an included file. Is this supported?
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
It is if you use #include. fpp doesn't process Fortran INCLUDE.
Steve
Steve
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Please send an example to vf-support@compaq.com - our fpp expert (not me!) will look at it.
Steve
Steve

Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable