NCAR CSM Pacific Basin Model, version 3.e -- User's Guide         <<     Table of Contents     >>

2   Batch Job Scripts

In this section we examine an example Network Queuing System (NQS) shell script and a model setup script. The example scripts shown below are complete scripts, suitable for actual use. While the specifics shown below are a recommended method for running the model on one of NCAR's Cray computers, variations of this method will also work, some of which may be more appropriate for different situations.

 §2.1  NQS Script
 §2.2  Setup Script

2.1   NQS Script

The Pacific model batch job script below is a top-level NQS batch job script which in turn calls a separate subscript called a "setup script." The subscript, called "pac3.setup.csh", is responsible for building the executable code, documenting the source code, and gathering any required input data files. The setup script receives input data from the parent NQS script by accessing environment variables set in the NQS script. After calling the setup subscript, the parent NQS script executes the Pacific model. When the Pacific model has completed, the NQS script saves stdout output and terminates. Following the example is a more detailed explanation of what is being done in the various parts of the NQS script.

    #=======================================================================
    #  This is a CSM Pacific Basin Model NQS batch job script
    #=======================================================================
    
    #-----------------------------------------------------------------------
    # (a) Set NQS options
    #-----------------------------------------------------------------------
    # QSUB -q   reg                      # select queue
    # QSUB -lT  5:01:00 -lt  5:00:00     # set time limits
    # QSUB -lM  8.00Mw                   # set memory limits
    # QSUB -mb -me -eo                   # combine stdout & stderr
    # QSUB -s  /bin/csh                  # select shell script
    # QSUB                               # no more qsub options
    
    #-----------------------------------------------------------------------
    # (b) Set env variables available to model setup script
    #-----------------------------------------------------------------------
    
    setenv CASE     test.01                # case name
    setenv CASESTR  'code test'            # short descriptive text string
    setenv RUNTYPE  initial                # run type
    setenv ARCH     C90                    # machine: C90,J90,...
    setenv MSS      TRUE                   # MSS is available?
    setenv MSSDIR   /DOE/pac3/$CASE        # MSS directory path name
    setenv MSSRPD   20                     # MSS file retention period
    setenv MSSPWD   $LOGNAME               # MSS file password
    setenv RPTDIR   $HOME                  # where restart pointer file goes
    
    #-----------------------------------------------------------------------
    # (c) Specify input & output (stdout & stderr) directories
    #-----------------------------------------------------------------------
    
    set EXEDIR = /tmp/$USER/pac3/$CASE
    set NQSDIR = /fs/cgd/home0/$USER/pac/nqs/$CASE
    set LOGDIR = $NQSDIR
    
    #-----------------------------------------------------------------------
    # (d) Prepare model for execution
    #-----------------------------------------------------------------------
    
    set LID = "`date +%y%m%d-%H%M%S`"      # a unique log file ID
    
    mkdir -p $EXEDIR
    cd       $EXEDIR 
    echo "Date: `date`"     >&! pac3.log.$LID
    $NQSDIR/pac3.setup.csh  >>! pac3.log.$LID || exit 99
    
    #-----------------------------------------------------------------------
    # (e) Execute model
    #-----------------------------------------------------------------------
    
    cd  $EXEDIR 
    if ($ARCH == 'C90' || $ARCH == 'J90') ja        $TMPDIR/jacct
    ocn < ocn.parm >>&  pac3.log.$LID
    if ($ARCH == 'C90' || $ARCH == 'J90') ja -ts    $TMPDIR/jacct
    
    #-----------------------------------------------------------------------
    # (f) save model output (stdout & stderr) to $LOGDIR
    #-----------------------------------------------------------------------
    
    ls -alFt
    gzip  pac3.log.$LID
    cp -p pac3.log.$LID*  $LOGDIR
    
    #======================================================================+
    # end of nqs shell script                                         
    #======================================================================+

Referring to items (a) through (f) in the NQS job script (above)...

(a) Set NQS options

