Next: 3.6 Running MITgcm
Up: 3. Getting Started with
Previous: 3.4.2 Directory structure of
Contents
3.5 Building the code
To compile the code, we use the make program. This uses a file
(Makefile) that allows us to pre-process source files, specify
compiler and optimization options and also figures out any file
dependencies. We supply a script (genmake2), described in
section 3.16.2, that automatically creates the Makefile for you. You then need to build the dependencies and
compile the code.
As an example, let's assume that you want to build and run experiment
verification/exp2. The are multiple ways and places to
actually do this but here let's build the code in
verification/exp2/input:
% cd verification/exp2/input
First, build the Makefile:
% ../../../tools/genmake2 -mods=../code
The command line option tells genmake to override model source
code with any files in the directory ../code/.
On many systems, the genmake2 program will be able to
automatically recognize the hardware, find compilers and other tools
within the user's path (``echo $PATH''), and then choose an
appropriate set of options from the files (``optfiles'') contained in
the tools/build_options directory. Under some circumstances, a
user may have to create a new ``optfile'' in order to specify the
exact combination of compiler, compiler flags, libraries, and other
options necessary to build a particular configuration of MITgcm. In
such cases, it is generally helpful to read the existing ``optfiles''
and mimic their syntax.
Through the MITgcm-support list, the MITgcm developers are willing to
provide help writing or modifing ``optfiles''. And we encourage users
to post new ``optfiles'' (particularly ones for new machines or
architectures) to the
mitgcm-support@dev.mitgcm.org
MITgcm-support@mitgcm.org
list.
To specify an optfile to genmake2, the syntax is:
% ../../../tools/genmake2 -mods=../code -of /path/to/optfile
Once a Makefile has been generated, we create the dependencies:
% make depend
This modifies the Makefile by attaching a [long] list of files
upon which other files depend. The purpose of this is to reduce
re-compilation if and when you start to modify the code. The make
depend command also creates links from the model source to this
directory. It is important to note that the make depend stage
will occasionally produce warnings or errors since the dependency
parsing tool is unable to find all of the necessary header files
(eg. netcdf.inc). In these circumstances, it is
usually OK to ignore the warnings/errors and proceed to the next step.
Next compile the code:
% make
The make command creates an executable called mitgcmuv.
Additional make ``targets'' are defined within the makefile to aid in
the production of adjoint and other versions of MITgcm.
Now you are ready to run the model. General instructions for doing so are
given in section 3.6. Here, we can run the model with:
./mitgcmuv > output.txt
where we are re-directing the stream of text output to the file output.txt.
Next: 3.6 Running MITgcm
Up: 3. Getting Started with
Previous: 3.4.2 Directory structure of
Contents
mitgcm-support@dev.mitgcm.org
Copyright © 2002
Massachusetts Institute of Technology |
|
|