#!/bin/sh set -xa export MP_IOAGENT_CNT=all export MP_IO_BUFFER_SIZE=8M ########################################################################## # Runs NEMS GFS AEROSOL COMPONENT (NGAC) initialization # # Author: Sarah Lu ; Dec 05 2011 # # # # REVISION HISTORY: # # 13Jan2012 Sarah Lu Add cold start option # # 19Jan2012 Sarah Lu Modify err_check and remove file copy # # 29Mar2012 Sarah Lu Add ngac_para_config # # 15Jun2012 Sarah Lu Streamline the code to comply the NCO guideline # ########################################################################## # # Specify whether the run is production or development # export RUN_ENVIR=${RUN_ENVIR:-prod} # ################################################################ # Specify NET and RUN Name and model ################################################################ export NET=${NET:-ngac} export RUN=${RUN:-ngac} ################################################################ # Run config file to get input parameters for the developers ################################################################ if [ $RUN_ENVIR != prod ] ### For Developers then . ${PARA_CONFIG:-/global/save/wx23lu/NGAC/nwprod_2jif/parm/ngac_para_config} fi ################################################################ # This block can be modified for different test environment ################################################################ if [ $RUN_ENVIR = prod -a $envir != prod ]; then export SENDDBN=${SENDDBN:-NO} export jlogfile=${jlogfile:-/com/logs/${envir}/jlogfile} export utilexec=${utilexec:-/nw${envir}/util/exec} export DBNROOT=/nwprod/spa_util/fakedbn else # export LOGDIR=${DATA_IN}/logs export LOGDIR=/com/logs mkdir -m 775 -p $LOGDIR export jlogfile=${jlogfile:-${LOGDIR}/jlogfile} fi if [[ $RUN_ENVIR = prod || ${DEV_SMS:-YES} = YES ]] ; then $SMSBIN/smsinit $LOADL_STEP_ID fi # ################################################################ # set up job name and environment ################################################################ export job=${job:-$RUN} export envir=${envir:-prod} export host=${host:-`hostname | cut -c1`} ################################################################ # SETUP NGAC PROCESSING VARIABLES ################################################################ export PS4='$SECONDS + ' date ################################################################ # obtain unique process id (pid) and make temp directory ################################################################ export pid=${pid:-$$} export DATA_IN=${DATA_IN:-/tmpnwprd} export DATA=${DATA:-$DATA_IN/${job}.${pid}} mkdir -p $DATA cd $DATA #################################### # Specify NGAC version number #################################### export NGAC_VERSION=${NGAC_VERSION:-${model_ver}} ################################################################ # Specify Execution Areas ################################################################ export HOMEngac=${HOMEngac:-/nw${envir}/ngac.${NGAC_VERSION}} export EXECngac=${EXECngac:-$HOMEngac/exec} export FIXngac=${FIXngac:-$HOMEngac/fix} export USHngac=${USHngac:-$HOMEngac/ush} export PARMngac=${PARMngac:-$HOMEngac/parm} export SCRIPTDIR=${SCRIPTDIR:-$HOMEngac/scripts} export HOMEGLOBAL=${HOMEGLOBAL:-/nw${envir}} export EXECGLOBAL=${EXECGLOBAL:-$HOMEGLOBAL/exec} export FIXGLOBAL=${FIXGLOBAL:-$HOMEGLOBAL/fix} export USHGLOBAL=${USHGLOBAL:-$HOMEGLOBAL/ush} export PARMGLOBAL=${PARMGLOBAL:-$HOMEGLOBAL/parm} ################################################################ # Specify CONFIG_FILE ################################################################ export CONFIG_FILE=${CONFIG_FILE:-$PARMngac/ngac_config} [[ $(dirname $CONFIG_FILE) = . ]]&&CONFIG_FILE=$(pwd)/$CONFIG_FILE if [[ ! -r $CONFIG_FILE ]];then echo $0: inaccessible configuration file $CONFIG_FILE >&2 err_exit fi ################################################################ # Determine Job Output Name on System ################################################################ export cyc=${cyc:-00} export outid="LL$job" export jobid="${outid}.o${pid}" export pgmout="OUTPUT.${pid}" export pgmerr=errfile export cycle=t${cyc}z ################################################################ # 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 prep from beginning (default no) # VERBOSE - Specify Verbose Output ################################################################ export SAVEGES=${SAVEGES:-YES} export SENDSMS=${SENDSMS:-YES} export SENDCOM=${SENDCOM:-YES} export SENDDBN=${SENDDBN:-YES} export RERUN=${RERUN:-NO} export VERBOSE=${VERBOSE:-YES} ################################################################ # Set up the UTILITIES ################################################################ export utilscript=${utilscript:-/nwprod/util/ush} export utilexec=${utilexec:-/nwprod/util/exec} export err_chk=${err_chk:-$utilscript/err_chk.sh} export startmsg=${startmsg:-$utilscript/startmsg.sh} export ERRSCRIPT=${ERRSCRIPT:-$err_chk} export LOGSCRIPT=${LOGSCRIPT:-$startmsg} ################################################################ # Run setup to initialize working directory and utility scripts ################################################################ sh $utilscript/setup.sh # export PDY=20120624 ################################################################ # Run setpdy and initialize PDY variables ################################################################ sh $utilscript/setpdy.sh . PDY export CDATE=${CDATE:-${PDY}$cyc} ################################################################ # Get the variables setup from config script ################################################################ set -a; . $CONFIG_FILE; set +a env export MP_SHARED_MEMORY=${MP_SHARED_MEMORY:-no} # ################################################################ # Define COM and GES directories ################################################################ export COM_IN=${COM_IN:-/com/${NET}/${envir}} export COM_OUT=${COM_OUT:-/com/${NET}/${envir}} export gespath=${gespath:-/nwges/${envir}} export COMIN=${COMIN:-$COM_IN/${RUN}.${PDY}} export COMOUT=${COMOUT:-$COM_OUT/${RUN}.${PDY}} export GESdir=${GESdir:-$gespath/${RUN}.${PDY}} mkdir -m 775 -p $COMOUT mkdir -m 775 -p $GESdir ##### ------------- prep job starts here -------------------------------- msg="NGAC_PREP HAS BEGUN on`hostname`" $DATA/postmsg "$jlogfile" "$msg" ################################################################ # Define Output File Names ################################################################ ## Note: Output files from prep are input files for fcst export GRDI=${GRDI:-$GESdir/${RUN}.${cycle}.gfsanl} export SFCI=${SFCI:-$GESdir/${RUN}.${cycle}.sfcanl} ################################################################ # Check Upstream Dependency: NGAC forecasts ################################################################ ### NGAC forecasts are needed for warm start runs if [ ${COLD_START:-NO} = NO ] ; then ndays_max=${ndays_max:-5} ## max time window for guess file ndays=1 found=0 while [[ $ndays -le $ndays_max ]]; do nhours=`expr $ndays \* 24` ymdh=`$ndate -$nhours $CDATE` ymd=`echo $ymdh | cut -c1-8` export SIG_TEMP=$COM_OUT/${RUN}.${ymd}/${RUN}.${cycle}.sigf${nhours} export SFC_TEMP=$COM_OUT/${RUN}.${ymd}/${RUN}.${cycle}.sfcf${nhours} if eval test -f $SFC_TEMP -a -f $SIG_TEMP then export SIG_NGAC=$SIG_TEMP export SFC_NGAC=$SFC_TEMP found=1 ## sig/sfc files found break ## break the while-loop fi ndays=`expr $ndays + 1` done if [ $found -ne 1 ]; then msg="NGAC Prep Cannot Start/Guess Fields Not Available" postmsg "$jlogfile" "$msg" export pgm=JNGAC_PREP export err=1; err_chk else msg="NGAC Prep Guess Fields Found" postmsg "$jlogfile" "$msg" fi fi ################################################################ # Check Upstream Dependency: High-Resol GDAS analyses ################################################################ ### High-Resol GDAS analyses are needed for cold start or replay run if [ ${COLD_START:-NO} = YES -o ${DO_REPLAY:-YES} = YES ] ; then if [ ${RETRO:-NO} = YES ]; then msg="This is a retro run" postmsg "$jlogfile" "$msg" if [ $CDUMP=gfs -o $CDUMP=gdas ]; then export SIG_GDAS=/global/shared/dump/${CDATE}/$CDUMP/siganl.$CDUMP.$CDATE export SFC_GDAS=/global/shared/dump/${CDATE}/$CDUMP/sfcanl.$CDUMP.$CDATE else msg="NGAC Prep Cannot Start/CDUMP Option Not Supported" postmsg "$jlogfile" "$msg" export pgm=JNGAC_PREP export err=1; err_chk fi else msg="This is a real-time run" postmsg "$jlogfile" "$msg" if [ $CDUMP = gfs ]; then export SIG_GDAS=$COMDIR/$CDUMP.${PDY}/gfs.t00z.sanl export SFC_GDAS=$COMDIR/$CDUMP.${PDY}/gfs.t00z.sfcanl elif [ $CDUMP = gdas ]; then export SIG_GDAS=$COMDIR/$CDUMP.${PDY}/gdas1.t00z.sanl export SFC_GDAS=$COMDIR/$CDUMP.${PDY}/gdas1.t00z.sfcanl else msg="NGAC Prep Cannot Start/CDUMP Option Not Supported" postmsg "$jlogfile" "$msg" export pgm=JNGAC_PREP export err=1; err_chk fi fi if eval test -f $SFC_GDAS -a -f $SIG_GDAS then msg="GDAS Analysis Fields Found" postmsg "$jlogfile" "$msg" else msg="NGAC Prep Cannot Start/GDAS Analyses Not Available" postmsg "$jlogfile" "$msg" export pgm=JNGAC_PREP export err=1; err_chk fi fi ################################################################ # Execute the script ################################################################ msg="Submit NGAC Prep Job" postmsg "$jlogfile" "$msg" export PREP_SCRIPT_DIR=${PREP_SCRIPT_DIR:-$SCRIPTDIR} export PREP_SCRIPT=${PREP_SCRIPT:-$PREP_SCRIPT_DIR/exngac_prep.sh.sms} $PREP_SCRIPT ##### ------------- prep job ends here -------------------------------- ################################################### # msg end of job and clean up temperary directory ################################################### msg="ENDED NORMALLY." postmsg "$jlogfile" "$msg" cd $DATA_IN if [ ${RM_TMPDIR:-YES} = YES ] ; then rm -rf $DATA ; fi date if [[ $RUN_ENVIR = prod || ${DEV_SMS:-YES} = YES ]] ; then $SMSBIN/endt ; fi