The Network Queuing System (NQS) is a special facility available under UNICOS (Cray's version of UNIX). NQS is a batch job facility: you submit your job to NQS and NQS runs your job. The QSUB options set here select the queue, the maximum memory required, the maximum time required, the combining of the NQS script's stdout and stderr, and the shell to interpret the NQS script. See the qsub man page on an NCAR Cray computer for more information.

(b) Set environment variables available to model setup script

While the executing of the Pacific model is explicitly done in this NQS script, the building of the executable from source code, the gathering of necessary input data files, and any other pre-execution preparation is deferred to the subscript "pac3.setup.csh". The environment variables are set in the NQS script and may be used by the setup script to prepare the code for execution. In particular, these environment variables are used to create an input namelist. The exectuable code does not access any environment variables directly -- all input is via an input namelist. The environment variables are:

(c) Specify input, output, & execution directories

Here we specify the directory where the model will run, the directory where the model setup script is found, and the directory where stdout and stderr output data will be saved when the simulation finishes.

(d) Prepare the model for execution

Here the model setup script is invoked. The purpose of the setup script is to build the executable code, gather any necessary input data files, and do whatever bookkeeping is necessary to document what source code and what data files are being used.

(e) Execute the model

In this section we execute the model, redirecting stdin and stdout. The ja command is a UNICOS job accounting utility which provides data on CPU time used, memory used, etc. See the ja man page on a UNICOS system for more details.

(g) Save model output (stdout & stderr)

The stdout output file (combined with the stderr output) from the model is compressed and saved in the directory $LOGDIR.

2   Setup Script

All the necessary pre-execution preparation of the model is done by a cshell setup script called "pac3.setup.csh." This setup script is called by the parent NQS batch job script described above. This setup script gathers the source code, documents the source code, builds an executable, and gathers and/or creates any necessary data files. Following the example is a more detailed explanation of what is being done in the various parts of the setup script.
    #! /bin/csh -f
    #=======================================================================
    #  This is a c shell script that builds a binary and creates an
    #  input parameter namelist FOR THE UNCOUPLED VERSION
    #=======================================================================
    
    #-----------------------------------------------------------------------
    # (a) Build an executable                                         
    #-----------------------------------------------------------------------
    mkdir src
    cd    src
    cp -fp /fs/cgd/home0/kauff/pac/pac3.e/* .
    Makeprep
    make EXEC=../ocn ARCH=$ARCH
    cd ..
    
    #-----------------------------------------------------------------------
    # (b) document the source code used
    #-----------------------------------------------------------------------
    pwd ; ls -alFt   src       
    grep 'CVS' src/*.[hF]
    
    #-----------------------------------------------------------------------
    # (c) Create an input parameter namelist file
    #-----------------------------------------------------------------------
    cat >! ocn.parm  << EOF
     &inparm
      case_name   = '$CASE '
      case_desc   = '$CASE $CASESTR '
      rest_type   = '$RUNTYPE'
      rest_pfile  = '$RPTDIR/pac3.$CASE.rpointer '
      rest_bfile  = '/KAUFF/pac3/data/r0000-01-01'
      rest_date   = 00000101
      rest_freq   = 'monthly'
      stop_option = 'newmonth'
      hist_freq   = 'monthly'
      hist_tavg   = 1
      diag_freq   = 'monthly'
      mss_dir     =  '$MSSDIR'
      mss_pass    = ',$MSSPWD'
      mss_rtpd    =   $MSSRPD
      frc_wfile   = '/KAUFF/pac3/data/wind1.fsu.mnth'
      frc_cfile   = '/KAUFF/pac3/data/cloud.isccp.mnth'
      frc_tfile   = '/KAUFF/pac3/data/sst.str.mnth'
     /
    EOF
    
    echo "o contents of ocn.parm:" ; cat ocn.parm ; echo ' '
    echo "o contents of `pwd`:"    ; ls -alF      ; echo ' '
    
    #=======================================================================
    # end of setup shell script 
    #=======================================================================

Referring to items (a) and (c) in the model setup script (above)...

(a) Build an executable

The goal here is to build an executable binary in the current working directory. This is done creating a source code subdirectory called "src," gathering source code into this subdirectory, building a binary there, and linking to the binary in the /src subdirectory. Here we also find any Code Version System (CVS) keywords from the source code and do a directory listing to document the souce code that was used.

(b) document the source code used

Here we make a detailed listing of the source code used, a list of revision control system (CVS) information, and list of the contents of the current working directory. This information can be used to identify what model source code, input namelist, etc. were used in a particular simulation. This is not necessary but is strongly suggested.

(c) Create an input parameter namelist file

Here we are creating an input parameter namelist file. These input parameters specify details having to do with creating a case name, creation and use of restart files, starting and stopping dates for the simulation, creation of history and diagnostic data, the use of the MSS, and which forcing data files to use. This particular input namelist was selected just to illustrate how the pac3.setup.csh script works. For a detailed discussion of the model's input parameters, along with several example input namelists, see the Input Parameter section of this User's Guide.