Next: 3.4.1 Building/compiling the code
Up: 3. Getting Started with
Previous: 3.3 Model and directory
Contents
3.4 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.4.2, that automatically creates the
Makefile for you. You then need to build the dependencies and
compile the code.
As an example, 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/build:
% cd verification/exp2/build
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@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 with the command:
% make depend
This modifies the Makefile by attaching a (usually, 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 one can compile the code using:
% 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. On SMP
(shared multi-processor) systems, the build process can often be sped
up appreciably using the command:
% make -j 2
where the ``2'' can be replaced with a number that corresponds to the
number of CPUs available.
Now you are ready to run the model. General instructions for doing so are
given in section 3.5. Here, we can run the model by
first creating links to all the input files:
ln -s ../input/* .
and then calling the executable with:
./mitgcmuv > output.txt
where we are re-directing the stream of text output to the file
output.txt.
Subsections
Next: 3.4.1 Building/compiling the code
Up: 3. Getting Started with
Previous: 3.3 Model and directory
Contents
mitgcm-support@mitgcm.org
Copyright © 2006
Massachusetts Institute of Technology |
Last update 2011-01-09 |
|
|