#!/bin/sh ############################################################# # Setup environment for the SREF's downscaling job # # change log: # 12/10/2011 Jun Du, initial implementation # ############################################################# set -xa # # Specify whether the run is production or development # export RUN_ENVIR=${RUN_ENVIR:-prod} ##################################################################################### # Run config file to get input parameters # This config file should define the following variables # DATA_IN: Location of working directory, default to /tmpnwprd # DEV_SMS: If the job is to be running using SMS, default to YES # SENDDBN: Set to NO for developers, default to YES # COM_IN: Directory for input files, default to /com/$NET/${envir} # COM_OUT: Directory for output file, default to /com/$NET/${envir} # gespath: Directory for the guess or restart files, default to /nwges/${envir} ##################################################################################### if [ "$RUN_ENVIR" != prod ] ### For Developers, "group_name" is passed from the SMS script then CONFIG_FILE=${CONFIG_FILE:-/meso/save/${LOGNAME}/sref/nwprod/parm/sref_para_config} . $CONFIG_FILE export userid=$LOGNAME export DATA_IN=${DATA_IN:-/ptmp/$userid} fi ############################################################### # This block can be modified for different test environment ############################################################### if [ $RUN_ENVIR = prod -a $envir != prod ]; then export DBNROOT=/nwprod/spa_util/fakedbn export jlogfile=${jlogfile:-/com/logs/${envir}/jlogfile} fi if [[ $RUN_ENVIR = prod || ${SENDSMS:-YES} = YES ]] ; then $SMSBIN/smsinit $LOADL_STEP_ID fi echo `date` $0 `date -u` begin export PS4='$SECONDS + ' ########################################################### # obtain unique process id (pid) and make temp directories ########################################################### export pid=$$ export DATA_IN=${DATA_IN:-/tmpnwprd} export DATA=$DATA_IN/${job}.${pid} rm -rf $DATA mkdir -p $DATA cd $DATA #################################### # File To Log Msgs #################################### export jlogfile=${jlogfile:-/com/logs/jlogfile} #################################### # Determine Job Output Name on System #################################### export outid="LL$job" export jobid="${outid}.o${pid}" export pgmout="OUTPUT.${pid}" export cycle=t${cyc}z ############################### # Specify NET and RUN name ############################## export NET=sref export RUN=sref ################################################## # SAVEGES - Copy Files From TMPDIR to $GESdir # SENDSMS - Flag Events on SMS # SENDCOM - Copy Files From TMPDIR to $COMOUT # SENDDBN - Issue DBNet Client Calls # RERUN - Rerun fcst from beginning (default no) ################################################## export SENDCOM=${SENDCOM:-YES} export SENDSMS=${SENDSMS:-YES} export SENDDBN=${SENDDBN:-YES} export VERBOSE=${VERBOSE:-YES} export HOMEsref=${HOMEsref:-/nw${envir}/${NET}.${model_ver}} export EXECsref=${EXECsref:-$HOMEsref/exec} export FIXsref=${FIXsref:-$HOMEsref/fix} export PARMsref=${PARMsref:-$HOMEsref/parm} export USHsref=${USHsref:-$HOMEsref/ush} export HOMEglobal=${HOMEglobal:-/nwprod} export EXECglobal=$HOMEglobal/exec export FIXglobal=$HOMEglobal/fix export PARMglobal=$HOMEglobal/parm export USHglobal=$HOMEglobal/ush ################################### # Set up the UTILITIES ################################### export utilscript=/nwprod/util/ush export utilexec=/nwprod/util/exec # Run setup to initialize working directory and utility scripts sh $utilscript/setup.sh # Run setpdy and initialize PDY variables sh $utilscript/setpdy.sh . PDY ############################################# # COMIN and COMOUT ############################################# export COM_IN=${COM_IN:-/com/${NET}/${envir}} export COM_OUT=${COM_OUT:-/com/${NET}/${envir}} export gespath=${gespath:-/nwges/${envir}} export com=${com:-$COM_IN} export GES_IN=${GES_IN:-$gespath} export GESDIR=$GES_IN/${NET}.${PDY} export COMIN=$COM_IN/${RUN}.${PDY}/${cyc}/pgrb #export COMIN_ENSPRD=${COMIN_ENSPRD:-$COM_IN/${RUN}.${PDY}/${cyc}/ensprod} export COM_NDGD=${COM_NDGD:-$COM_IN/${RUN}.${PDY}/${cyc}/pgrb_ndgd} export COM_MISC=${COM_MISC:-$COM_IN/${RUN}.${PDY}/${cyc}/misc} export COMIN_BC=${COMIN_BC:-$COM_OUT/${RUN}.${PDY}/$cyc/pgrb_biasc} export COMOUT=$COM_OUT/${RUN}.${PDY}/$cyc/pgrb_biasc export COMOUT_BC=$COM_OUT/${RUN}.${PDY}/${cyc}/ensprod_biasc export COMOUT_NDGD=$COM_OUT/${RUN}.${PDY}/${cyc}/ensprod_ndgd export GESNDAS=${GESNDAS:-/nwges/prod} export COMNAM=${COMNAM:-/com/nam/prod} export COMENS=${COMENS:-/com/gens/prod} export COMGFS=${COMGFS:-/com/gfs/prod} mkdir -p -m 775 $COM_NDGD $COMOUT_NDGD env ####################################################### # Pass information which is needed to run the Script ####################################################### export ENDHOUR=87 export INCHOUR=03 export VERBOSE=YES ################################################### # Execute the Script ################################################### # 1. Downscaling vector calculation export COMRTMA=${COMRTMA:-/com/rtma/prod} mkdir -m 775 $DATA/downscalevector cd $DATA/downscalevector /nwprod/util/ush/setup.sh $HOMEsref/scripts/exsref_caldwnsvect.sh.sms # 2. Downscaling forecast (note: this job has to be run after Job 1 finishes!) mkdir -m 775 $DATA/downscaleforecast cd $DATA/downscaleforecast /nwprod/util/ush/setup.sh rm -rf $DATA/downscaleforecast/poescript typeset -Z2 HR HR=03 while [ $HR -le $ENDHOUR ] do mkdir -m 775 $DATA/downscaleforecast/$HR echo "$HOMEsref/scripts/exsref_dwnsfcst.sh.sms $HR > $DATA/downscaleforecast/${HR}.out " >>$DATA/downscaleforecast/poescript HR=`expr $HR + $INCHOUR` done chmod 775 $DATA/downscaleforecast/poescript export MP_PGMMODEL=mpmd export MP_CMDFILE=$DATA/downscaleforecast/poescript /usr/bin/poe -cmdfile $DATA/downscaleforecast/poescript -pgmmodel mpmd -ilevel 3 -labelio yes -stdoutmode ordered # 3. Ensemble product of downscaled forecasts (note: this job has to be run after Job 2 finishes!) mkdir -m 775 $DATA/downscaleproduct cd $DATA/downscaleproduct /nwprod/util/ush/setup.sh $HOMEsref/scripts/exsref_enspost_afterDS.sh.sms 3hrly 197 111 ######################################################## cat $pgmout msg="JOB COMPLETED NORMALLY" postmsg "$jlogfile" "$msg" ################################ # Remove the Working Directory ################################ cd $DATA_IN if [ ${RM_TMPDIR:-YES} = YES ] ; then rm -rf $DATA ; fi date if [ $SENDSMS = YES ]; then $SMSBIN/smscomplete fi