Example 9 Example 2-5 makefile

makefile # description for building do_stats do_stats : main.o code.o data.o

f90 -o do_stats main.o code.o data.o

#main.o is dependent on main.f90 and code.f90 main.o : main.f90 code.o f90 -c main.f90

#code.o is dependent on code.f90 and data.f90 code.o : code.f90 data.o f90 -c code.f90

# data.o is dependent only its source, data.f90 data.o : data.f90

f90 -c data.f90

Note that the dependencies correspond to the order in which the source files are specified in the followingf90 command line

$ f90 -o do_stats data.f90 code.f90 main.f90

Assuming that you name the description file makefile, the command line to compile the program with make is:

$ make

Managing .mod files

By default, the compiler writes.mod files to the current working directory and looks there when it has to read them. The +moddir=directoryand -I directory options enable you to specify different directories. The +moddiroption causes the compiler to write .modfiles in directory, and the -Ioption causes the compiler to search directory for .modfiles to read. (The space character between -Iand directoryis optional.)

Using the example of the do_statsprogram, the following command line compiles (without linking) data.f90and writes a.modfile to the subdirectory mod_files:$ f90 -c+moddir=mod_filesdata.f90The command line: $

f90-c+moddir=mod_files-Imod_filescode.f90uses both the +moddir and -Ioptions, as follows:

The +moddir option causes f90 to write the .mod file for code.f90 in the subdirectory mod_files.

The -I option causes f90 to look in the same subdirectory for the .mod file to read when compiling code.f90. The command line: $ f90 -odo_stats -I mod_files main.f90 code.o data.o causes f90 to compile main.f90, look for the .mod file in the subdirectory mod_files, and link all of the object files into an executable program named do_stats.

Compiling for different PA-RISC machines

When you compile an HP Fortran 90 program, the object code that the compiler generates by default is based on the PA-RISC model of the machine that is running the compiler. If your program will execute on a different PA-RISC model machine, the code may run less efficiently or (in the case of PA2.0 code that attempts to run on a PA1.1 machine) may not run at all.

Also, some libraries (for example, the math library) are available in different PA-RISC versions. By default, the compiler selects the version that is based on the PA-RISC model of the compiling machine. If your program will execute on a different model machine, it may not be linked with the appropriate libraries.

Compiling with the +DAmodel option ensures that the compiler generates code that is based on the architecture specified by model and that the linker selects libraries that are compatible with model. model must be one of the following:

A PA-RISC version number—1.1, 2.0, or 2.0W. Use +DA2.0W to compile in 64-bit mode; see “Compiling in 64-bit mode” (page 63).

A model number—for example, 750or 870.

58 Compiling and linking