build roms

From WikiROMS
Revision as of 21:27, 16 June 2008 by Kate (talk | contribs) (part of big rewrite)
Jump to navigationJump to search
Build Script - build.sh, build.bash

As mentioned in makefile, you need to provide settings for some user-defined choices before you can compile ROMS. If you have more than one application (or more than one compiler), you may get tired of editing the makefile. One option is to have a makefile for each configuration, then type:

 make -f makefile.circle_pgi

for instance. If that's too cumbersome, there's also an option of keeping track of the user-defined choices in a build script. There are now two of these scripts in the ROMS/Bin directory: build.sh (which is surprisingly a csh script) and build.bash. The build scripts use environment variables to provide values for the list above, overwriting those found in the ROMS makefile. Just as in the multiple makefile option, you will need as many build scripts as you have applications. The scope of these variables is local to the build script, allowing you to compile different applications at the same time from the same sources as long as each $(SCRATCH_DIR) is unique.

Usage:

./build.sh [options]

Options:

-j [N] Compile in parallel using N CPUs. Omit argument to compile on all availabe CPUs.
-noclean Do not clean already compiled objects.

Example:

./build.sh -j 2

The new structure of ROMS (version 3.0 or higher) allows user specific CPP definitions and analytical options to be set in a small number of separate standalone header files. Therefore, users no longer have to modify small blocks of code within huge files as was necessary in previous versions (cppdefs.h and analytical.F). This makes it easy to distribute the configuration for a specific application via a small number of source code related files plus the inputs (grid, initial conditions, and forcing NetCDF files), while allowing users of the application to keep current with central code improvements via svn. This also takes care of all licensing issues. You are free to include your own statement of your contributions in the files you distribute. The license and copyright statements by the ROMS developer group remain in the source code distributed at www.myroms.org.

We recommend that users work with a local source code that is regularly updated with the official version at the ROMS svn repository using svn update. This will allow bug fixes and new code developments to be pushed out to users and minimize the risk of a user unwittingly working with code with known flaws. There are a few standalone applications in ROMS website Datasets menu. The user can download any of these set-ups. Note that these applications do not include the source code since the user can checkout the latest version of ROMS from the svn repository. We usually create a Projects root directory containing all applications. For example, the double gyre test case (double_gyre.tar.gz) has the following directory structure:

 Projects                               root directory 
         /double_gyre                   idealized double gyre test case 
                     /Data              input NetCDF files 
                     /Forward           nonlinear model, ensembles 
                     /IS4DVAR           incremental, strong contraint 4DVar 
                     /OBS               data assimilation observations

If you check the IS4DVAR sub-directory, you will find the following files:

 Projects 
         /double_gyre 
                     /IS4DVAR 
                             /build.sh
                             /double_gyre.h
                             /job_is4dvar.sh
                             /is4dvar.in
                             /ocean_double_gyre.in
                             /s4dvar.in

Notice that there is a local copy of the header file double_gyre.h containing the CPP options to use in this application. We highly recommend that the user have a local copy of the header file instead of editing the distributed files in the ROMS/Include directory. During the compilation build.sh will direct make to use the appropriate one.

Environment Variables

Currently, the build.sh and build.bash set the following environment variables described in makefile as well as a few local to the scripts:


  • If appropriate, remove build directory.
    if ( $clean == 1 ) then
    make clean
    endif
  • Finally, compile application.
    if ( $parallel == 1 ) then
    make $NCPUS
    else
    make
    endif