The C preprocessor (CPP) is applied to files with .FM and .F suffixes as the first stage of compilation. (For a detailed description of CPP, see any good C programming manual.) These files can contain CPP directives that specify conditional compilation , macro expansion , and constants . The following program, cpp_ex.FM, uses CPP directives for all of these purposes.
==
#ifndef N_NODES
#define N_NODES 1
#endif
#ifndef PRODUCER_OFFSET
#define PRODUCER_OFFSET 0
#endif
#define N_PRODUCERS (N_NODES - PRODUCER_OFFSET)
program cpp_ex
processors(N_NODES)
integer n_producers
parameter (n_producers = N_PRODUCERS)
inport (integer, integer) pi
outport (integer, integer) po(n_producers)
merger(in=pi, out=(po(i),i=1,n_producers))
processes
#ifdef USE_CONSUMER1
processcall consumer1(pi) location(1)
#else
processcall consumer2(pi) location(1)
#endif
processdo i = 1, n_producers
processcall producer(i, po(i))
x location(i+PRODUCER_OFFSET)
endprocessdo
endprocesses
end
=1.03This program creates a single consumer process and one or more producer processes and connects the producers to the consumer by a merger. By default, all processes run on a single processor, and consumer2 is used as the consumer process. Various aspects of this behavior can be modified at compile time through the use of -D compiler arguments . For example:
The result of running CPP on a .FM or .F file is a .fm or .f file, respectively, which will be passed onto the following compiler stages.
To ensure consistency across different machines, the Fortran M compiler includes its own version of CPP which it applies to files with .FM and .F suffixes. This CPP is used even if a target computer has its own CPP or if its Fortran compiler supports CPP directives. It has been our experience that different versions of CPP can differ in subtle ways, particularly when applied to Fortran programs. Please see Appendix E for information on deficiencies of the included CPP.
The behavior of CPP can be modified with the following compiler arguments :