Compiler options: Difference between revisions

From VASP Wiki
(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
Line 1: Line 1:
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:
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 37: Line 37:
:*Using gfortran:
:*Using gfortran:
:<pre>FREE=-ffree-form -ffree-line-length-none</pre>
:<pre>FREE=-ffree-form -ffree-line-length-none</pre>
= 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 (other than the general level specified by <code>OFLAG</code>).
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 53:
: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:<br />
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 <tt>path/to/vasp.X.X.X/src/.objects</tt> file through the variables:<br />
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>.
<code>SOURCE_O1</code>, <code>SOURCE_O2</code>, <code>SOURCE_IN</code>


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 <code>-O1</code> special rules) you can use the following construct:
SOURCE_O1  =
OBJECTS_O1 = .. your list of objects ..


To completely overrule a default setting (for instance for the <code>-O1</code> special rules) you can use the following construct:
----
SOURCE_O1 =
[[The_VASP_Manual|Contents]]
OBJECTS_O1= .. your list of objects ..
 
[[Category:VASP]]
[[Category:Installation]]

Revision as of 09:46, 20 January 2022

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 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.

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 ..

Contents