#!/bin/ksh # ####################################################### # Bias Correct FNMOC Global Ensemble Forecast # ####################################################### ###################################################### # The following two variable could be defined in the # loadleveler submission script (the sms script), if # not they will take the default values which is set # for the NCO running enviroment ####################################################### set -xa ################################### # Specify NET and RUN Name and model #################################### export NET=${NET:-naefs} export RUN=${RUN:-fens} ##################################################################################### # DATAROOT: Location of working directory, default to /lfs/f1/ops/${envir}/tmp # SENDECF: 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 ${COMROOT}/$NET/${envir} # COM_OUT: Directory for output file, default to ${COMROOT}/$NET/${envir} ##################################################################################### export PS4='${PMI_FORK_RANK}: $SECONDS + ' # JY export PS4='${PMI_FORK_RANK}: $SECONDS `basename $0` + ' date #################################### # obtain unique process id (pid) and make temp directory #################################### export pid=$$ export DATAROOT=${DATAROOT:-/lfs/f1/ops/${envir}/tmp} export DATA=${DATA:-${DATAROOT:?}/${jobid}} mkdir -p $DATA cd $DATA #################################### # Determine Job Output Name on System #################################### export outid="LL$job" export jobid="${outid}.o${pid}" export pgmout="OUTPUT.${pid}" export pgmerr=errfile export cycle=t${cyc}z #################################### # File To Log Msgs #################################### export jlogfile=${jlogfile:-${DATA}/jlogfile.${job}.${pid}} ################################################################ # SENDCOM=YES--Copy output file to ${COMROOT} # SENDECF=YES--Allow to talk back to SMS # SENDDBN=YES--Alert output file to TOC, set to NO for testing ################################################################ export SENDCOM=${SENDCOM:-YES} export SENDDBN=${SENDDBN:-YES} # need to set to NO for testing export SENDECF=${SENDECF:-YES} #################################### # Specify Execution Areas #################################### export HOMEfnmoc=${HOMEfnmoc:-${PACKAGEROOT}/naefs.${naefs_ver}} export EXECfnmoc=${EXECfnmoc:-$HOMEfnmoc/exec} export FIXfnmoc=${FIXfnmoc:-$HOMEfnmoc/fix} export USHfnmoc=${USHfnmoc:-$HOMEfnmoc/ush} export ERRSCRIPT=err_chk export LOGSCRIPT=startmsg export REDOUT='1>>' export REDERR='2>' ############################## # Run setpdy and initialize PDY variables ############################## setpdy.sh . ./PDY ############################################## # Define COM directories ############################################## export DCOM=${DCOM:-${DCOMROOT}/$PDY/wgrbbul} export COMIN=${COMIN:-$DCOM/fnmoc_0p5_ens_gb2} export COMINBC=${COMINBC:-$DCOM/fnmoc_0p5_ens_bc_gb2} export COMINbias=${COMINbias:-$(compath.py $envir/$NET/${naefs_ver})} export COM_OUT=${COM_OUT:-$(compath.py -o $NET/${naefs_ver})} export COMOUT=$COM_OUT/${RUN}.${PDY}/${cyc}/pgrb2ap5 export COMOUTAN=$COM_OUT/${RUN}.${PDY}/${cyc}/pgrb2ap5_an export COMOUTWT=$COM_OUT/${RUN}.${PDY}/${cyc}/pgrb2ap5_wt export COMOUTBC=$COM_OUT/${RUN}.${PDY}/${cyc}/pgrb2ap5_bc mkdir -m 775 -p ${COMOUT} mkdir -m 775 -p ${COMOUTAN} mkdir -m 775 -p ${COMOUTWT} mkdir -m 775 -p ${COMOUTBC} msg="HAS BEGUN on `hostname`" postmsg "$jlogfile" "$msg" env ##################### # Execute the scripts ##################### runscript=$HOMEfnmoc/scripts/exnaefs_fnmoc_ens_debias.sh hourlist="000 003 006 009 012 015 018 021 024 027 030 033 036 039 042 045 048 \ 051 054 057 060 063 066 069 072 075 078 081 084 087 090 093 096 099 \ 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 \ 153 156 159 162 165 168 171 174 177 180 183 186 189 192 198 204 \ 210 216 222 228 234 240 246 252 258 264 270 276 282 288 294 300 \ 306 312 318 324 330 336 342 348 354 360 366 372 378 384" if [ -s $DATA/poescript ]; then rm -f $DATA/poescript fi for nhr in $hourlist; do mkdir -p $DATA/group.$nhr echo "$runscript \"$nhr\" $DATA/group.$nhr" >>$DATA/poescript done chmod +x $DATA/poescript startmsg $APRUN $DATA/poescript export err=$?; err_chk wait if [ -e ${DATA}/wallkill ]; then echo "................................................." >> ${DATA}/wallemail echo "jnaefs_fnmoc_ens_debias_${cyc} is about to exceed wall clock processing data of opportunity" >> ${DATA}/wallemail echo "Job will be allowed to complete" >> ${DATA}/wallemail echo "Run: ls ${COMIN}/ENSEMBLE.MET.fcst_et0*${cyc} | wc -l" >> ${DATA}/wallemail echo "and" >> ${DATA}/wallemail echo "Run: ls ${COMINBC}/ENSEMBLE.MET.fcst_bc0*${cyc} | wc -l" >> ${DATA}/wallemail echo "There should be 1365 files per directory per cycle" >> ${DATA}/wallemail echo "If files arrive soon, feel free to rerun" >> ${DATA}/wallemail echo "................................................." >> ${DATA}/wallemail cat ${DATA}/wallemail | mail.py -s "naefs - fnmoc outage" "nco.spa@noaa.gov,ncep.sos@noaa.gov,nco.sos@noaa.gov" -v exit fi ##################################### # calculate ensemble mean and spread ##################################### export DATAHOLD=$DATA export DATA=$DATAHOLD/dir_avgspr_bc mkdir -p $DATA cd $DATA $USHfnmoc/fnmocens_bc_avgspr.sh export DATA=$DATAHOLD/dir_avgspr mkdir -p $DATA cd $DATA $USHfnmoc/fnmocens_avgspr.sh cat $DATAHOLD/group.006/$pgmout.006.p02_an cat $DATAHOLD/group.006/$pgmout.006.p02_wt cat $DATAHOLD/group.360/$pgmout.360.p02_an cat $DATAHOLD/dir_avgspr_bc/$pgmout.012_avgspr cat $DATAHOLD/dir_avgspr/$pgmout.012_avgspr cat $DATAHOLD/dir_avgspr_bc/$pgmout.360_avgspr cat $DATAHOLD/dir_avgspr/$pgmout.360_avgspr msg="JOB COMPLETED NORMALLY" postmsg "$jlogfile" "$msg" ############################## # Remove the Temporary working directory ############################## if [ $KEEPDATA != YES ]; then cd $DATAROOT rm -rf $DATA rm -rf $DATAHOLD fi date