§2.1  NQS 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)
 §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
#======================================================================+