I.1 A more measured approach to building FHI-aims
This is a slower and step by step explanation of the build process, slightly different and somewhat redundant with Sec. I. Ultimately, your build process should ideally look somewhat like what is covered in Sec. I, and in particular, never edit the Makefile if you already have a file make.sys around. What follows is based on direct editing of the Makefile and should only be needed for practice purposes.
Starting from the end of Sec. 1.2 and once all prerequisites are in place, change directory to the src/ directory, and open the Makefile in a text editor.
You must adjust at least some system-specific portions of the Makefile—simply typing “make” and hoping that the problem will go away will not work.
Usually, all you will have to do is to decide on one of the preconfigured make targets – “serial”, “mpi”, or “scalapack.mpi”. Near the top of the Makefile, a number of mandatory settings are commented for each target. Uncomment only the block of settings relevant to your chosen make target, and fill in the correct values of each variable (FC, FFLAGS, LAPACKBLAS, …) for your computer system. Note that the Makefile itself contains detailed instructions and explanations regarding the meaning of these variables. Often, simply adjusting the compiler name, the location of your libraries (LAPACKBLAS, possibly MPIFC or SCALAPACK) will be sufficient. In addition, we strongly recommend that you consult the documentation of your compiler, in order to find out which optimization options beyond the generic “-O3” optimization level suggested preset in the Makefile will make a difference on your computer.
Finally, this brings us to the key step of the build process: Building the code. After the Makefile is adjusted, type
make <target>
at the command line, where “target” should be replaced by the target of your choice: “serial”, “mpi”, or “scalapack.mpi”.11 1 There is an additional target, parser, which builds an executable that stops after parsing the input. This binary can be used to check the validity of input files. (The dry_run keyword achieves the almost same effect with the full binary.) If successful, this should build the desired FHI-aims binary (the compilation will take a while) and place it in the bin/ directory mentioned above.
Building FHI-aims can take a while nowadays. If you have more than one processor on the machine for building FHI-aims, try
make -j <number_of_processors> <target>
This choice should speed up the process greatly.
You may also wish to keep your own copy of the Makefile, for instance to be able to work directly with the FHI-aims git repository without overwriting the general Makefile. In that case, just copy the standard Makefile to something like Makefile.myname, and use
make -j <number_of_processors> -f Makefile.myname <target>
Finally, we do note that there is some support for more sophisticated tasks, such as cross-platform builds (building binaries for different architectures from the same home directory) among the non-standard environment variables in the Makefile (see there).
I.1.1 Cross-Compiling with a C Compiler
As noted in Section I, FHI-aims does provide some functionality that can only be accessed by compiling part of the code base with a C compiler, in some cases simply because a system call in question is not available from a Fortran interface.
Cross-compiling with a C compiler can be simple if your Fortran and C compiler use compatible interfaces. (This may not be always the case.) In the simplest case, adding the following variable to your make.sys:
CC = gcc
The CC variable should specify a C compiler compatible with your Fortran compiler on your specific computer system. Please make sure that the right C compiler is chosen for your system.
An additional variable CCFLAGS can be set to specify C compiler flags along with the CC variable above and will add C compiler flags that might be necessary for your particular computer setup.