
Chapter 5. Fortran programming 49
F90= f90
iterate: $(OBJS)
$(F90) -o $@ $(OBJS)
iterate.o: myprec.o cg.o matrix.o
cg.o: myprec.o matrix.o
matrix.o: myprec.o
.SUFFIXES: .f90
.f90.o:
$(F90) $(OPTS) $<
clean:
rm -f *.o iterate
If the module files (.o or .a) are not in the current directory, one can
use the -p path option of the f90 command to include additional search
paths and/or module files.
It is common to place the modules in an archive so that they can be used
in several programs. As an example we compile the previous modules
as before and form a library called libmod.a:
t3e% ar rv libmod.a myprec.o matrix.o cg.o
t3e% rm myprec.o matrix.o cg.o
Suppose that libmod.a is in the subdirectory lib. Then we can compile
and link the main program with
t3e% f90 -o iterate -p lib iterate.f90
The compiler option -p may take as an argument a directory name,
when all archive files in it are search, or a single file name, e.g., -p
lib/libmod.a.
5.9 Source code preprocessing
Source code preprocessing is activated if the filename extension is .F
or .F90. Preprocessing directives (like #ifdef...#else...#endif)can
help to isolate computer system specific features. This helps in main-
taining a single version of source code in one source file.
On Cray systems it is often necessary to use the option -F to make
certain macro expansions work (#define). The option -D can be used to
define macros directly from the compiler command line. One can also
use the compiler options -eP (only preprocessing) or -eZ (preprocessing
and compilation) to preprocess source codes.
Komentáře k této Příručce