From: Elijah Cardon on
One of the reasons that I use #define in c is that it mimics what might
happen if a caller were passing what is being #defined. Is there such a
thing as a preprocessor in fortran? EC


From: Kamaraju Kusumanchi on
Elijah Cardon wrote:
> One of the reasons that I use #define in c is that it mimics what might
> happen if a caller were passing what is being #defined. Is there such a
> thing as a preprocessor in fortran? EC
>
>
I use cpp as the preprocessor on Debian Etch for fortran 90 programs.

raju
From: Tim Prince on
Elijah Cardon wrote:
> One of the reasons that I use #define in c is that it mimics what might
> happen if a caller were passing what is being #defined. Is there such a
> thing as a preprocessor in fortran? EC
>
>
Many Fortran compilers come with a pre-processor which implements
#define, although it's not part of the standards. On linux-like
systems, source files named with .F or .F90 typically cause the
pre-precessor to be invoked, or a command line option which invokes
pre-processing is available. If all else fails, a common tactic is
gcc -x c -traditional -E yourfile.f > preprocessedfile.f
Several preprocessors of similar nature are available as open source.
Pre-processors closer to the standard, although not in as widespread
use, have similar functionality.
I don't recognize your description of the usage of pre-processing.
From: AeroSpace Ed on
Elijah Cardon wrote:

> One of the reasons that I use #define in c is that it mimics what might
> happen if a caller were passing what is being #defined. Is there such a
> thing as a preprocessor in fortran? EC

This doesn't make any sense to me. What EXACTLY are you using the #defined
directive for? Many Fortran compilers can pre-process cpp statements.

However, your described use doesn't make any sense to me.

Ed
From: Tobias Schlemmer on
AeroSpace Ed schrieb:
> Elijah Cardon wrote:
>
>> One of the reasons that I use #define in c is that it mimics what might
>> happen if a caller were passing what is being #defined. Is there such a
>> thing as a preprocessor in fortran? EC

> This doesn't make any sense to me. What EXACTLY are you using the #defined
> directive for? Many Fortran compilers can pre-process cpp statements.

One interesteing application of #define is IMHO the C/C++ macro assert,
which assures a given expression. In the failure case it will stop your
program and output the current filename and line number together with
the test to stderr.

One problem I have with g95:
The macro expansion very often exeeds the

> However, your described use doesn't make any sense to me.
Using autoconf is a very useful example.

or e. g.

#ifdef DEBUG
#define pure
#endif

That enables you to have some debug output in otherwise pure functions
if you are familiar with the side effects.

Tobias