Skip to content

BeginnersGuide

Jatin Kala edited this page Dec 8, 2015 · 97 revisions

Beginner's guide to CABLE development

Please read the Guidelines for use and development of CABLE first. This page provides more specific technical details.

General tips

  • The Linux/UNIX grep command is very useful when doing model development. For example, you want to add a namelist switch. The easiest way would be to find out how existing switches are defined. Doing a recursive grep for an existing switch name would give you this information, for example:
grep -ri 'cable_user%FWSOIL_SWITCH' .
  • If the project involves several people, it is generally easier to have the code under share rather than your own user branch, as only you have write permission on your user branch, although this can be changed. Under share, anyone can write, which is easier (remember that any change can be un-done, so this is not an issue)
  • After modifying CABLE, it is worth doing a compile with both Intel (ifort) and GNU (gfortran). Intel generally has better performance, but lets you get away with being a bit slack, whereas GNU genrally is a bit more strict.
  • Un-initialized variables in Fortran will result in head-aches, be careful to Not introduce any!

Modifying build.ksh and build_mpi.ksh if your machine option is not already there

The build scripts starts near the end of the script and gets the first 4 characters of the hostname:

HOST_MACH=`uname -n | cut -c 1-4`

If your machine is not already defined, let's say it's called monsoon, then you would need to add at the top:

known_hosts()
{
   set -A kh cher burn shin raij mons
}

And then define the various environment variables as per existing examples:

host_mons()
{
   export NCDIR='/share/apps/netcdf/intel/4.2.1/lib'
   export NCMOD='/share/apps/netcdf/intel/4.2.1/include'
   export FC=ifort
   export CFLAGS='-O2 -fp-model precise'
   export LD='-lnetcdf -lnetcdff'
   export LDFLAGS='-L'$NCDIR' -O2'
   build_build
   cd ../
   build_status
}

To find out the path to NCDIR and NCMOD, you may try something like:

which ncdump

Also note that there is a clean option within the build script, which will do a clean re-compile:

./build_mpi.ksh clean

When debugging, one should usually compile without optimization and inlucde the traceback:

export CFLAGS='-O0 -traceback -g -fp-model precise -ftz -fpe0'

Some differences between git and svn

For users who use git but have never used svn, most command are the same, e.g., the equivalent of "git status" is simply "svn status". Note that while "git status" can be run anywhere within the repo, "svn status" should be run at the root of the repo or given full path.

I want to:

  • Add a new switch Switches of the type cable_user%some_switch_name are defined in core/biogeophys/cable_common.F90 under:
TYPE kbl_user_switches
Switches are usually either defined as logicals or characters  
  • Add new vegetation parameters to veg_param file
  • Single-site serial offline
  • Global MPI offline
  • Coupled ACCESS
  • Read a new 2D static parameter from a netcdf file
  • Single-site serial offline
  • Global MPI offline
  • Coupled ACCESS
  • Read a new 2D time-varying parameter from a netcdf file (e.g., a daily varying LAI)
  • Single-site serial offline
  • Global MPI offline
  • Coupled ACCESS
  • Add a new prognostic variable
  • Single-site serial offline
  • Global MPI offline
  • Coupled ACCESS
  • Output something which is not output by default
  • Single-site serial offline
  • Global MPI offline
  • Coupled ACCESS
  • Run CABLE with my own gridded forcing data
Clone this wiki locally