Makefile configuration

User configuration

When irpf90 --init is run, a standard Makefile is created:

IRPF90 = irpf90  #-a -d
FC     = gfortran -ffree-line-length-none
FCFLAGS= -O2

SRC=
OBJ=
LIB=

include irpf90.make

irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) \
             $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
        $(IRPF90)

The IRPF90 variable contains the IRPF90 invocation. All the options of IRPF90 should be given in this line. To include some additional directories to be read by IRPF90, the -I option should be used.

The FC variable describes the Fortran compiler to use. As IRPF90 adds comments at the end of the lines to express the correspondence between the Fortran generated files and the IRPF90 source files, the lines are too long for the default options of gfortran. This explains why -ffree-line-length-none is inserted by default. If the Intel Fortran compiler is used, this option should be removed. The FC variable should contain the invocation of the Fortran compiler which is common to compiling Fortran files and to link the project. For example, the -openmp option of the Intel compiler should be placed on this line as it should be mentioned to compile the Fortran files, but it is also required at the link stage.

FCFLAGS contains the flags that should be present at compile time but not at link time. The code optimization options should appear here.

It is possible to add some files to the project that will not be seen by IRPF90, but need to be compiled and linked to the project. For example, a Fortran file containing a "black box" subroutine could be taken from another project, and your IRPF90 program could call this subroutine. To do that, the names of these Fortran source files should be added to the SRC variable, and the names of the corresponding object files to the OBJ variable. Note that it is also possible to add some C source files and objects, but then the corresponding compiling rules would have to be added to the Makefile.

External libraries may be added to the LIB variable.

Auto-generated configuration

The targets are generated by IRPF90 and are written in the irpf90.make file. The name of each main program is a target. The all target builds all the programs.

The clean target removes all the object files. The veryclean target removes also the IRPF90_temp/ and IRPF90_man/ directories as well as the irpf90.make, irpf90_entities and tags files.

If the USE_IRPF90_A environment variable is set, then an archive irpf90.a containing everything except the main functions is created. This archive is linked with every target program. If this environment variable is not set, all object files are linked to create the executables.

IRPF90 creates Fortran modules that will store the cached data. These modules only contain data but no subroutines nor functions. This makes them very fast to compile. All the subroutines and functions are written in other files, and they use the modules. In this way, all the files containing subroutines and functions depend only on module files. The greatest advantage is that all of the files containing subroutines and functions, which are the longest to compile, are independent of each other. This makes the parallel builds very efficient using make -j <n> where <n> is the number of threads. Another advantage is that the irpf90.a library can be linked and used in any other program without requiring any .mod file. Module .mod files are to be avoided in libraries as they are compiler-specific (Intel Fortran .mod files are not compatible with gfortran and vice versa).