Compiler options

From VASP Wiki
Revision as of 16:28, 19 January 2022 by Huebsch (talk | contribs) (Created page with "The compiler options specify by compiler variables that set the compiler and compiler flags you want to use. The Fortran compiler will then be invoked as: $(FC) $(FREE) $(FF...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The compiler options specify by compiler variables that set the compiler and compiler flags you want to use. The Fortran compiler will then be invoked as:

$(FC) $(FREE) $(FFLAGS) $(OFLAG) $(INCS)

Compiler variables

FC

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

FCL

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

OFLAG

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

FFLAGS

Additional compiler flags. To enable debugging, for instance, the following line could be added:
FFLAGS+=-g 

OFLAG_IN

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

DEBUG

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

INCS

Use this variable to specify objects to be included in the sense of:
INCS=-I/path/to/directory-with-files-to-be-included

FREE

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


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.

FFLAGS_x

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

OFLAG_x

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

INCS_x

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

and reflect the special rules as they were present in most of the makefiles of the old build system.

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

SOURCE_O1 =
OBJECTS_O1= .. your list of objects ..