Difference between revisions of "makefile"

From WikiROMS
Jump to navigationJump to search
Line 70: Line 70:
==Compiler-dependent Changes==
==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 [http://www.unidata.ucar.edu/software/netcdf/ 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.
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 '''FORT'''. 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 [http://www.unidata.ucar.edu/software/netcdf/ 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.

Revision as of 18:19, 28 May 2007

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 a value or leave blank few macro definitions. Notice that the macro definitions below use the ?= assigment so the environmental value has precedence. The makefile will set the value only if there is no value defined somewhere else. This is very convient and used in the compiling script build.sh located in the ROMS/Bin directory.

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 desirable 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.
NestedGrids ?=
Number of ROMS nested and/or composed grids. The default value is 1. Currently, only one grid is supported. This definition is needed always since it used to dynamically allocate all ROMS arrays structures.
USE_DEBUG ?=
Used to turn on symbolic debug information with no optimization. Set it to on or leave it blank.
USE_MPI ?=
Used to turn on distributed-memory parallelization in ROMS and linking to the Message Passing Interface (MPI) library. Set it to on or leave it blank.
USE_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. Set it to on or leave it blank.
USE_OPENMP ?=
Used to turn on shared-memory parallelization in ROMS using the OpenMP compiler directives. Set it to on or leave it blank.
USE_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 and 4Dvar preconditioning. Set it to on or leave it blank.
USE_LARGE ?=
Used to turn on 64-bit floating-point number precision. Set it to on or leave it blank.
SWAN_COUPLE ?=
Used to turn coupling to the SWAN model. Set it to on or leave it blank.

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, ifort
Darwin f90, gfortran, xlf
Linux ftn, ifc, ifort, pgi, path, g95, gfortran
SunOS f95
SunOS/Linus ftn
UNICOS-mp ftn
FORT ?=
Set the Fortran-90 compiler to use.
BINDIR ?=
Set directory path for the compiled executable.

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