#!/bin/sh
#=======================================================================
# Run RCM                                                 --- rcmrun ---
# $Id: rcmrun_jobdef 267 2008-03-31 21:54:13Z acrnrls $
#=======================================================================
#     keyword :: rcmrun
# description :: run RCM
#        hide :: yes

set -a
. betapath2

#  * ........................... Parmsub Parameters ............................

 runid="job000"; uxxx='uxxx'; rcmrun_uxxx=$uxxx;
 crawork=${runid}_job; rcmrun_prefix=${rcmrun_uxxx}_$runid;
 nqsext="_${runid}"; prefix=${rcmrun_prefix}

 username="acrnxxx"; user="XXX";

 year="yyy"; mon="mm"; year_restart="yyy"; mon_restart="mm"; kfinal="0000000000";
 model=${prefix}_${year}_m${mon}_;
 start=${prefix}_${year_restart}_m${mon_restart}_;

 rcmtime="10800"; memory1="60000mb"

#  * ............................ Condef Parameters ............................

 nprocx=32

 nextjob=on
 noprint=off

# Both auto and rcm switches need to be turned on if a month run spans more 
# than a single job. In which case, a customized endjcl.cdk must be placed in
# the $HOME/bin_aix directory.

#auto=on
#rcm=on         

#  * ............................. Deck Definition .............................

#deck rcmrun
jobname=rcmrun; time=$rcmtime; memory=$memory1
. comjcl.cdk

cat > Execute_Script << 'end_of_script'

#               rcmrun                  EC. Feb 01/07
#  -----------------------------------  Run the RCM.

#  * Access the required files for the run.

   access AN ${model}an
   access INMRC ${model}inmrc
   access mrc_settings ${model}settings

   access NUGT ${model}sst
   access NUSIC ${model}sic
   access NUGC ${model}sicn

#  * Get the executable.

   access RCM mr_${runid}_ab

#  * Get restart files, if they exist.

   access OLDRS ${start}rs na
   access OLDDYRS ${start}dyrs na

#  * Set the runtime environment variable for OpenMP
#  * and launch the model.

   OMP_NUM_THREADS=$nprocx
   export OMP_NUM_THREADS

   hpmcount RCM

#  * Post process output files.

   pakgcm8 OUTMRC dummy OUTRCM

   cat > xsave_input <<......enddat
  XSAVE    U  DATA DESCRIPTION

  XSAVE    U  MODEL OUTPUT

......enddat

   xsave OLDEMTY OUTINV OUTRCM NEWGS input=xsave_input | msgxsvo

#  * Save the output and restart files.

   save NEWGS ${model}gs
   save NEWRS ${model}rs
   save NEWDYRS ${model}dyrs

end_of_script

. endjcl.cdk

#end_of_job
