Compiler options

From VASP Wiki

The compiler options are specified by compiler variables that set the compiler and compiler flags. The Fortran compiler will then be invoked as:


Compiler variables


The command to invoke your Fortran compiler (e.g. gfortran, ifort, mpif90, mpiifort, ... ).


The command that invokes the linker. In most cases:
FCL=$(FC) [+ some options]


The general level of optimization (default: OFLAG=-O2).


Additional compiler flags. To enable debugging, for instance, the following line could be added:


(default: -O2) In the vast majority of makefile.include files this variable is set:


The optimization level with which the main program (main.F) will be compiled, usually:


Use this variable to specify objects to be included in the sense of:


Specify the options that your Fortran compiler needs for it to accept free-form source layout, without line-length limitation. For instance:
  • Using Intel's Fortran compiler:
FREE=-free -names lowercase
  • Using gfortran:
FREE=-ffree-form -ffree-line-length-none

MPI + OpenMP parallelization

To compile VASP with OpenMP support, add the following to the list of precompiler flags in your makefile.include file:


In addition, you will have to add some compiler-specific options to the command that invokes your Fortran compiler (and sometimes to the linker as well).

When using an Intel toolchain (ifort + Intel MPI), for instance:

FC = mpiifort -qopenmp

Special rules

The current src/makefile contains a set of recipes to allow for the compilation of objects at different levels of optimization other than the general level specified by OFLAG. In these recipes, the compiler will be invoked as:

$(FC) $(FREE) $(FFLAGS_x) $(OFLAG_x) $(INCS_x) 

where x stands for: 1, 2, 3, or IN.


Default: FFLAGS_x=$(FFLAGS), for x=1, 2, 3, and IN.


Default: OFLAG_x=-Ox (for x=1, 2, 3), and OFLAG_IN=-O2


Default: INCS_x=$(INCS), for x=1, 2, 3, and IN.

The objects to be compiled in accordance with these recipes have to be specified by means of the variables: OBJECTS_O1, OBJECTS_O2, OBJECTS_O3, OBJECTS_IN

Several objects are compiled at -O1 and -O2 by default. These lists of objects are specified in the /path/to/vasp.X.X.X/src/.objects file through the variables: SOURCE_O1, SOURCE_O2, SOURCE_IN.

To completely overrule a default setting (for instance for the -O1 special rules) you can use the following construct:

OBJECTS_O1 = .. your list of objects ..

Related articles

Installing VASP.6.X.X, makefile.include, Precompiler options, Linking to libraries, OpenACC GPU port of VASP, Toolchains, Validation tests, Known issues