Compiler options: Difference between revisions
(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...") |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
The compiler options | The compiler options are specified by compiler variables that set the compiler and compiler flags. The Fortran compiler will then be invoked as: | ||
$(FC) $(FREE) $(FFLAGS) $(OFLAG) $(INCS) | $(FC) $(FREE) $(FFLAGS) $(OFLAG) $(INCS) | ||
Line 38: | Line 38: | ||
:<pre>FREE=-ffree-form -ffree-line-length-none</pre> | :<pre>FREE=-ffree-form -ffree-line-length-none</pre> | ||
== MPI + OpenMP parallelization== | |||
To compile VASP with OpenMP support, add the following to the list of [[Installing_VASP.6.X.X#Precompiler_variables|precompiler flags]] in your <code>makefile.include</code> file: | |||
CPP_OPTIONS += -D_OPENMP | |||
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 = | = Special rules = | ||
The current <code>src/makefile</code> contains a set of recipes to allow for the compilation of objects at different levels of optimization | The current <code>src/makefile</code> contains a set of recipes to allow for the compilation of objects at different levels of optimization other than the general level specified by <code>OFLAG</code>. | ||
In these recipes the compiler will be invoked as: | In these recipes, the compiler will be invoked as: | ||
$(FC) $(FREE) $(FFLAGS_x) $(OFLAG_x) $(INCS_x) | $(FC) $(FREE) $(FFLAGS_x) $(OFLAG_x) $(INCS_x) | ||
Line 55: | Line 65: | ||
:Default: <code>INCS_x=$(INCS)</code>, for x=1, 2, 3, and IN. | :Default: <code>INCS_x=$(INCS)</code>, 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: | The objects to be compiled in accordance with these recipes have to be specified by means of the variables: <code>OBJECTS_O1</code>, <code>OBJECTS_O2</code>, <code>OBJECTS_O3</code>, <code>OBJECTS_IN</code> | ||
<code>OBJECTS_O1</code>, <code>OBJECTS_O2</code>, <code>OBJECTS_O3</code>, <code>OBJECTS_IN</code> | |||
Several objects are compiled at <code>-O1</code> and <code>-O2</code> by default. These lists of objects are specified in the '''/path/to/vasp.X.X.X/src/.objects''' file through the variables: <code>SOURCE_O1</code>, <code>SOURCE_O2</code>, <code>SOURCE_IN</code>. | |||
To completely overrule a default setting (for instance for the <code>-O1</code> special rules) you can use the following construct: | |||
SOURCE_O1 = | |||
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]] | |||
---- | |||
[[Category:VASP]][[Category:Installation]][[Category:Performance]][[Category:GPU]] | |||
Latest revision as of 14:37, 20 February 2024
The compiler options are specified by compiler variables that set the compiler and compiler flags. 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 ofmakefile.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
MPI + OpenMP parallelization
To compile VASP with OpenMP support, add the following to the list of precompiler flags in your makefile.include
file:
CPP_OPTIONS += -D_OPENMP
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.
FFLAGS_x
- Default:
FFLAGS_x=$(FFLAGS)
, for x=1, 2, 3, and IN.
OFLAG_x
- Default:
OFLAG_x=-Ox
(for x=1, 2, 3), andOFLAG_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
.
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 ..
Related articles
Installing VASP.6.X.X, makefile.include, Precompiler options, Linking to libraries, OpenACC GPU port of VASP, Toolchains, Validation tests, Known issues