makefile

From WikiROMS
Jump to navigationJump to search
makefile

ROMS has a single makefile located in the top-level directory. Its generic structure facilitates the compiling of ROMS with other coupled models. The user usually needs to check/modify few definitions in the makefile before compiling a particular applications to specify primarily Fortran compiler, parallel options, and 64-bit floating-point number precision.

User Changes to makefile

As a user, you need to check and perhaps edit the makefile to set the value or leave blank for the following macro definitions:

ROMS_APPLICATION ?=
CPP option defining a particular application (for example, UPWELLING). The makefile will include its associated header file which is located in either the ROMS/Include directory or the path specified in the MY_HEADER_DIR definition. The header file name is the lowercase value of ROMS_APPLICATION with the .h extension (for example, upwelling.h). Recall the CPP option defining an application must be unique.
MY_HEADER_DIR ?=
Application header file full directory path. Recall that a ROMS header file contains all the CPP options defining a particular application. This is the header file that it is included in cppdefs.h. Notice that if the header file is located in the ROMS/Include directory, it is possible to include the same header file name located somewhere else because the full directory path is specified here. This is very convient. The user may copy the distributed header file(s) into a different directory and modify it to explore different CPP options.
MY_ANALYTICAL_DIR ?=
Directory containing an application analytical expressions, if any. Templates of the analytical expressions are provided in the User/Functional directory. If analytical expressions are activated, the makefile will load first the ones located in MY_ANALYTICAL_DIR and then the ones located in ROMS/Functionals. We recommended to not modify the analytical expressions in the ROMS/Functionals directory since these are the official version of these files and reported in the literature. The user however can modify these expresions somewhere else in the directory path specified here.
MY_CPP_FLAGS ?=
Additional CPP options to activate. Sometimes it is desirabel to activate one or more CPP options to run different variants of the same application without modifying its header file. If this is the case, specify such options here using the -D syntax. For example, to write out time-averaged NetCDF file use -DAVERAGES.
DEBUG :=
Used to turn on symbolic debug information with no optimization.
MPI :=
Used to turn on distributed-memory parallelization in ROMS and linking to the Message Passing Interface (MPI) library.
MPIF90 :=
Used to turn on the MPICH implementation of MPI via the compilation script mpif90 which is required in some Linux operating systems without a native MPI library (-lmpi). This definition macro is also convinient when there are several Fortran-90 compilers (ifort, pgf90, pathf90) in the system that use the mpif90 compilation command. In this case, the user needs turn on both MPI and MPIF90 definitions and specify the appropriate Fortran-90 compiler in FORTRAN macro definition.
OPENMP :=
Used to turn on shared-memory parallelization in ROMS using the OpenMP compiler directives.
ARPACK :=
Used to turn on linking to the ARPACK library which is used to solve large Ritz eigenvalue problems in the adjoint-based Generalized Stability Theory (GST) analysis.
LARGE :=
Used to turn on 64-bit floating-point number precision.

The user also needs to specify the appropriate Fortran-90 compiler to use. The name of the Fortran-90 compiler depends on the operating system (see table below). This name is also used to determine the compiling configuration file to include in the makefile by concatenating the operating system (uname -s) and the chosen compiler name.

Operating System Compiler(s)
AIX xlf
ALPHA f90
CYGWIN g95, df
Darwin f90, gfortran, xlf
Linux ifc, ifort, pgi, path, g95
SunOS f95
SunOS/Linus ftn
UNICOS-mp ftn
FORTRAN ?=
Set the Fortran-90 compiler to use. Notice that since the ?= assigment is used, the value of this macro definition is only relevant if the environmental variable FORTRAN has not been defined. The environmental value takes precedence.

See gmake for additional documentation.

Compiler-dependent Changes

Also as a user, you need to be aware of the files in the Compilers directory. The top-level makefile will be including one of these files, based on combining the result of uname -s with the value of FORTRAN. For instance, it might be including Darwin-gfortran.mk if you are on a Mac and using the gfortran compiler. You need to make sure this file exists and has the correct values for the compiler options and for finding the NetCDF library. The file should contain pointers to both the NetCDF library and include files. If the library is different for 32-bit and 64-bit options, that needs to be taken care of as well. See Gmake#Conditionals for an example.