#!/bin/sh #################################### # Ensure environment is defined. #################################### set +x echo cyc is ${cyc:?} echo envir is ${envir:?} echo rtofs_glo_ver is ${rtofs_glo_ver:?} export PS4='$SECONDS + ' date env set -xa ####################################### # Specify NET and RUN Name and model ID ####################################### export NET=rtofs export RUN=rtofs export modID=glo export RUN_MODE=forecast export RUN_STEP=step2 export HYCOM_EXPT=930 export mycyc='00' export cycle=t${mycyc}z ########################################################## # obtain unique process id (pid) and make temp directories ########################################################## jobname=${PBS_JOBNAME} export DATA=${DATA:-${DATAROOT}/${jobname}_${model_ver}/${jobid}} export DATArestart=${DATAROOT}/${jobname}_${model_ver}/restart export DATAarchive=${DATAROOT}/${jobname}_${model_ver}/archive mkdir -p $DATA mkdir -p $DATArestart $DATAarchive cd $DATA #################################### # Determine Job Output Name on System #################################### export pgmout="OUTPUT.$$" #################################### # Specify Execution Areas #################################### #export HOMErtofs=${HOMErtofs:-${NWROOT:?}/${RUN}_${modID}.${rtofs_glo_ver}} export EXECrtofs=${HOMErtofs}/exec export PARMrtofs=${HOMErtofs}/parm export FIXrtofs=${HOMErtofs}/fix export USHrtofs=${HOMErtofs}/ush ############################# # Set up the UTILITIES ############################## export USHutil=${UTILROOT:?}/ush export EXECutil=${UTILROOT:?}/exec export utilexec=$EXECutil # needed by some scripts in USHutil ########################################################### # Run setpdy and initialize PDY variables # For any retrospecitve run, set the PDY in the ECF script ########################################################### setpdy.sh . ./PDY ############################################## # Define Input/Output/Restart directories ############################################## export COMIN=${COMIN:-$(compath.py ${envir}/com/${NET}/${rtofs_glo_ver})/${RUN}.${PDY}} export COMINm1=${COMINm1:-$(compath.py ${envir}/com/${NET}/${rtofs_glo_ver})/${RUN}.${PDYm1}} export COMOUT=${COMOUT:-$(compath.py -o ${NET}/${rtofs_glo_ver})/${RUN}.${PDY}} mkdir -m 775 -p $COMOUT test -d $COMOUT || mkdir -p $COMOUT ################### # Define model grid ################### export inputgrid=navy_0.08 export useslp=NO # YES or NO, use sea level pressure ################################################################## # Run the config file to set up specific model variables if needed ################################################################## . $PARMrtofs/${RUN}_${modID}.${inputgrid}.config export DBL_THKDF=NO # YES or NO ################################# # Set up forecast step parameters ################################# stepnum=${RUN_STEP#step} cnum=1 fcstdays_before_thisstep=0 while [ ${cnum} -lt ${stepnum} ] do eval daysadd="\$fcstdays_step$cnum" fcstdays_before_thisstep=$(expr ${fcstdays_before_thisstep} + ${daysadd}) cnum=$(expr ${cnum} + 1) done export startdate=$($NDATE $(expr ${fcstdays_before_thisstep} \* 24) ${PDY}${mycyc}) eval fcstdays="\$fcstdays_step$stepnum" eval SAVE_RESTART="\$SAVE_RESTART_FORECAST_STEP$stepnum" eval CONTINUE_FORECAST="\$CONTINUE_FORECAST_STEP$stepnum" export fcstdays export stepnum export SAVE_RESTART export CONTINUE_FORECAST ############################################## # Check for viable restart files - remove any files that are not part of a complete set ############################################## goodsizea=25472139264 goodsizeb=31039 goodsizei=8189748580 for rtype in out out1 do if [[ -s ${DATArestart}/restart_${rtype}.a && ${DATArestart}/restart_${rtype}.b ]] then # rtype exists sizea=$(stat -c %s ${DATArestart}/restart_${rtype}.a) sizeb=$(stat -c %s ${DATArestart}/restart_${rtype}.b) if [[ $sizea -ne $goodsizea || $sizeb -ne $goodsizeb ]] then # bad size so remove echo "INFO - removing partial restart file ${DATArestart}/restart_${rtype}" rm -f ${DATArestart}/restart_${rtype}.? else # check on cice restart file rdate=$(${USHrtofs}/rtofs_date4restart.sh ${DATArestart}/restart_${rtype}.b) YYYY=$(echo $rdate | cut -c1-4) MM=$(echo $rdate | cut -c5-6) DD=$(echo $rdate | cut -c7-8) HH=$(echo $rdate | cut -c9-10) SSSSS=$(printf "%05d\n" $(expr $HH \* 3600)) rice=$DATArestart/cice.restart.${YYYY}-${MM}-${DD}-${SSSSS} if [ -s $rice ] then # cice restart file exists sizei=$(stat -c %s $rice) if [ $sizei -ne $goodsizei ] then echo "INFO - removing partial restart file $rice and associated restart_out files" rm -f $rice ${DATArestart}/restart_${rtype}.? fi else # cice file does not exist echo "INFO - removing restart_out files for missing $rice file" rm -f ${DATArestart}/restart_${rtype}.? fi fi else # if only one of a or b exists, remove the other rm -f ${DATArestart}/restart_${rtype}.? fi done if compgen -G "$DATArestart/restart_*.a" > /dev/null && \ compgen -G "$DATArestart/restart_*.b" > /dev/null && \ compgen -G "$DATArestart/cice.restart.*" > /dev/null then export RESTART=YES else export RESTART=NO fi ################################################################# # Send a message indicating the start of the job ################################################################# msg="JOB $job HAS BEGUN on $(hostname)" postmsg "$msg" #################### # execute the script #################### ksh ${HOMErtofs}/scripts/ex${RUN}_${modID}_${RUN_MODE}.sh #=================================================================== cat $pgmout cp -p $pgmout $COMOUT/${RUN}_${modID}.t${cyc}z.${RUN_MODE}.$(basename $pgmout) msg="JOB $job HAS COMPLETED NORMALLY." postmsg "$msg" cd $DATAROOT if [ "$KEEPDATA" != YES ]; then rm -rf $DATA rm -rf $DATAarchive rm -rf $DATArestart fi date