From 93c7cf3a413fcc3bd1fa4501f631c6eb8d321aee Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Thu, 8 Sep 2022 09:23:03 -0500 Subject: [PATCH 01/36] Remove GLDAS scripts from .gitignore - Remove GLDAS JJOB script from ignore file. - Remove GLDAS exscript from ignore file. - Remove GLDAS ush scripts from ignore file. Refs #1014 --- .gitignore | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index 937b7bae1c..65643d9e64 100644 --- a/.gitignore +++ b/.gitignore @@ -135,7 +135,6 @@ sorc/wafs_setmissing.fd # Ignore scripts from externals #------------------------------ # jobs symlinks -jobs/JGDAS_ATMOS_GLDAS jobs/JGFS_ATMOS_WAFS jobs/JGFS_ATMOS_WAFS_BLENDING jobs/JGFS_ATMOS_WAFS_BLENDING_0P25 @@ -144,7 +143,6 @@ jobs/JGFS_ATMOS_WAFS_GRIB2 jobs/JGFS_ATMOS_WAFS_GRIB2_0P25 # scripts symlinks scripts/exemcsfc_global_sfc_prep.sh -scripts/exgdas_atmos_gldas.sh scripts/exgfs_atmos_wafs_blending.sh scripts/exgfs_atmos_wafs_blending_0p25.sh scripts/exgfs_atmos_wafs_gcip.sh @@ -160,12 +158,6 @@ ush/fv3gfs_driver_grid.sh ush/fv3gfs_filter_topo.sh ush/fv3gfs_make_grid.sh ush/fv3gfs_make_orog.sh -ush/gldas_archive.sh -ush/gldas_forcing.sh -ush/gldas_get_data.sh -ush/gldas_liscrd.sh -ush/gldas_post.sh -ush/gldas_process_data.sh ush/global_chgres.sh ush/global_chgres_driver.sh ush/global_cycle.sh From 016c8c2f6e02c79104347c1fdf882ef712f86e6e Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Thu, 8 Sep 2022 09:24:53 -0500 Subject: [PATCH 02/36] Remove GLDAS script symlinks from link_workflow.sh - Remove symlink creation for GLDAS scripts in the workflow link script. - Removal includes JJOB, ex-script, and ush script symlinks. Refs #1014 --- sorc/link_workflow.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sorc/link_workflow.sh b/sorc/link_workflow.sh index 62ff535e04..39ad138746 100755 --- a/sorc/link_workflow.sh +++ b/sorc/link_workflow.sh @@ -83,10 +83,6 @@ fi #--------------------------------------- #--add files from external repositories #--------------------------------------- -cd ${pwd}/../jobs ||exit 8 -if [ -d ../sorc/gldas.fd ]; then - $LINK ../sorc/gldas.fd/jobs/JGDAS_ATMOS_GLDAS . -fi cd ${pwd}/../parm ||exit 8 # [[ -d post ]] && rm -rf post # $LINK ../sorc/upp.fd/parm post @@ -106,19 +102,11 @@ cd ${pwd}/../parm/post ||exit 8 done cd ${pwd}/../scripts ||exit 8 $LINK ../sorc/ufs_utils.fd/scripts/exemcsfc_global_sfc_prep.sh . - if [ -d ../sorc/gldas.fd ]; then - $LINK ../sorc/gldas.fd/scripts/exgdas_atmos_gldas.sh . - fi cd ${pwd}/../ush ||exit 8 for file in emcsfc_ice_blend.sh fv3gfs_driver_grid.sh fv3gfs_make_orog.sh global_cycle_driver.sh \ emcsfc_snow.sh fv3gfs_filter_topo.sh global_cycle.sh fv3gfs_make_grid.sh ; do $LINK ../sorc/ufs_utils.fd/ush/$file . done - if [ -d ../sorc/gldas.fd ]; then - for file in gldas_archive.sh gldas_forcing.sh gldas_get_data.sh gldas_process_data.sh gldas_liscrd.sh gldas_post.sh ; do - $LINK ../sorc/gldas.fd/ush/$file . - done - fi #----------------------------------- From 858cbfc2168a7c0ad9c4fe5b88ef9fe528dea03b Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Thu, 8 Sep 2022 09:26:10 -0500 Subject: [PATCH 03/36] Add GLDAS scripts to global-workflow - Initial copy of GLDAS JJOB, exscript, and ush scripts from GLDAS repo into global-workflow. Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 133 ++++++++++++++ scripts/exgdas_atmos_gldas.sh | 328 ++++++++++++++++++++++++++++++++++ ush/gldas_archive.sh | 93 ++++++++++ ush/gldas_forcing.sh | 123 +++++++++++++ ush/gldas_get_data.sh | 85 +++++++++ ush/gldas_liscrd.sh | 41 +++++ ush/gldas_post.sh | 34 ++++ ush/gldas_process_data.sh | 39 ++++ 8 files changed, 876 insertions(+) create mode 100755 jobs/JGDAS_ATMOS_GLDAS create mode 100755 scripts/exgdas_atmos_gldas.sh create mode 100755 ush/gldas_archive.sh create mode 100755 ush/gldas_forcing.sh create mode 100755 ush/gldas_get_data.sh create mode 100755 ush/gldas_liscrd.sh create mode 100755 ush/gldas_post.sh create mode 100755 ush/gldas_process_data.sh diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS new file mode 100755 index 0000000000..8db81a1764 --- /dev/null +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -0,0 +1,133 @@ +#!/bin/ksh +set -x + +#export RUN_ENVIR=${RUN_ENVIR:-"nco"} +export PS4='$SECONDS + ' +date + +############################# +# Source relevant config files +############################# +export EXPDIR=${EXPDIR:-$HOMEgfs/parm/config} +configs="base gldas" +config_path=${EXPDIR:-$NWROOT/gfs.${gfs_ver}/parm/config} +for config in $configs; do + . $config_path/config.$config + status=$? + [[ $status -ne 0 ]] && exit $status +done + + +if [ $cyc -ne $gldas_cyc ]; then + echo "GLDAS only runs for $gldas_cyc cycle; Skip GLDAS step for cycle $cyc" + exit 0 +fi + +xtime=$((gldas_spinup_hours+12)) +if [ $CDATE -le $($NDATE +$xtime $SDATE) ]; then + echo "GLDAS needs fluxes as forcing from cycles in previous $xtime hours" + echo "starting from $SDATE. This gldas cycle is skipped" + exit 0 +fi + +########################################## +# Source machine runtime environment +########################################## +. $HOMEgfs/env/${machine}.env gldas +status=$? +[[ $status -ne 0 ]] && exit $status + + +############################################## +# Obtain unique process id (pid) and make temp directory +############################################## +export pid=${pid:-$$} +export outid=${outid:-"LL$job"} + +export DATA=${DATA:-${DATAROOT}/${jobid:?}} +mkdir -p $DATA +cd $DATA + + +############################################## +# Run setpdy and initialize PDY variables +############################################## +export cycle="t${cyc}z" +setpdy.sh +. ./PDY + + +############################################## +# Determine Job Output Name on System +############################################## +export pgmout="OUTPUT.${pid}" +export pgmerr=errfile + + +############################################## +# Set variables used in the exglobal script +############################################## +export CDATE=${CDATE:-${PDY}${cyc}} +export CDUMP=${CDUMP:-${RUN:-"gdas"}} +export COMPONENT=${COMPONENT:-atmos} + + +############################################## +# Begin JOB SPECIFIC work +############################################## +export gldas_ver=${gldas_ver:-v2.3.0} +export HOMEgldas=${HOMEgldas:-$HOMEgfs} +export FIXgldas=${FIXgldas:-$HOMEgldas/fix/fix_gldas} +export PARMgldas=${PARMgldas:-$HOMEgldas/parm/gldas} +export EXECgldas=${EXECgldas:-$HOMEgldas/exec} +export USHgldas=${USHgldas:-$HOMEgldas/ush} +export PARA_CONFIG=$HOMEgfs/parm/config/config.gldas + +if [ $RUN_ENVIR = "nco" ]; then + export COMIN=${COMIN:-$ROTDIR/$RUN.$PDY/$cyc/$COMPONENT} + export COMOUT=${COMOUT:-$ROTDIR/$RUN.$PDY/$cyc/$COMPONENT} +else + export COMIN="$ROTDIR/$CDUMP.$PDY/$cyc/$COMPONENT" + export COMOUT="$ROTDIR/$CDUMP.$PDY/$cyc/$COMPONENT" +fi +[[ ! -d $COMOUT ]] && mkdir -m 775 -p $COMOUT + +export COMINgdas=${COMINgdas:-$ROTDIR} +export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} + +export model=${model:-noah} +export MODEL=${MODEL:-`echo $model |tr '[a-z]' '[A-Z]'`} + + +############################################################### +# Run relevant exglobal script +env +msg="HAS BEGUN on `hostname`" +$LOGSCRIPT + +${GLDASSH:-$HOMEgldas/scripts/exgdas_atmos_gldas.sh} +status=$? +[[ $status -ne 0 ]] && exit $status + +############################################## +# End JOB SPECIFIC work +############################################## + +############################################## +# Final processing +############################################## +if [ -e "$pgmout" ] ; then + cat $pgmout +fi + +msg="ENDED NORMALLY." + +########################################## +# Remove the Temporary working directory +########################################## +cd $DATAROOT +[[ $KEEPDATA = "NO" ]] && rm -rf $DATA + +date +exit 0 + diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh new file mode 100755 index 0000000000..cc844a4ffc --- /dev/null +++ b/scripts/exgdas_atmos_gldas.sh @@ -0,0 +1,328 @@ +#!/bin/ksh +################################################################################ +#### UNIX Script Documentation Block +# . . +# Script name: exgdas_gldas.sh.ecf +# Script description: Runs the global land analysis +# +# History: +# 20191015 Jesse Meng and Youlong Xia, first version +# 20191123 Fanglin Yang, restructure for global workflow +################################################################################ + +# Set environment +export VERBOSE=${VERBOSE:-"YES"} +if [ $VERBOSE = "YES" ]; then + echo $(date) EXECUTING $0 $* >&2 + set -x +fi + +################################# +# Set up UTILITIES +################################# +export FINDDATE=${FINDDATE:-/apps/ops/prod/nco/core/prod_util.v2.0.13/ush/finddate.sh} +export utilexec=${utilexec:-/apps/ops/prod/libs/intel/19.1.3.304/grib_util/1.2.3/bin} +export CNVGRIB=${CNVGRIB:-$utilexec/cnvgrib} +export WGRIB=${WGRIB:-$utilexec/wgrib} +export WGRIB2=${WGRIB2:-/apps/ops/prod/libs/intel/19.1.3.304/wgrib2/2.0.7/bin/wgrib2} +export COPYGB=${COPYGB:-$utilexec/copygb} +export NDATE=${NDATE:-/apps/ops/prod/nco/core/prod_util.v2.0.13/exec/ndate} +export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} +export CPCGAUGE=${CPCGAUGE:-/lfs/h2/emc/global/noscrub/emc.global/dump} +export COMINgdas=${COMINgdas:-$ROTDIR} +export OFFLINE_GLDAS=${OFFLINE_GLDAS:-"NO"} +export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} + + +################################# +# Set up the running environment +################################# +export USE_CFP=${USE_CFP:-"NO"} +export COMPONENT=${COMPONENT:-atmos} +export assim_freq=${assim_freq:-6} +export gldas_spinup_hours=${gldas_spinup_hours:-72} +export gldas_cdate=$CDATE +export gldas_eymd=`echo $gldas_cdate |cut -c 1-8` +export gldas_ecyc=`echo $gldas_cdate |cut -c 9-10` +export gldas_sdate=`$NDATE -$gldas_spinup_hours $CDATE` +export gldas_symd=`echo $gldas_sdate |cut -c 1-8` +export gldas_scyc=`echo $gldas_sdate |cut -c 9-10` + +export iau_cdate=$CDATE +if [ "$DOIAU" = "YES" ]; then + IAU_OFFSET=${IAU_OFFSET:-0} + IAUHALH=$((IAU_OFFSET/2)) + export iau_cdate=`$NDATE -$IAUHALH $CDATE` +fi +export iau_eymd=`echo $iau_cdate |cut -c 1-8` +export iau_ecyc=`echo $iau_cdate |cut -c 9-10` +echo "GLDAS runs from $gldas_sdate to $iau_cdate" + +export CASE=${CASE:-C768} +export res=$(echo $CASE |cut -c2-5) +export JCAP=$((2*res-2)) +export nlat=$((2*res)) +export nlon=$((4*res)) + +export FIXgldas=${FIXgldas:-$HOMEgfs/fix} +export topodir=${topodir:-$HOMEgfs/fix/fix_fv3_gmted2010/$CASE/} + +DATA=${DATA:-$pwd/gldastmp$$} +mkdata=NO +if [ ! -d $DATA ]; then + mkdata=YES + mkdir -p $DATA +fi +cd $DATA || exit 1 +export RUNDIR=$DATA + + +################################# +GDAS=${RUNDIR}/force +mkdir -p $GDAS + +input1=$COMINgdas/gdas.$gldas_symd/$gldas_scyc/$COMPONENT/RESTART +input2=$COMINgdas/gdas.$gldas_eymd/$gldas_ecyc/$COMPONENT/RESTART +[[ -d $RUNDIR ]] && rm -fr $RUNDIR/FIX +[[ -f $RUNDIR/LIS ]] && rm -fr $RUNDIR/LIS +[[ -d $RUNDIR/input ]] && rm -fr $RUNDIR/input +mkdir -p $RUNDIR/input +ln -fs $GDAS $RUNDIR/input/GDAS +ln -fs $FIXgldas/FIX_T${JCAP} $RUNDIR/FIX +ln -fs $EXECgldas/gldas_model $RUNDIR/LIS + + +#--------------------------------------------------------------- +### 1) Get gdas 6-tile netcdf restart file and gdas forcing data +#--------------------------------------------------------------- + +${USHgldas}/gldas_get_data.sh $gldas_sdate $gldas_cdate +export err=$? +$ERRSCRIPT || exit 2 + +#--------------------------------------------------------------- +### 2) Get CPC daily precip and temporally disaggreated +#--------------------------------------------------------------- + +${USHgldas}/gldas_forcing.sh $gldas_symd $gldas_eymd +export err=$? +$ERRSCRIPT || exit 3 + +# spatially disaggregated + +if [ $JCAP -eq 1534 ]; then + gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' +elif [ $JCAP -eq 766 ]; then + gds='255 4 1536 768 89821 0 128 -89821 -234 234 384 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' +elif [ $JCAP -eq 382 ]; then + gds='255 4 768 384 89641 0 128 -89641 -469 469 192 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' +elif [ $JCAP -eq 190 ]; then + gds='255 4 384 192 89284 0 128 -89284 -938 938 96 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' +else + echo "JCAP=$JCAP no supportted, exit" + export err=4 + $ERRSCRIPT || exit 4 +fi + +echo $JCAP +echo $gds +ymdpre=`sh $FINDDATE $gldas_symd d-1` +ymdend=`sh $FINDDATE $gldas_eymd d-2` +ymd=$ymdpre + +if [ $USE_CFP = "YES" ] ; then + rm -f ./cfile + touch ./cfile +fi + +while [ $ymd -le $ymdend ]; do + if [ $ymd -ne $ymdpre ]; then + if [ $USE_CFP = "YES" ] ; then + echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}00 $RUNDIR/cmap.gdas.${ymd}00" >> ./cfile + echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}06 $RUNDIR/cmap.gdas.${ymd}06" >> ./cfile + else + $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}00 $RUNDIR/cmap.gdas.${ymd}00 + $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}06 $RUNDIR/cmap.gdas.${ymd}06 + fi + fi + if [ $ymd -ne $ymdend ]; then + if [ $USE_CFP = "YES" ] ; then + echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}12 $RUNDIR/cmap.gdas.${ymd}12" >> ./cfile + echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}18 $RUNDIR/cmap.gdas.${ymd}18" >> ./cfile + else + $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}12 $RUNDIR/cmap.gdas.${ymd}12 + $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}18 $RUNDIR/cmap.gdas.${ymd}18 + fi + fi + ymd=`sh $FINDDATE $ymd d+1` +done + +if [ $USE_CFP = "YES" ] ; then + $APRUN_GLDAS_DATA_PROC ./cfile +fi + +# create configure file +${USHgldas}/gldas_liscrd.sh $gldas_sdate $iau_cdate ${JCAP} +export err=$? +$ERRSCRIPT || exit 4 + + +#--------------------------------------------------------------- +### 3) Produce initials noah.rst from 6-tile gdas restart files +#--------------------------------------------------------------- +rm -f fort.41 fort.141 fort.11 fort.12 + +# 3a) create gdas2gldas input file + +cat >> fort.141 << EOF + &config + data_dir_input_grid="$input1" + sfc_files_input_grid="${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile1.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile2.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile3.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile4.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile5.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile6.nc" + mosaic_file_input_grid="${CASE}_mosaic.nc" + orog_dir_input_grid="$topodir" + orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" + i_target=$nlon + j_target=$nlat + model="$model" + / +EOF +cp fort.141 fort.41 + + +# 3b) Use gdas2gldas to generate nemsio file + +export OMP_NUM_THREADS=1 +export pgm=gdas2gldas +. prep_step +$APRUN_GAUSSIAN ${EXECgldas}/gdas2gldas 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 5 + + +# 3c)gldas_rst to generate noah.rst + +sfcanl=sfc.gaussian.nemsio +ln -fs FIX/lmask_gfs_T${JCAP}.bfsa fort.11 +ln -fs $sfcanl fort.12 +export pgm=gldas_rst +. prep_step +${EXECgldas}/gldas_rst 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 6 + +mv $sfcanl ${sfcanl}.$gldas_symd + + +#--------------------------------------------------------------- +### 4) run noah/noahmp model +#--------------------------------------------------------------- +export pgm=LIS +. prep_step +$APRUN_GLDAS ./LIS 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 7 + + +#--------------------------------------------------------------- +### 5) using gdas2gldas to generate nemsio file for gldas_eymd +### use gldas_post to replace soil moisture and temperature +### use gldas2gdas to produce 6-tile restart file +#--------------------------------------------------------------- +rm -f fort.41 fort.241 fort.42 + +# 5a) create input file for gdas2gldas + +cat >> fort.241 << EOF + &config + data_dir_input_grid="$input2" + sfc_files_input_grid="${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile1.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile2.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile3.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile4.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile5.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile6.nc" + mosaic_file_input_grid="${CASE}_mosaic.nc" + orog_dir_input_grid="$topodir" + orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" + i_target=$nlon + j_target=$nlat + model="$model" + / +EOF +cp fort.241 fort.41 + +# 5b) use gdas2gldas to produce nemsio file + +export OMP_NUM_THREADS=1 +export pgm=gdas2gldas +. prep_step +$APRUN_GAUSSIAN ${EXECgldas}/gdas2gldas 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 8 + + +# 5c) use gldas_post to replace soil moisture and temperature + +yyyy=`echo $iau_eymd | cut -c1-4` +gbin=$RUNDIR/EXP901/NOAH/$yyyy/$iau_eymd/LIS.E901.${iau_eymd}${iau_ecyc}.NOAHgbin +sfcanl=sfc.gaussian.nemsio +rm -rf fort.11 fort.12 +ln -fs $gbin fort.11 +ln -fs $sfcanl fort.12 + +export pgm=gldas_post +. prep_step +${EXECgldas}/gldas_post 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 9 + +cp fort.22 ./gldas.nemsio +mv fort.22 ${sfcanl}.gldas + + +# 5d) use gldas2gdas to create 6-tile restart tiles + +cat >> fort.42 << EOF + &config + orog_dir_gdas_grid="$topodir" + mosaic_file_gdas_grid="${CASE}_mosaic.nc" + / +EOF + +# copy/link gdas netcdf tiles +k=1; while [ $k -le 6 ]; do + cp $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ./sfc_data.tile${k}.nc + k=$((k+1)) +done + +# copy soil type +ln -fs FIX/stype_gfs_T${JCAP}.bfsa stype_gfs_T${JCAP}.bfsa + +export OMP_NUM_THREADS=1 +export pgm=gldas2gdas +. prep_step +$APRUN_GAUSSIAN $EXECgldas/gldas2gdas 1>&1 2>&2 +export err=$? +$ERRSCRIPT || exit 10 + + +# 5e) archive gldas results + +if [ $OFFLINE_GLDAS = "YES" ]; then + ${USHgldas}/gldas_archive.sh $gldas_symd $gldas_eymd + export err=$? + $ERRSCRIPT || exit 11 +else + k=1; while [ $k -le 6 ]; do + mv $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas + cp sfc_data.tile${k}.nc $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc + k=$((k+1)) + done +fi + + +#------------------------------------------------------------------ +# Clean up before leaving +if [ $mkdata = "YES" ]; then rm -rf $DATA; fi + +set +x +if [ $VERBOSE = "YES" ] ; then + echo $(date) EXITING $0 with return code $err >&2 +fi +exit $err + diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh new file mode 100755 index 0000000000..b98fe04d6c --- /dev/null +++ b/ush/gldas_archive.sh @@ -0,0 +1,93 @@ +#!/bin/ksh +# +######################################################### +# This script collects gldas output to archive directory +# Replace soil moisture and temperature for gdas nemsio file +# generate from Gaussian grid fileds to 6-tile netcdf file +# +# usage - gldas_archive.sh sdate edate +# sdate/edate in yyyymmdd +# +# HOMEgldas - software directory +# COMDIR - output archive directory +# RUNDIR - run directory +# GDAS - /lfs/h1/ops/prod/com/gfs/prod +# +# gldas runs 72 hrs, from day1.00z to day4.00z +# first 36 hr obs precip forcing +# second 36 hrs gdas model forcing to bring it to realtime. +# +# save all output to day1 directory +# save noah.rst.day2 to day2 directory for next day restart +# save gdas.t00z.sfcanl.nemsio.gldas.day4 to day4 directory for gfs restart +# +# script history: +# 20190604 Jesse Meng - first version +# 20191010 Youlong Xia - modified +######################################################### +set -ux + +if [ $# -lt 1 ]; then +echo "usage: ksh $0 sdate [edate]" +exit $? +fi + +sdate=$1 +edate=`sh $FINDDATE $1 d+1` +if [ $# -gt 1 ]; then edate=$2 ; fi + +yyyy=`echo $sdate | cut -c1-4` + +### save all output to day1 directory +export COMDIR=${COM_OUT} + +mkdir -p $COMDIR/gldas.$sdate +yyyymmdd=`sh $FINDDATE $sdate d+1` +while [ $yyyymmdd -le $edate ]; do + +mkdir -p $COMDIR/gldas.$yyyymmdd + +yyyy=`echo $yyyymmdd | cut -c1-4` +cp $RUNDIR/EXP901/NOAH/$yyyy/$yyyymmdd/* $COMDIR/gldas.$sdate + +yyyymmdd=`sh $FINDDATE $yyyymmdd d+1` +done + +cp $RUNDIR/sfc.gaussian.nemsio.$sdate $COMDIR/gldas.$sdate + +### rename grb files + +yyyymmdd=$sdate +while [ $yyyymmdd -lt $edate ]; do + +day1=$yyyymmdd +day2=`sh $FINDDATE $yyyymmdd d+1` +mv $COMDIR/gldas.$sdate/LIS.E901.${day2}00.NOAH.grb $COMDIR/gldas.$sdate/LIS.E901.${day1}00.NOAH.grb + +yyyymmdd=`sh $FINDDATE $yyyymmdd d+1` +done + +### save noah.rst.day2 to day2 directory for next day gldas restart + +yyyymmdd=`sh $FINDDATE $sdate d+1` +yyyy=`echo $yyyymmdd | cut -c1-4` +mkdir -p $COMDIR/gldas.$edate +cp $RUNDIR/EXP901/NOAH/$yyyy/$edate/LIS.E901.${edate}00.Noahrst $COMDIR/gldas.$yyyymmdd/noah.rst.$edate + +### generate and save gdas.t${cyc1}z.sfcanl.nemsio.gldas.day4 to day4 directory for next cycle gfs restart + +mkdir -p $COMDIR/gldas.$edate +gdate=${edate} +gdas_date=${gdate}.${cyc}0000 +cp sfc_data.tile1.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile1.nc +cp sfc_data.tile2.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile2.nc +cp sfc_data.tile3.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile3.nc +cp sfc_data.tile4.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile4.nc +cp sfc_data.tile5.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile5.nc +cp sfc_data.tile6.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile6.nc + +cp sfc.gaussian.nemsio.gldas $COMDIR/gldas.$edate/${gdas_date}.sfc.gaussian.nemsio.gldas + +cp sfc.gaussian.nemsio $COMDIR/gldas.$edate/${gdas_date}.sfc.gaussian.nemsio.gdas + +echo $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile6.nc diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh new file mode 100755 index 0000000000..6bc9c18181 --- /dev/null +++ b/ush/gldas_forcing.sh @@ -0,0 +1,123 @@ +#!/bin/ksh +########################################################################### +# this script gets cpc daily precipitation and using gdas hourly precipitation +# to disaggregate daily value into hourly value +# 20190509 Jesse Meng - first version +# 20191008 Youlong Xia - modified +# 20191123 Fanglin Yang - restructured for global-workflow +########################################################################### + +bdate=$1 +edate=$2 + +# Set environment +export VERBOSE=${VERBOSE:-"YES"} +if [ $VERBOSE = "YES" ]; then + echo $(date) EXECUTING $0 $* >&2 + set -x +fi + +# HOMEgldas - gldas directory +# EXECgldas - gldas exec directory +# PARMgldas - gldas param directory +# FIXgldas - gldas fix field directory +export LISDIR=$HOMEgldas +export fpath=${RUNDIR}/force +export xpath=${RUNDIR}/force +export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} + +#------------------------------- +#--- extract variables of each timestep and create forcing files +sdate=$bdate +edate=`sh $FINDDATE $edate d-1` +while [ $sdate -lt $edate ]; do +#------------------------------- + +sdat0=`sh $FINDDATE $sdate d-1` +[[ ! -d $xpath/cpc.${sdate} ]] && mkdir -p $xpath/cpc.${sdate} +[[ ! -d $xpath/cpc.${sdat0} ]] && mkdir -p $xpath/cpc.${sdat0} + +cd $xpath +rm -f fort.* grib.* + +COMPONENT=${COMPONENT:-"atmos"} +pathp1=$CPCGAUGE/gdas.$sdate/00/$COMPONENT +pathp2=$DCOMIN/$sdate/wgrbbul/cpc_rcdas +yyyy=`echo $sdate |cut -c 1-4` +cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT" +if [ $RUN_ENVIR = "emc" ] && [ $sdate -gt $bdate ]; then + cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT_early" +fi +cpc=$pathp1/$cpc_precip +if [ ! -s $cpc ]; then cpc=$pathp2/$cpc_precip ; fi +if [ $RUN_ENVIR = "nco" ]; then cpc=$pathp2/$cpc_precip ; fi +if [ ! -s $cpc ]; then + echo "WARNING: GLDAS MISSING $cpc, WILL NOT RUN." + exit 3 +fi +cp $cpc $xpath/cpc.$sdate/. + +sflux=$fpath/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 +prate=gdas.${sdat0}12 +$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate + +sflux=$fpath/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 +prate=gdas.${sdat0}18 +$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate + +sflux=$fpath/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 +prate=gdas.${sdate}00 +$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate + +sflux=$fpath/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 +prate=gdas.${sdate}06 +$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate + +if [ $USE_CFP = "YES" ] ; then + rm -f ./cfile + touch ./cfile + echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile + echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" >> ./cfile + echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" >> ./cfile + echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile + $APRUN_GLDAS_DATA_PROC ./cfile +else + $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12 + $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18 + $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00 + $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06 +fi + +rm -f fort.10 +touch fort.10 +echo ${sdat0} >> fort.10 +echo ${sdate} >> fort.10 + +export pgm=gldas_forcing +. prep_step + +$WGRIB -d -bin grib.12 -o fort.11 +$WGRIB -d -bin grib.18 -o fort.12 +$WGRIB -d -bin grib.00 -o fort.13 +$WGRIB -d -bin grib.06 -o fort.14 + +ln -fs $xpath/cpc.$sdate/$cpc_precip fort.15 + +$EXECgldas/gldas_forcing 1>&1 2>&2 + +export err=$? +$ERRSCRIPT || exit 3 + +cp fort.21 $xpath/cpc.$sdat0/precip.gldas.${sdat0}12 +cp fort.22 $xpath/cpc.$sdat0/precip.gldas.${sdat0}18 +cp fort.23 $xpath/cpc.$sdate/precip.gldas.${sdate}00 +cp fort.24 $xpath/cpc.$sdate/precip.gldas.${sdate}06 + +rm -f fort.* grib.* + +#------------------------------- +sdate=`sh $FINDDATE $sdate d+1` +done +#------------------------------- + +exit $err diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh new file mode 100755 index 0000000000..529ebbc260 --- /dev/null +++ b/ush/gldas_get_data.sh @@ -0,0 +1,85 @@ +#!/bin/ksh +######################################################### +# This script generate gldas forcing from gdas prod sflux +# script history: +# 20190509 Jesse Meng - first version +# 20191008 Youlong Xia - modified +# 20191123 Fanglin Yang - restructured for global-workflow +######################################################### + +export VERBOSE=${VERBOSE:-"YES"} +if [ $VERBOSE = "YES" ]; then + echo $(date) EXECUTING $0 $* >&2 + set -x +fi + +bdate=$1 +edate=$2 + +if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ + [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then + touch ./cfile +fi + +### COMINgdas = prod gdas sflux grib2 +### RUNDIR = gldas forcing in grib2 format +### RUNDIR/force = gldas forcing in grib1 format +export COMPONENT=${COMPONENT:-atmos} +fpath=$RUNDIR +gpath=$RUNDIR/force +cycint=${assim_freq:-6} + +# get gdas flux files to force gldas. +# CPC precipitation is from 12z to 12z. One more day of gdas data is +# needed to disaggregate daily CPC precipitation values to hourly values +cdate=`$NDATE -12 $bdate` + +iter=0 + +#------------------------------- +while [ $cdate -lt $edate ]; do +#------------------------------- + ymd=`echo $cdate |cut -c 1-8` + cyc=`echo $cdate |cut -c 9-10` + [[ ! -d $fpath/gdas.${ymd} ]] && mkdir -p $fpath/gdas.${ymd} + [[ ! -d $gpath/gdas.${ymd} ]] && mkdir -p $gpath/gdas.${ymd} + +f=1 +while [ $f -le $cycint ]; do + rflux=${COMINgdas}/gdas.$ymd/$cyc/$COMPONENT/gdas.t${cyc}z.sfluxgrbf00$f.grib2 + fflux=$fpath/gdas.$ymd/gdas.t${cyc}z.sfluxgrbf0$f.grib2 + gflux=$gpath/gdas.$ymd/gdas1.t${cyc}z.sfluxgrbf0$f + if [ ! -s $rflux ];then + echo "WARNING: GLDAS MISSING $rflux, WILL NOT RUN." + exit 2 + fi + rm -f $fflux $gflux + touch $fflux $gflux + + fcsty=anl + if [ $f -ge 1 ]; then fcsty=fcst; fi + + if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ + [ $machine = "WCOSS2" ]; then + echo "${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile + elif [ $machine = "HERA" ]; then + echo "$iter ${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile + else + ${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f + fi + + iter=$((iter+1)) + f=$((f+1)) +done + +#------------------------------- + cdate=`$NDATE +$cycint $cdate` +done +#------------------------------- + +if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ + [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then + $APRUN_GLDAS_DATA_PROC ./cfile +fi + +exit $? diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh new file mode 100755 index 0000000000..d7ffec2ad2 --- /dev/null +++ b/ush/gldas_liscrd.sh @@ -0,0 +1,41 @@ +#!/bin/sh +if [ $# -lt 3 ]; then +echo usage $0 yyyymmddhh1 yyyymmddhh2 126/382/574/1534 +exit $? +fi + +date1=$1 +date2=$2 +grid=$3 + +export yyyy1=`echo $date1 | cut -c 1-4` +export mm1=`echo $date1 | cut -c 5-6` +export dd1=`echo $date1 | cut -c 7-8` +export hh1=`echo $date1 | cut -c 9-10` +export yyyy2=`echo $date2 | cut -c 1-4` +export mm2=`echo $date2 | cut -c 5-6` +export dd2=`echo $date2 | cut -c 7-8` +export hh2=`echo $date2 | cut -c 9-10` +export grid=$grid +export PARM_LM=${PARMgldas} +export LISCARD=lis.crd + +rm -f $LISCARD +touch $LISCARD +cat $PARM_LM/lis.crd.T${grid}.tmp.1 >> $LISCARD +echo "LIS%t%SSS = 0 " >> $LISCARD +echo "LIS%t%SMN = 00 " >> $LISCARD +echo "LIS%t%SHR = $hh1 " >> $LISCARD +echo "LIS%t%SDA = $dd1 " >> $LISCARD +echo "LIS%t%SMO = $mm1 " >> $LISCARD +echo "LIS%t%SYR = $yyyy1" >> $LISCARD +echo "LIS%t%ENDCODE = 1 " >> $LISCARD +echo "LIS%t%ESS = 0 " >> $LISCARD +echo "LIS%t%EMN = 00 " >> $LISCARD +echo "LIS%t%EHR = $hh2 " >> $LISCARD +echo "LIS%t%EDA = $dd2 " >> $LISCARD +echo "LIS%t%EMO = $mm2 " >> $LISCARD +echo "LIS%t%EYR = $yyyy2" >> $LISCARD +cat $PARM_LM/lis.crd.T${grid}.tmp.2 >> $LISCARD + +exit 0 diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh new file mode 100755 index 0000000000..d095d4cf30 --- /dev/null +++ b/ush/gldas_post.sh @@ -0,0 +1,34 @@ +#/bin/sh +set -x + +if [ $# -lt 2 ]; then +echo "usage: $0 gldas.gbin gdas.sfcanl" + err_exit 99 +fi + +cd $RUNDIR + +export pgm=gldas_post + . prep_step + +gbin=$1 +sfcanl=$2 + +rm -f fort.11 fort.12 fort.22 +cp $gbin fort.11 +cp $sfcanl fort.12 + + echo 'running NOAH model' + startmsg + ${EXECgldas}/gldas_post >>$pgmout 2>errfile + export err=$?; err_chk + +##cp fort.22 ${sfcanl}.gldas +cp fort.22 ./gldas.nemsio +cp fort.22 ${sfcanl}.gldas +rm -f fort.11 fort.12 fort.22 + +echo ${sfcanl}.gldas + +exit $? + diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh new file mode 100755 index 0000000000..74db995775 --- /dev/null +++ b/ush/gldas_process_data.sh @@ -0,0 +1,39 @@ +#!/bin/bash + + set -x + + rflux=$1 + fcsty=$2 + fflux=$3 + gflux=$4 + f=$5 + + $WGRIB2 $rflux | grep "TMP:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "SPFH:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "UGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "VGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "HGT:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "PRES:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "PRATE:surface" | grep ave | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "VEG:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "SFCR:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "SFEXC:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "TMP:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "WEASD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "SNOD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +# $WGRIB2 $rflux | grep "SOILW:0-0" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +# $WGRIB2 $rflux | grep "SOILW:0.1" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +# $WGRIB2 $rflux | grep "SOILW:0.4" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +# $WGRIB2 $rflux | grep "SOILW:1-2" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux + + $WGRIB2 $rflux | grep "DSWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "DLWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux + $WGRIB2 $rflux | grep "USWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux + +#gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' +#$COPYGB -g"$gds" -x $fflux flux1534 +#mv flux1534 $fflux + + $CNVGRIB -g21 $fflux $gflux + + exit $? From 8f456115518df6ed6f8a444ecfed77b272e228f6 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Thu, 8 Sep 2022 13:56:47 -0500 Subject: [PATCH 04/36] Updates to GLDAS scripts - Convert from ksh to bash. - Convert backticks to substitutions. - Add preamble. - Remove announcements and general cleanup. Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 15 ++------- scripts/exgdas_atmos_gldas.sh | 40 ++++++++++-------------- ush/gldas_archive.sh | 38 +++++++++-------------- ush/gldas_forcing.sh | 22 +++++-------- ush/gldas_get_data.sh | 19 ++++-------- ush/gldas_liscrd.sh | 25 ++++++++------- ush/gldas_post.sh | 16 +++++----- ush/gldas_process_data.sh | 58 +++++++++++++++-------------------- 8 files changed, 92 insertions(+), 141 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 8db81a1764..a75e814a00 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -1,9 +1,6 @@ -#!/bin/ksh -set -x +#! /usr/bin/env bash -#export RUN_ENVIR=${RUN_ENVIR:-"nco"} -export PS4='$SECONDS + ' -date +source "$HOMEgfs/ush/preamble.sh" ############################# # Source relevant config files @@ -96,14 +93,11 @@ export COMINgdas=${COMINgdas:-$ROTDIR} export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} export model=${model:-noah} -export MODEL=${MODEL:-`echo $model |tr '[a-z]' '[A-Z]'`} +export MODEL=${MODEL:-$(echo $model |tr '[a-z]' '[A-Z]')} ############################################################### # Run relevant exglobal script -env -msg="HAS BEGUN on `hostname`" -$LOGSCRIPT ${GLDASSH:-$HOMEgldas/scripts/exgdas_atmos_gldas.sh} status=$? @@ -120,14 +114,11 @@ if [ -e "$pgmout" ] ; then cat $pgmout fi -msg="ENDED NORMALLY." - ########################################## # Remove the Temporary working directory ########################################## cd $DATAROOT [[ $KEEPDATA = "NO" ]] && rm -rf $DATA -date exit 0 diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index cc844a4ffc..ad14fc62ab 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -1,4 +1,5 @@ -#!/bin/ksh +#! /usr/bin/env bash + ################################################################################ #### UNIX Script Documentation Block # . . @@ -10,12 +11,7 @@ # 20191123 Fanglin Yang, restructure for global workflow ################################################################################ -# Set environment -export VERBOSE=${VERBOSE:-"YES"} -if [ $VERBOSE = "YES" ]; then - echo $(date) EXECUTING $0 $* >&2 - set -x -fi +source "$HOMEgfs/ush/preamble.sh" ################################# # Set up UTILITIES @@ -42,20 +38,20 @@ export COMPONENT=${COMPONENT:-atmos} export assim_freq=${assim_freq:-6} export gldas_spinup_hours=${gldas_spinup_hours:-72} export gldas_cdate=$CDATE -export gldas_eymd=`echo $gldas_cdate |cut -c 1-8` -export gldas_ecyc=`echo $gldas_cdate |cut -c 9-10` -export gldas_sdate=`$NDATE -$gldas_spinup_hours $CDATE` -export gldas_symd=`echo $gldas_sdate |cut -c 1-8` -export gldas_scyc=`echo $gldas_sdate |cut -c 9-10` +export gldas_eymd=$(echo $gldas_cdate |cut -c 1-8) +export gldas_ecyc=$(echo $gldas_cdate |cut -c 9-10) +export gldas_sdate=$($NDATE -$gldas_spinup_hours $CDATE) +export gldas_symd=$(echo $gldas_sdate |cut -c 1-8) +export gldas_scyc=$(echo $gldas_sdate |cut -c 9-10) export iau_cdate=$CDATE if [ "$DOIAU" = "YES" ]; then IAU_OFFSET=${IAU_OFFSET:-0} IAUHALH=$((IAU_OFFSET/2)) - export iau_cdate=`$NDATE -$IAUHALH $CDATE` + export iau_cdate=$($NDATE -$IAUHALH $CDATE) fi -export iau_eymd=`echo $iau_cdate |cut -c 1-8` -export iau_ecyc=`echo $iau_cdate |cut -c 9-10` +export iau_eymd=$(echo $iau_cdate |cut -c 1-8) +export iau_ecyc=$(echo $iau_cdate |cut -c 9-10) echo "GLDAS runs from $gldas_sdate to $iau_cdate" export CASE=${CASE:-C768} @@ -119,15 +115,15 @@ elif [ $JCAP -eq 382 ]; then elif [ $JCAP -eq 190 ]; then gds='255 4 384 192 89284 0 128 -89284 -938 938 96 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' else - echo "JCAP=$JCAP no supportted, exit" + echo "JCAP=$JCAP not supported, exit" export err=4 $ERRSCRIPT || exit 4 fi echo $JCAP echo $gds -ymdpre=`sh $FINDDATE $gldas_symd d-1` -ymdend=`sh $FINDDATE $gldas_eymd d-2` +ymdpre=$(sh $FINDDATE $gldas_symd d-1) +ymdend=$(sh $FINDDATE $gldas_eymd d-2) ymd=$ymdpre if [ $USE_CFP = "YES" ] ; then @@ -154,7 +150,7 @@ while [ $ymd -le $ymdend ]; do $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}18 $RUNDIR/cmap.gdas.${ymd}18 fi fi - ymd=`sh $FINDDATE $ymd d+1` + ymd=$(sh $FINDDATE $ymd d+1) done if [ $USE_CFP = "YES" ] ; then @@ -258,7 +254,7 @@ $ERRSCRIPT || exit 8 # 5c) use gldas_post to replace soil moisture and temperature -yyyy=`echo $iau_eymd | cut -c1-4` +yyyy=$(echo $iau_eymd | cut -c1-4) gbin=$RUNDIR/EXP901/NOAH/$yyyy/$iau_eymd/LIS.E901.${iau_eymd}${iau_ecyc}.NOAHgbin sfcanl=sfc.gaussian.nemsio rm -rf fort.11 fort.12 @@ -320,9 +316,5 @@ fi # Clean up before leaving if [ $mkdata = "YES" ]; then rm -rf $DATA; fi -set +x -if [ $VERBOSE = "YES" ] ; then - echo $(date) EXITING $0 with return code $err >&2 -fi exit $err diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh index b98fe04d6c..fa5e47fe04 100755 --- a/ush/gldas_archive.sh +++ b/ush/gldas_archive.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#! /usr/bin/env bash # ######################################################### # This script collects gldas output to archive directory @@ -13,44 +13,34 @@ # RUNDIR - run directory # GDAS - /lfs/h1/ops/prod/com/gfs/prod # -# gldas runs 72 hrs, from day1.00z to day4.00z -# first 36 hr obs precip forcing -# second 36 hrs gdas model forcing to bring it to realtime. -# -# save all output to day1 directory -# save noah.rst.day2 to day2 directory for next day restart -# save gdas.t00z.sfcanl.nemsio.gldas.day4 to day4 directory for gfs restart -# -# script history: -# 20190604 Jesse Meng - first version -# 20191010 Youlong Xia - modified ######################################################### -set -ux + +source "$HOMEgfs/ush/preamble.sh" if [ $# -lt 1 ]; then -echo "usage: ksh $0 sdate [edate]" -exit $? + echo "usage: $0 sdate [edate]" + exit $? fi sdate=$1 -edate=`sh $FINDDATE $1 d+1` +edate=$(sh $FINDDATE $1 d+1) if [ $# -gt 1 ]; then edate=$2 ; fi -yyyy=`echo $sdate | cut -c1-4` +yyyy=$(echo $sdate | cut -c1-4) ### save all output to day1 directory export COMDIR=${COM_OUT} mkdir -p $COMDIR/gldas.$sdate -yyyymmdd=`sh $FINDDATE $sdate d+1` +yyyymmdd=$(sh $FINDDATE $sdate d+1) while [ $yyyymmdd -le $edate ]; do mkdir -p $COMDIR/gldas.$yyyymmdd -yyyy=`echo $yyyymmdd | cut -c1-4` +yyyy=$(echo $yyyymmdd | cut -c1-4) cp $RUNDIR/EXP901/NOAH/$yyyy/$yyyymmdd/* $COMDIR/gldas.$sdate -yyyymmdd=`sh $FINDDATE $yyyymmdd d+1` +yyyymmdd=$(sh $FINDDATE $yyyymmdd d+1) done cp $RUNDIR/sfc.gaussian.nemsio.$sdate $COMDIR/gldas.$sdate @@ -61,16 +51,16 @@ yyyymmdd=$sdate while [ $yyyymmdd -lt $edate ]; do day1=$yyyymmdd -day2=`sh $FINDDATE $yyyymmdd d+1` +day2=$(sh $FINDDATE $yyyymmdd d+1) mv $COMDIR/gldas.$sdate/LIS.E901.${day2}00.NOAH.grb $COMDIR/gldas.$sdate/LIS.E901.${day1}00.NOAH.grb -yyyymmdd=`sh $FINDDATE $yyyymmdd d+1` +yyyymmdd=$(sh $FINDDATE $yyyymmdd d+1) done ### save noah.rst.day2 to day2 directory for next day gldas restart -yyyymmdd=`sh $FINDDATE $sdate d+1` -yyyy=`echo $yyyymmdd | cut -c1-4` +yyyymmdd=$(sh $FINDDATE $sdate d+1) +yyyy=$(echo $yyyymmdd | cut -c1-4) mkdir -p $COMDIR/gldas.$edate cp $RUNDIR/EXP901/NOAH/$yyyy/$edate/LIS.E901.${edate}00.Noahrst $COMDIR/gldas.$yyyymmdd/noah.rst.$edate diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index 6bc9c18181..b778570de1 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -1,22 +1,14 @@ -#!/bin/ksh +#! /usr/bin/env bash ########################################################################### # this script gets cpc daily precipitation and using gdas hourly precipitation # to disaggregate daily value into hourly value -# 20190509 Jesse Meng - first version -# 20191008 Youlong Xia - modified -# 20191123 Fanglin Yang - restructured for global-workflow ########################################################################### +source "$HOMEgfs/ush/preamble.sh" + bdate=$1 edate=$2 -# Set environment -export VERBOSE=${VERBOSE:-"YES"} -if [ $VERBOSE = "YES" ]; then - echo $(date) EXECUTING $0 $* >&2 - set -x -fi - # HOMEgldas - gldas directory # EXECgldas - gldas exec directory # PARMgldas - gldas param directory @@ -29,11 +21,11 @@ export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} #------------------------------- #--- extract variables of each timestep and create forcing files sdate=$bdate -edate=`sh $FINDDATE $edate d-1` +edate=$(sh $FINDDATE $edate d-1) while [ $sdate -lt $edate ]; do #------------------------------- -sdat0=`sh $FINDDATE $sdate d-1` +sdat0=$(sh $FINDDATE $sdate d-1) [[ ! -d $xpath/cpc.${sdate} ]] && mkdir -p $xpath/cpc.${sdate} [[ ! -d $xpath/cpc.${sdat0} ]] && mkdir -p $xpath/cpc.${sdat0} @@ -43,7 +35,7 @@ rm -f fort.* grib.* COMPONENT=${COMPONENT:-"atmos"} pathp1=$CPCGAUGE/gdas.$sdate/00/$COMPONENT pathp2=$DCOMIN/$sdate/wgrbbul/cpc_rcdas -yyyy=`echo $sdate |cut -c 1-4` +yyyy=$(echo $sdate |cut -c 1-4) cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT" if [ $RUN_ENVIR = "emc" ] && [ $sdate -gt $bdate ]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT_early" @@ -116,7 +108,7 @@ cp fort.24 $xpath/cpc.$sdate/precip.gldas.${sdate}06 rm -f fort.* grib.* #------------------------------- -sdate=`sh $FINDDATE $sdate d+1` +sdate=$(sh $FINDDATE $sdate d+1) done #------------------------------- diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 529ebbc260..fa7aacf70e 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -1,17 +1,10 @@ -#!/bin/ksh +#! /usr/bin/env bash ######################################################### # This script generate gldas forcing from gdas prod sflux # script history: -# 20190509 Jesse Meng - first version -# 20191008 Youlong Xia - modified -# 20191123 Fanglin Yang - restructured for global-workflow ######################################################### -export VERBOSE=${VERBOSE:-"YES"} -if [ $VERBOSE = "YES" ]; then - echo $(date) EXECUTING $0 $* >&2 - set -x -fi +source "$HOMEgfs/ush/preamble.sh" bdate=$1 edate=$2 @@ -32,15 +25,15 @@ cycint=${assim_freq:-6} # get gdas flux files to force gldas. # CPC precipitation is from 12z to 12z. One more day of gdas data is # needed to disaggregate daily CPC precipitation values to hourly values -cdate=`$NDATE -12 $bdate` +cdate=$($NDATE -12 $bdate) iter=0 #------------------------------- while [ $cdate -lt $edate ]; do #------------------------------- - ymd=`echo $cdate |cut -c 1-8` - cyc=`echo $cdate |cut -c 9-10` + ymd=$(echo $cdate |cut -c 1-8) + cyc=$(echo $cdate |cut -c 9-10) [[ ! -d $fpath/gdas.${ymd} ]] && mkdir -p $fpath/gdas.${ymd} [[ ! -d $gpath/gdas.${ymd} ]] && mkdir -p $gpath/gdas.${ymd} @@ -73,7 +66,7 @@ while [ $f -le $cycint ]; do done #------------------------------- - cdate=`$NDATE +$cycint $cdate` + cdate=$($NDATE +$cycint $cdate) done #------------------------------- diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index d7ffec2ad2..51a1226853 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -1,21 +1,24 @@ -#!/bin/sh +#! /usr/bin/env bash + +source "$HOMEgfs/ush/preamble.sh" + if [ $# -lt 3 ]; then -echo usage $0 yyyymmddhh1 yyyymmddhh2 126/382/574/1534 -exit $? + echo usage $0 yyyymmddhh1 yyyymmddhh2 126/382/574/1534 + exit $? fi date1=$1 date2=$2 grid=$3 -export yyyy1=`echo $date1 | cut -c 1-4` -export mm1=`echo $date1 | cut -c 5-6` -export dd1=`echo $date1 | cut -c 7-8` -export hh1=`echo $date1 | cut -c 9-10` -export yyyy2=`echo $date2 | cut -c 1-4` -export mm2=`echo $date2 | cut -c 5-6` -export dd2=`echo $date2 | cut -c 7-8` -export hh2=`echo $date2 | cut -c 9-10` +export yyyy1=$(echo $date1 | cut -c 1-4) +export mm1=$(echo $date1 | cut -c 5-6) +export dd1=$(echo $date1 | cut -c 7-8) +export hh1=$(echo $date1 | cut -c 9-10) +export yyyy2=$(echo $date2 | cut -c 1-4) +export mm2=$(echo $date2 | cut -c 5-6) +export dd2=$(echo $date2 | cut -c 7-8) +export hh2=$(echo $date2 | cut -c 9-10) export grid=$grid export PARM_LM=${PARMgldas} export LISCARD=lis.crd diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh index d095d4cf30..f6d793378d 100755 --- a/ush/gldas_post.sh +++ b/ush/gldas_post.sh @@ -1,9 +1,10 @@ -#/bin/sh -set -x +#! /usr/bin/env bash + +source "$HOMEgfs/ush/preamble.sh" if [ $# -lt 2 ]; then -echo "usage: $0 gldas.gbin gdas.sfcanl" - err_exit 99 + echo "usage: $0 gldas.gbin gdas.sfcanl" + err_exit 99 fi cd $RUNDIR @@ -18,12 +19,9 @@ rm -f fort.11 fort.12 fort.22 cp $gbin fort.11 cp $sfcanl fort.12 - echo 'running NOAH model' - startmsg - ${EXECgldas}/gldas_post >>$pgmout 2>errfile - export err=$?; err_chk +${EXECgldas}/gldas_post >>$pgmout 2>errfile +export err=$?; err_chk -##cp fort.22 ${sfcanl}.gldas cp fort.22 ./gldas.nemsio cp fort.22 ${sfcanl}.gldas rm -f fort.11 fort.12 fort.22 diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index 74db995775..44237d554c 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -1,39 +1,31 @@ -#!/bin/bash +#! /usr/bin/env bash - set -x +source "$HOMEgfs/ush/preamble.sh" - rflux=$1 - fcsty=$2 - fflux=$3 - gflux=$4 - f=$5 +rflux=$1 +fcsty=$2 +fflux=$3 +gflux=$4 +f=$5 - $WGRIB2 $rflux | grep "TMP:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "SPFH:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "UGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "VGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "HGT:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "PRES:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "PRATE:surface" | grep ave | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "VEG:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "SFCR:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "SFEXC:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "TMP:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "WEASD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "SNOD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -# $WGRIB2 $rflux | grep "SOILW:0-0" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -# $WGRIB2 $rflux | grep "SOILW:0.1" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -# $WGRIB2 $rflux | grep "SOILW:0.4" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -# $WGRIB2 $rflux | grep "SOILW:1-2" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "TMP:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "SPFH:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "UGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "VGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "HGT:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "PRES:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "PRATE:surface" | grep ave | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "VEG:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "SFCR:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "SFEXC:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "TMP:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "WEASD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "SNOD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "DSWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "DLWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux - $WGRIB2 $rflux | grep "USWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "DSWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "DLWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux +$WGRIB2 $rflux | grep "USWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux -#gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -#$COPYGB -g"$gds" -x $fflux flux1534 -#mv flux1534 $fflux +$CNVGRIB -g21 $fflux $gflux - $CNVGRIB -g21 $fflux $gflux - - exit $? +exit $? From 72bba7e7b699eee48116b4ab4bae29358dd70049 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 09:38:23 -0500 Subject: [PATCH 05/36] Cleanup GLDAS script doc blocks more Refs #1014 --- scripts/exgdas_atmos_gldas.sh | 5 +---- ush/gldas_get_data.sh | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index ad14fc62ab..c52a40dc36 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -3,12 +3,9 @@ ################################################################################ #### UNIX Script Documentation Block # . . -# Script name: exgdas_gldas.sh.ecf +# Script name: exgdas_atmos_gldas.sh # Script description: Runs the global land analysis # -# History: -# 20191015 Jesse Meng and Youlong Xia, first version -# 20191123 Fanglin Yang, restructure for global workflow ################################################################################ source "$HOMEgfs/ush/preamble.sh" diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index fa7aacf70e..79bad966e4 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -1,7 +1,6 @@ #! /usr/bin/env bash ######################################################### # This script generate gldas forcing from gdas prod sflux -# script history: ######################################################### source "$HOMEgfs/ush/preamble.sh" From 4d7a6dbe247e9c7e2908aa30948fe9a573ea42bc Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 13:54:30 -0500 Subject: [PATCH 06/36] Address linter warnings and remove obsolete platforms - Remove references to WCOSS_DELL_P3 and WCOSS_C in GLDAS scripts. - Update $HOMEgfs variable in GLDAS preable source lines to address warnings from linter regarding: 1) HOMEgfs is referenced but not assigned. 2) Prefer putting braces around variable references even when not strictly required. Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 2 +- scripts/exgdas_atmos_gldas.sh | 2 +- ush/gldas_archive.sh | 2 +- ush/gldas_forcing.sh | 2 +- ush/gldas_get_data.sh | 11 ++++------- ush/gldas_liscrd.sh | 2 +- ush/gldas_post.sh | 2 +- ush/gldas_process_data.sh | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index a75e814a00..b4f5b2aa43 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -1,6 +1,6 @@ #! /usr/bin/env bash -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" ############################# # Source relevant config files diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index c52a40dc36..e98320ec18 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -8,7 +8,7 @@ # ################################################################################ -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" ################################# # Set up UTILITIES diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh index fa5e47fe04..193b7f0f1e 100755 --- a/ush/gldas_archive.sh +++ b/ush/gldas_archive.sh @@ -15,7 +15,7 @@ # ######################################################### -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" if [ $# -lt 1 ]; then echo "usage: $0 sdate [edate]" diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index b778570de1..9f6ccaf905 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -4,7 +4,7 @@ # to disaggregate daily value into hourly value ########################################################################### -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 79bad966e4..24d358d431 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -3,13 +3,12 @@ # This script generate gldas forcing from gdas prod sflux ######################################################### -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 -if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ - [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then +if [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then touch ./cfile fi @@ -51,8 +50,7 @@ while [ $f -le $cycint ]; do fcsty=anl if [ $f -ge 1 ]; then fcsty=fcst; fi - if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ - [ $machine = "WCOSS2" ]; then + if [ $machine = "WCOSS2" ]; then echo "${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile elif [ $machine = "HERA" ]; then echo "$iter ${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile @@ -69,8 +67,7 @@ done done #------------------------------- -if [ $machine = "WCOSS_DELL_P3" ] || [ $machine = "WCOSS_C" ] || \ - [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then +if [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then $APRUN_GLDAS_DATA_PROC ./cfile fi diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 51a1226853..0c4fa79c86 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" if [ $# -lt 3 ]; then echo usage $0 yyyymmddhh1 yyyymmddhh2 126/382/574/1534 diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh index f6d793378d..bd9de60f81 100755 --- a/ush/gldas_post.sh +++ b/ush/gldas_post.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" if [ $# -lt 2 ]; then echo "usage: $0 gldas.gbin gdas.sfcanl" diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index 44237d554c..2f8a663983 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -source "$HOMEgfs/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" rflux=$1 fcsty=$2 From 79f747cd3bf991dfdf734cdf0eeebf4c12f3495d Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 15:26:03 -0500 Subject: [PATCH 07/36] Address linter warnings in JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 73 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index b4f5b2aa43..5b7e63f12a 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -5,45 +5,46 @@ source "${HOMEgfs:?}/ush/preamble.sh" ############################# # Source relevant config files ############################# -export EXPDIR=${EXPDIR:-$HOMEgfs/parm/config} +export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config} configs="base gldas" -config_path=${EXPDIR:-$NWROOT/gfs.${gfs_ver}/parm/config} -for config in $configs; do - . $config_path/config.$config +config_path=${EXPDIR:-${NWROOT}/gfs.${gfs_ver}/parm/config} +for config in ${configs}; do + # shellcheck source=parm/config/${config} + . "${config_path}/config.${config}" status=$? - [[ $status -ne 0 ]] && exit $status + [[ ${status} -ne 0 ]] && exit "${status}" done -if [ $cyc -ne $gldas_cyc ]; then - echo "GLDAS only runs for $gldas_cyc cycle; Skip GLDAS step for cycle $cyc" +if [ "${cyc:?}" -ne "${gldas_cyc:?}" ]; then + echo "GLDAS only runs for ${gldas_cyc} cycle; Skip GLDAS step for cycle ${cyc}" exit 0 fi xtime=$((gldas_spinup_hours+12)) -if [ $CDATE -le $($NDATE +$xtime $SDATE) ]; then - echo "GLDAS needs fluxes as forcing from cycles in previous $xtime hours" - echo "starting from $SDATE. This gldas cycle is skipped" +if [ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]; then + echo "GLDAS needs fluxes as forcing from cycles in previous ${xtime} hours" + echo "starting from ${SDATE}. This gldas cycle is skipped" exit 0 fi ########################################## # Source machine runtime environment ########################################## -. $HOMEgfs/env/${machine}.env gldas +. "${HOMEgfs}/env/${machine:?}.env gldas" status=$? -[[ $status -ne 0 ]] && exit $status +[[ ${status} -ne 0 ]] && exit "${status}" ############################################## # Obtain unique process id (pid) and make temp directory ############################################## export pid=${pid:-$$} -export outid=${outid:-"LL$job"} +export outid=${outid:-"LL${job}"} export DATA=${DATA:-${DATAROOT}/${jobid:?}} -mkdir -p $DATA -cd $DATA +mkdir -p "${DATA}" +cd "${DATA}" || exit ############################################## @@ -73,35 +74,35 @@ export COMPONENT=${COMPONENT:-atmos} # Begin JOB SPECIFIC work ############################################## export gldas_ver=${gldas_ver:-v2.3.0} -export HOMEgldas=${HOMEgldas:-$HOMEgfs} -export FIXgldas=${FIXgldas:-$HOMEgldas/fix/fix_gldas} -export PARMgldas=${PARMgldas:-$HOMEgldas/parm/gldas} -export EXECgldas=${EXECgldas:-$HOMEgldas/exec} -export USHgldas=${USHgldas:-$HOMEgldas/ush} -export PARA_CONFIG=$HOMEgfs/parm/config/config.gldas - -if [ $RUN_ENVIR = "nco" ]; then - export COMIN=${COMIN:-$ROTDIR/$RUN.$PDY/$cyc/$COMPONENT} - export COMOUT=${COMOUT:-$ROTDIR/$RUN.$PDY/$cyc/$COMPONENT} +export HOMEgldas=${HOMEgldas:-${HOMEgfs}} +export FIXgldas=${FIXgldas:-${HOMEgldas}/fix/fix_gldas} +export PARMgldas=${PARMgldas:-${HOMEgldas}/parm/gldas} +export EXECgldas=${EXECgldas:-${HOMEgldas}/exec} +export USHgldas=${USHgldas:-${HOMEgldas}/ush} +export PARA_CONFIG=${HOMEgfs}/parm/config/config.gldas + +if [ "${RUN_ENVIR:?}" = "nco" ]; then + export COMIN=${COMIN:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} + export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} else - export COMIN="$ROTDIR/$CDUMP.$PDY/$cyc/$COMPONENT" - export COMOUT="$ROTDIR/$CDUMP.$PDY/$cyc/$COMPONENT" + export COMIN="${ROTDIR}/${CDUMP}.${PDY}/${cyc}/${COMPONENT}" + export COMOUT="${ROTDIR}/${CDUMP}.${PDY}/${cyc}/${COMPONENT}" fi -[[ ! -d $COMOUT ]] && mkdir -m 775 -p $COMOUT +[[ ! -d ${COMOUT} ]] && mkdir -m 775 -p "${COMOUT}" -export COMINgdas=${COMINgdas:-$ROTDIR} +export COMINgdas=${COMINgdas:-${ROTDIR}} export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} export model=${model:-noah} -export MODEL=${MODEL:-$(echo $model |tr '[a-z]' '[A-Z]')} +export MODEL=${MODEL:-$(echo "${model} |tr 'a-z' 'A-Z'")} ############################################################### # Run relevant exglobal script -${GLDASSH:-$HOMEgldas/scripts/exgdas_atmos_gldas.sh} +${GLDASSH:-${HOMEgldas}/scripts/exgdas_atmos_gldas.sh} status=$? -[[ $status -ne 0 ]] && exit $status +[[ ${status} -ne 0 ]] && exit "${status}" ############################################## # End JOB SPECIFIC work @@ -110,15 +111,15 @@ status=$? ############################################## # Final processing ############################################## -if [ -e "$pgmout" ] ; then - cat $pgmout +if [ -e "${pgmout}" ] ; then + cat "${pgmout}" fi ########################################## # Remove the Temporary working directory ########################################## -cd $DATAROOT -[[ $KEEPDATA = "NO" ]] && rm -rf $DATA +cd "${DATAROOT}" || exit +[[ ${KEEPDATA} = "NO" ]] && rm -rf "${DATA}" exit 0 From 11e59b086de4c20792b92f73ccf9c639508b0dac Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 15:42:16 -0500 Subject: [PATCH 08/36] Address linter warning for KEEPDATA and assign gldas_spinup_hours Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 5b7e63f12a..4d11f0244c 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -21,6 +21,7 @@ if [ "${cyc:?}" -ne "${gldas_cyc:?}" ]; then exit 0 fi +gldas_spinup_hours=${gldas_spinup_hours-:72} xtime=$((gldas_spinup_hours+12)) if [ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]; then echo "GLDAS needs fluxes as forcing from cycles in previous ${xtime} hours" @@ -119,7 +120,7 @@ fi # Remove the Temporary working directory ########################################## cd "${DATAROOT}" || exit -[[ ${KEEPDATA} = "NO" ]] && rm -rf "${DATA}" +[[ ${KEEPDATA:?} = "NO" ]] && rm -rf "${DATA}" exit 0 From e27275e57bce3b21c1452f84506150d0a89bb6e6 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 15:53:26 -0500 Subject: [PATCH 09/36] Address linter warning for SC1091 in JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 4d11f0244c..82af8f4b7c 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -32,6 +32,7 @@ fi ########################################## # Source machine runtime environment ########################################## +# shellcheck source=env/${machine}.env . "${HOMEgfs}/env/${machine:?}.env gldas" status=$? [[ ${status} -ne 0 ]] && exit "${status}" @@ -53,7 +54,9 @@ cd "${DATA}" || exit ############################################## export cycle="t${cyc}z" setpdy.sh +# shellcheck disable=SC1091 . ./PDY +# shellcheck disable= ############################################## From 71878607a62a36cafa47501a50c6d6e72f3dd877 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 16:03:16 -0500 Subject: [PATCH 10/36] Update linter directive for machine env line in JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 82af8f4b7c..068e76ad90 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -32,7 +32,7 @@ fi ########################################## # Source machine runtime environment ########################################## -# shellcheck source=env/${machine}.env +# shellcheck source=env/wcoss2.env . "${HOMEgfs}/env/${machine:?}.env gldas" status=$? [[ ${status} -ne 0 ]] && exit "${status}" From 3bdf47a7c352b4abfe5c215daf72032e92094ddb Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 16:11:47 -0500 Subject: [PATCH 11/36] Make machine for env file uppercase Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 068e76ad90..474175c2cb 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -32,7 +32,7 @@ fi ########################################## # Source machine runtime environment ########################################## -# shellcheck source=env/wcoss2.env +# shellcheck source=env/WCOSS2.env . "${HOMEgfs}/env/${machine:?}.env gldas" status=$? [[ ${status} -ne 0 ]] && exit "${status}" From 63b34f6c5c9846b6d1a6be884ef5bb5db92b1280 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 12 Sep 2022 16:19:04 -0500 Subject: [PATCH 12/36] Address linter warnings in scripts/exgdas_atmos_gldas.sh - Address SC2016 (double instead of single quote for ERRSCRIPT and SC2250 (curly braces). Refs #1014 --- scripts/exgdas_atmos_gldas.sh | 214 +++++++++++++++++----------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index e98320ec18..2fe8131ff6 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -15,16 +15,16 @@ source "${HOMEgfs:?}/ush/preamble.sh" ################################# export FINDDATE=${FINDDATE:-/apps/ops/prod/nco/core/prod_util.v2.0.13/ush/finddate.sh} export utilexec=${utilexec:-/apps/ops/prod/libs/intel/19.1.3.304/grib_util/1.2.3/bin} -export CNVGRIB=${CNVGRIB:-$utilexec/cnvgrib} -export WGRIB=${WGRIB:-$utilexec/wgrib} +export CNVGRIB=${CNVGRIB:-${utilexec}/cnvgrib} +export WGRIB=${WGRIB:-${utilexec}/wgrib} export WGRIB2=${WGRIB2:-/apps/ops/prod/libs/intel/19.1.3.304/wgrib2/2.0.7/bin/wgrib2} -export COPYGB=${COPYGB:-$utilexec/copygb} +export COPYGB=${COPYGB:-${utilexec}/copygb} export NDATE=${NDATE:-/apps/ops/prod/nco/core/prod_util.v2.0.13/exec/ndate} export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} export CPCGAUGE=${CPCGAUGE:-/lfs/h2/emc/global/noscrub/emc.global/dump} -export COMINgdas=${COMINgdas:-$ROTDIR} +export COMINgdas=${COMINgdas:-${ROTDIR}} export OFFLINE_GLDAS=${OFFLINE_GLDAS:-"NO"} -export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} +export ERRSCRIPT=${ERRSCRIPT:-"eval [[ $err = 0 ]]"} ################################# @@ -34,130 +34,130 @@ export USE_CFP=${USE_CFP:-"NO"} export COMPONENT=${COMPONENT:-atmos} export assim_freq=${assim_freq:-6} export gldas_spinup_hours=${gldas_spinup_hours:-72} -export gldas_cdate=$CDATE -export gldas_eymd=$(echo $gldas_cdate |cut -c 1-8) -export gldas_ecyc=$(echo $gldas_cdate |cut -c 9-10) -export gldas_sdate=$($NDATE -$gldas_spinup_hours $CDATE) -export gldas_symd=$(echo $gldas_sdate |cut -c 1-8) -export gldas_scyc=$(echo $gldas_sdate |cut -c 9-10) - -export iau_cdate=$CDATE -if [ "$DOIAU" = "YES" ]; then +export gldas_cdate=${CDATE} +export gldas_eymd=$(echo ${gldas_cdate} |cut -c 1-8) +export gldas_ecyc=$(echo ${gldas_cdate} |cut -c 9-10) +export gldas_sdate=$(${NDATE} -${gldas_spinup_hours} ${CDATE}) +export gldas_symd=$(echo ${gldas_sdate} |cut -c 1-8) +export gldas_scyc=$(echo ${gldas_sdate} |cut -c 9-10) + +export iau_cdate=${CDATE} +if [ "${DOIAU}" = "YES" ]; then IAU_OFFSET=${IAU_OFFSET:-0} IAUHALH=$((IAU_OFFSET/2)) - export iau_cdate=$($NDATE -$IAUHALH $CDATE) + export iau_cdate=$(${NDATE} -${IAUHALH} ${CDATE}) fi -export iau_eymd=$(echo $iau_cdate |cut -c 1-8) -export iau_ecyc=$(echo $iau_cdate |cut -c 9-10) -echo "GLDAS runs from $gldas_sdate to $iau_cdate" +export iau_eymd=$(echo ${iau_cdate} |cut -c 1-8) +export iau_ecyc=$(echo ${iau_cdate} |cut -c 9-10) +echo "GLDAS runs from ${gldas_sdate} to ${iau_cdate}" export CASE=${CASE:-C768} -export res=$(echo $CASE |cut -c2-5) +export res=$(echo ${CASE} |cut -c2-5) export JCAP=$((2*res-2)) export nlat=$((2*res)) export nlon=$((4*res)) -export FIXgldas=${FIXgldas:-$HOMEgfs/fix} -export topodir=${topodir:-$HOMEgfs/fix/fix_fv3_gmted2010/$CASE/} +export FIXgldas=${FIXgldas:-${HOMEgfs}/fix} +export topodir=${topodir:-${HOMEgfs}/fix/fix_fv3_gmted2010/${CASE}/} -DATA=${DATA:-$pwd/gldastmp$$} +DATA=${DATA:-${pwd}/gldastmp$$} mkdata=NO -if [ ! -d $DATA ]; then +if [ ! -d ${DATA} ]; then mkdata=YES - mkdir -p $DATA + mkdir -p ${DATA} fi -cd $DATA || exit 1 -export RUNDIR=$DATA +cd ${DATA} || exit 1 +export RUNDIR=${DATA} ################################# GDAS=${RUNDIR}/force -mkdir -p $GDAS +mkdir -p ${GDAS} -input1=$COMINgdas/gdas.$gldas_symd/$gldas_scyc/$COMPONENT/RESTART -input2=$COMINgdas/gdas.$gldas_eymd/$gldas_ecyc/$COMPONENT/RESTART -[[ -d $RUNDIR ]] && rm -fr $RUNDIR/FIX -[[ -f $RUNDIR/LIS ]] && rm -fr $RUNDIR/LIS -[[ -d $RUNDIR/input ]] && rm -fr $RUNDIR/input -mkdir -p $RUNDIR/input -ln -fs $GDAS $RUNDIR/input/GDAS -ln -fs $FIXgldas/FIX_T${JCAP} $RUNDIR/FIX -ln -fs $EXECgldas/gldas_model $RUNDIR/LIS +input1=${COMINgdas}/gdas.${gldas_symd}/${gldas_scyc}/${COMPONENT}/RESTART +input2=${COMINgdas}/gdas.${gldas_eymd}/${gldas_ecyc}/${COMPONENT}/RESTART +[[ -d ${RUNDIR} ]] && rm -fr ${RUNDIR}/FIX +[[ -f ${RUNDIR}/LIS ]] && rm -fr ${RUNDIR}/LIS +[[ -d ${RUNDIR}/input ]] && rm -fr ${RUNDIR}/input +mkdir -p ${RUNDIR}/input +ln -fs ${GDAS} ${RUNDIR}/input/GDAS +ln -fs ${FIXgldas}/FIX_T${JCAP} ${RUNDIR}/FIX +ln -fs ${EXECgldas}/gldas_model ${RUNDIR}/LIS #--------------------------------------------------------------- ### 1) Get gdas 6-tile netcdf restart file and gdas forcing data #--------------------------------------------------------------- -${USHgldas}/gldas_get_data.sh $gldas_sdate $gldas_cdate +${USHgldas}/gldas_get_data.sh ${gldas_sdate} ${gldas_cdate} export err=$? -$ERRSCRIPT || exit 2 +${ERRSCRIPT} || exit 2 #--------------------------------------------------------------- ### 2) Get CPC daily precip and temporally disaggreated #--------------------------------------------------------------- -${USHgldas}/gldas_forcing.sh $gldas_symd $gldas_eymd +${USHgldas}/gldas_forcing.sh ${gldas_symd} ${gldas_eymd} export err=$? -$ERRSCRIPT || exit 3 +${ERRSCRIPT} || exit 3 # spatially disaggregated -if [ $JCAP -eq 1534 ]; then +if [ ${JCAP} -eq 1534 ]; then gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ $JCAP -eq 766 ]; then +elif [ ${JCAP} -eq 766 ]; then gds='255 4 1536 768 89821 0 128 -89821 -234 234 384 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ $JCAP -eq 382 ]; then +elif [ ${JCAP} -eq 382 ]; then gds='255 4 768 384 89641 0 128 -89641 -469 469 192 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ $JCAP -eq 190 ]; then +elif [ ${JCAP} -eq 190 ]; then gds='255 4 384 192 89284 0 128 -89284 -938 938 96 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' else - echo "JCAP=$JCAP not supported, exit" + echo "JCAP=${JCAP} not supported, exit" export err=4 - $ERRSCRIPT || exit 4 + ${ERRSCRIPT} || exit 4 fi -echo $JCAP -echo $gds -ymdpre=$(sh $FINDDATE $gldas_symd d-1) -ymdend=$(sh $FINDDATE $gldas_eymd d-2) -ymd=$ymdpre +echo ${JCAP} +echo ${gds} +ymdpre=$(sh ${FINDDATE} ${gldas_symd} d-1) +ymdend=$(sh ${FINDDATE} ${gldas_eymd} d-2) +ymd=${ymdpre} -if [ $USE_CFP = "YES" ] ; then +if [ ${USE_CFP} = "YES" ] ; then rm -f ./cfile touch ./cfile fi -while [ $ymd -le $ymdend ]; do - if [ $ymd -ne $ymdpre ]; then - if [ $USE_CFP = "YES" ] ; then - echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}00 $RUNDIR/cmap.gdas.${ymd}00" >> ./cfile - echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}06 $RUNDIR/cmap.gdas.${ymd}06" >> ./cfile +while [ ${ymd} -le ${ymdend} ]; do + if [ ${ymd} -ne ${ymdpre} ]; then + if [ ${USE_CFP} = "YES" ] ; then + echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00" >> ./cfile + echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06" >> ./cfile else - $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}00 $RUNDIR/cmap.gdas.${ymd}00 - $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}06 $RUNDIR/cmap.gdas.${ymd}06 + ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00 + ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06 fi fi - if [ $ymd -ne $ymdend ]; then - if [ $USE_CFP = "YES" ] ; then - echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}12 $RUNDIR/cmap.gdas.${ymd}12" >> ./cfile - echo "$COPYGB -i3 '-g"$gds"' -x $GDAS/cpc.$ymd/precip.gldas.${ymd}18 $RUNDIR/cmap.gdas.${ymd}18" >> ./cfile + if [ ${ymd} -ne ${ymdend} ]; then + if [ ${USE_CFP} = "YES" ] ; then + echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12" >> ./cfile + echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18" >> ./cfile else - $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}12 $RUNDIR/cmap.gdas.${ymd}12 - $COPYGB -i3 -g"$gds" -x $GDAS/cpc.$ymd/precip.gldas.${ymd}18 $RUNDIR/cmap.gdas.${ymd}18 + ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12 + ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18 fi fi - ymd=$(sh $FINDDATE $ymd d+1) + ymd=$(sh ${FINDDATE} ${ymd} d+1) done -if [ $USE_CFP = "YES" ] ; then - $APRUN_GLDAS_DATA_PROC ./cfile +if [ ${USE_CFP} = "YES" ] ; then + ${APRUN_GLDAS_DATA_PROC} ./cfile fi # create configure file -${USHgldas}/gldas_liscrd.sh $gldas_sdate $iau_cdate ${JCAP} +${USHgldas}/gldas_liscrd.sh ${gldas_sdate} ${iau_cdate} ${JCAP} export err=$? -$ERRSCRIPT || exit 4 +${ERRSCRIPT} || exit 4 #--------------------------------------------------------------- @@ -169,14 +169,14 @@ rm -f fort.41 fort.141 fort.11 fort.12 cat >> fort.141 << EOF &config - data_dir_input_grid="$input1" + data_dir_input_grid="${input1}" sfc_files_input_grid="${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile1.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile2.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile3.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile4.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile5.nc","${gldas_symd}.${gldas_scyc}0000.sfcanl_data.tile6.nc" mosaic_file_input_grid="${CASE}_mosaic.nc" - orog_dir_input_grid="$topodir" + orog_dir_input_grid="${topodir}" orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" - i_target=$nlon - j_target=$nlat - model="$model" + i_target=${nlon} + j_target=${nlat} + model="${model}" / EOF cp fort.141 fort.41 @@ -187,23 +187,23 @@ cp fort.141 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas . prep_step -$APRUN_GAUSSIAN ${EXECgldas}/gdas2gldas 1>&1 2>&2 +${APRUN_GAUSSIAN} ${EXECgldas}/gdas2gldas 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 5 +${ERRSCRIPT} || exit 5 # 3c)gldas_rst to generate noah.rst sfcanl=sfc.gaussian.nemsio ln -fs FIX/lmask_gfs_T${JCAP}.bfsa fort.11 -ln -fs $sfcanl fort.12 +ln -fs ${sfcanl} fort.12 export pgm=gldas_rst . prep_step ${EXECgldas}/gldas_rst 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 6 +${ERRSCRIPT} || exit 6 -mv $sfcanl ${sfcanl}.$gldas_symd +mv ${sfcanl} ${sfcanl}.${gldas_symd} #--------------------------------------------------------------- @@ -211,9 +211,9 @@ mv $sfcanl ${sfcanl}.$gldas_symd #--------------------------------------------------------------- export pgm=LIS . prep_step -$APRUN_GLDAS ./LIS 1>&1 2>&2 +${APRUN_GLDAS} ./LIS 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 7 +${ERRSCRIPT} || exit 7 #--------------------------------------------------------------- @@ -227,14 +227,14 @@ rm -f fort.41 fort.241 fort.42 cat >> fort.241 << EOF &config - data_dir_input_grid="$input2" + data_dir_input_grid="${input2}" sfc_files_input_grid="${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile1.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile2.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile3.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile4.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile5.nc","${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile6.nc" mosaic_file_input_grid="${CASE}_mosaic.nc" - orog_dir_input_grid="$topodir" + orog_dir_input_grid="${topodir}" orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" - i_target=$nlon - j_target=$nlat - model="$model" + i_target=${nlon} + j_target=${nlat} + model="${model}" / EOF cp fort.241 fort.41 @@ -244,25 +244,25 @@ cp fort.241 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas . prep_step -$APRUN_GAUSSIAN ${EXECgldas}/gdas2gldas 1>&1 2>&2 +${APRUN_GAUSSIAN} ${EXECgldas}/gdas2gldas 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 8 +${ERRSCRIPT} || exit 8 # 5c) use gldas_post to replace soil moisture and temperature -yyyy=$(echo $iau_eymd | cut -c1-4) -gbin=$RUNDIR/EXP901/NOAH/$yyyy/$iau_eymd/LIS.E901.${iau_eymd}${iau_ecyc}.NOAHgbin +yyyy=$(echo ${iau_eymd} | cut -c1-4) +gbin=${RUNDIR}/EXP901/NOAH/${yyyy}/${iau_eymd}/LIS.E901.${iau_eymd}${iau_ecyc}.NOAHgbin sfcanl=sfc.gaussian.nemsio rm -rf fort.11 fort.12 -ln -fs $gbin fort.11 -ln -fs $sfcanl fort.12 +ln -fs ${gbin} fort.11 +ln -fs ${sfcanl} fort.12 export pgm=gldas_post . prep_step ${EXECgldas}/gldas_post 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 9 +${ERRSCRIPT} || exit 9 cp fort.22 ./gldas.nemsio mv fort.22 ${sfcanl}.gldas @@ -272,14 +272,14 @@ mv fort.22 ${sfcanl}.gldas cat >> fort.42 << EOF &config - orog_dir_gdas_grid="$topodir" + orog_dir_gdas_grid="${topodir}" mosaic_file_gdas_grid="${CASE}_mosaic.nc" / EOF # copy/link gdas netcdf tiles -k=1; while [ $k -le 6 ]; do - cp $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ./sfc_data.tile${k}.nc +k=1; while [ ${k} -le 6 ]; do + cp ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ./sfc_data.tile${k}.nc k=$((k+1)) done @@ -289,21 +289,21 @@ ln -fs FIX/stype_gfs_T${JCAP}.bfsa stype_gfs_T${JCAP}.bfsa export OMP_NUM_THREADS=1 export pgm=gldas2gdas . prep_step -$APRUN_GAUSSIAN $EXECgldas/gldas2gdas 1>&1 2>&2 +${APRUN_GAUSSIAN} ${EXECgldas}/gldas2gdas 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 10 +${ERRSCRIPT} || exit 10 # 5e) archive gldas results -if [ $OFFLINE_GLDAS = "YES" ]; then - ${USHgldas}/gldas_archive.sh $gldas_symd $gldas_eymd +if [ ${OFFLINE_GLDAS} = "YES" ]; then + ${USHgldas}/gldas_archive.sh ${gldas_symd} ${gldas_eymd} export err=$? - $ERRSCRIPT || exit 11 + ${ERRSCRIPT} || exit 11 else - k=1; while [ $k -le 6 ]; do - mv $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas - cp sfc_data.tile${k}.nc $input2/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc + k=1; while [ ${k} -le 6 ]; do + mv ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas + cp sfc_data.tile${k}.nc ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc k=$((k+1)) done fi @@ -311,7 +311,7 @@ fi #------------------------------------------------------------------ # Clean up before leaving -if [ $mkdata = "YES" ]; then rm -rf $DATA; fi +if [ ${mkdata} = "YES" ]; then rm -rf ${DATA}; fi -exit $err +exit ${err} From fda14813a07ce1bad13868154203127a94321ca1 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 11:23:33 -0500 Subject: [PATCH 13/36] Resolve SC2250 (curly brace) shellcheck warnings in GLDAS ush scripts Refs #1014 --- ush/gldas_archive.sh | 62 +++++++++++------------ ush/gldas_forcing.sh | 102 +++++++++++++++++++------------------- ush/gldas_get_data.sh | 54 ++++++++++---------- ush/gldas_liscrd.sh | 52 +++++++++---------- ush/gldas_post.sh | 8 +-- ush/gldas_process_data.sh | 34 ++++++------- 6 files changed, 156 insertions(+), 156 deletions(-) diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh index 193b7f0f1e..16282124fd 100755 --- a/ush/gldas_archive.sh +++ b/ush/gldas_archive.sh @@ -23,61 +23,61 @@ if [ $# -lt 1 ]; then fi sdate=$1 -edate=$(sh $FINDDATE $1 d+1) +edate=$(sh ${FINDDATE} $1 d+1) if [ $# -gt 1 ]; then edate=$2 ; fi -yyyy=$(echo $sdate | cut -c1-4) +yyyy=$(echo ${sdate} | cut -c1-4) ### save all output to day1 directory export COMDIR=${COM_OUT} -mkdir -p $COMDIR/gldas.$sdate -yyyymmdd=$(sh $FINDDATE $sdate d+1) -while [ $yyyymmdd -le $edate ]; do +mkdir -p ${COMDIR}/gldas.${sdate} +yyyymmdd=$(sh ${FINDDATE} ${sdate} d+1) +while [ ${yyyymmdd} -le ${edate} ]; do -mkdir -p $COMDIR/gldas.$yyyymmdd +mkdir -p ${COMDIR}/gldas.${yyyymmdd} -yyyy=$(echo $yyyymmdd | cut -c1-4) -cp $RUNDIR/EXP901/NOAH/$yyyy/$yyyymmdd/* $COMDIR/gldas.$sdate +yyyy=$(echo ${yyyymmdd} | cut -c1-4) +cp ${RUNDIR}/EXP901/NOAH/${yyyy}/${yyyymmdd}/* ${COMDIR}/gldas.${sdate} -yyyymmdd=$(sh $FINDDATE $yyyymmdd d+1) +yyyymmdd=$(sh ${FINDDATE} ${yyyymmdd} d+1) done -cp $RUNDIR/sfc.gaussian.nemsio.$sdate $COMDIR/gldas.$sdate +cp ${RUNDIR}/sfc.gaussian.nemsio.${sdate} ${COMDIR}/gldas.${sdate} ### rename grb files -yyyymmdd=$sdate -while [ $yyyymmdd -lt $edate ]; do +yyyymmdd=${sdate} +while [ ${yyyymmdd} -lt ${edate} ]; do -day1=$yyyymmdd -day2=$(sh $FINDDATE $yyyymmdd d+1) -mv $COMDIR/gldas.$sdate/LIS.E901.${day2}00.NOAH.grb $COMDIR/gldas.$sdate/LIS.E901.${day1}00.NOAH.grb +day1=${yyyymmdd} +day2=$(sh ${FINDDATE} ${yyyymmdd} d+1) +mv ${COMDIR}/gldas.${sdate}/LIS.E901.${day2}00.NOAH.grb ${COMDIR}/gldas.${sdate}/LIS.E901.${day1}00.NOAH.grb -yyyymmdd=$(sh $FINDDATE $yyyymmdd d+1) +yyyymmdd=$(sh ${FINDDATE} ${yyyymmdd} d+1) done -### save noah.rst.day2 to day2 directory for next day gldas restart +### save noah.rst.day2 to day2 directory for next day gldas restart -yyyymmdd=$(sh $FINDDATE $sdate d+1) -yyyy=$(echo $yyyymmdd | cut -c1-4) -mkdir -p $COMDIR/gldas.$edate -cp $RUNDIR/EXP901/NOAH/$yyyy/$edate/LIS.E901.${edate}00.Noahrst $COMDIR/gldas.$yyyymmdd/noah.rst.$edate +yyyymmdd=$(sh ${FINDDATE} ${sdate} d+1) +yyyy=$(echo ${yyyymmdd} | cut -c1-4) +mkdir -p ${COMDIR}/gldas.${edate} +cp ${RUNDIR}/EXP901/NOAH/${yyyy}/${edate}/LIS.E901.${edate}00.Noahrst ${COMDIR}/gldas.${yyyymmdd}/noah.rst.${edate} ### generate and save gdas.t${cyc1}z.sfcanl.nemsio.gldas.day4 to day4 directory for next cycle gfs restart -mkdir -p $COMDIR/gldas.$edate +mkdir -p ${COMDIR}/gldas.${edate} gdate=${edate} gdas_date=${gdate}.${cyc}0000 -cp sfc_data.tile1.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile1.nc -cp sfc_data.tile2.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile2.nc -cp sfc_data.tile3.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile3.nc -cp sfc_data.tile4.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile4.nc -cp sfc_data.tile5.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile5.nc -cp sfc_data.tile6.nc $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile6.nc +cp sfc_data.tile1.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile1.nc +cp sfc_data.tile2.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile2.nc +cp sfc_data.tile3.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile3.nc +cp sfc_data.tile4.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile4.nc +cp sfc_data.tile5.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile5.nc +cp sfc_data.tile6.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc -cp sfc.gaussian.nemsio.gldas $COMDIR/gldas.$edate/${gdas_date}.sfc.gaussian.nemsio.gldas +cp sfc.gaussian.nemsio.gldas ${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gldas -cp sfc.gaussian.nemsio $COMDIR/gldas.$edate/${gdas_date}.sfc.gaussian.nemsio.gdas +cp sfc.gaussian.nemsio ${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gdas -echo $COMDIR/gldas.$edate/${gdas_date}.sfcanl_data.tile6.nc +echo ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index 9f6ccaf905..784a9112b6 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -13,71 +13,71 @@ edate=$2 # EXECgldas - gldas exec directory # PARMgldas - gldas param directory # FIXgldas - gldas fix field directory -export LISDIR=$HOMEgldas +export LISDIR=${HOMEgldas} export fpath=${RUNDIR}/force export xpath=${RUNDIR}/force export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} #------------------------------- #--- extract variables of each timestep and create forcing files -sdate=$bdate -edate=$(sh $FINDDATE $edate d-1) -while [ $sdate -lt $edate ]; do +sdate=${bdate} +edate=$(sh ${FINDDATE} ${edate} d-1) +while [ ${sdate} -lt ${edate} ]; do #------------------------------- -sdat0=$(sh $FINDDATE $sdate d-1) -[[ ! -d $xpath/cpc.${sdate} ]] && mkdir -p $xpath/cpc.${sdate} -[[ ! -d $xpath/cpc.${sdat0} ]] && mkdir -p $xpath/cpc.${sdat0} +sdat0=$(sh ${FINDDATE} ${sdate} d-1) +[[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p ${xpath}/cpc.${sdate} +[[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p ${xpath}/cpc.${sdat0} -cd $xpath +cd ${xpath} rm -f fort.* grib.* COMPONENT=${COMPONENT:-"atmos"} -pathp1=$CPCGAUGE/gdas.$sdate/00/$COMPONENT -pathp2=$DCOMIN/$sdate/wgrbbul/cpc_rcdas -yyyy=$(echo $sdate |cut -c 1-4) -cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT" -if [ $RUN_ENVIR = "emc" ] && [ $sdate -gt $bdate ]; then - cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.$sdate.RT_early" +pathp1=${CPCGAUGE}/gdas.${sdate}/00/${COMPONENT} +pathp2=${DCOMIN}/${sdate}/wgrbbul/cpc_rcdas +yyyy=$(echo ${sdate} |cut -c 1-4) +cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" +if [ ${RUN_ENVIR} = "emc" ] && [ ${sdate} -gt ${bdate} ]; then + cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" fi -cpc=$pathp1/$cpc_precip -if [ ! -s $cpc ]; then cpc=$pathp2/$cpc_precip ; fi -if [ $RUN_ENVIR = "nco" ]; then cpc=$pathp2/$cpc_precip ; fi -if [ ! -s $cpc ]; then - echo "WARNING: GLDAS MISSING $cpc, WILL NOT RUN." +cpc=${pathp1}/${cpc_precip} +if [ ! -s ${cpc} ]; then cpc=${pathp2}/${cpc_precip} ; fi +if [ ${RUN_ENVIR} = "nco" ]; then cpc=${pathp2}/${cpc_precip} ; fi +if [ ! -s ${cpc} ]; then + echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." exit 3 fi -cp $cpc $xpath/cpc.$sdate/. +cp ${cpc} ${xpath}/cpc.${sdate}/. -sflux=$fpath/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 +sflux=${fpath}/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 prate=gdas.${sdat0}12 -$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate +${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} -sflux=$fpath/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 +sflux=${fpath}/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 prate=gdas.${sdat0}18 -$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate +${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} -sflux=$fpath/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 +sflux=${fpath}/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 prate=gdas.${sdate}00 -$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate +${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} -sflux=$fpath/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 +sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 prate=gdas.${sdate}06 -$WGRIB -s $sflux | grep "PRATE:sfc" | $WGRIB -i $sflux -grib -o $prate +${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} -if [ $USE_CFP = "YES" ] ; then +if [ ${USE_CFP} = "YES" ] ; then rm -f ./cfile touch ./cfile - echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile - echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" >> ./cfile - echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" >> ./cfile - echo "$COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile - $APRUN_GLDAS_DATA_PROC ./cfile + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" >> ./cfile + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" >> ./cfile + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile + ${APRUN_GLDAS_DATA_PROC} ./cfile else - $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12 - $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18 - $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00 - $COPYGB -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06 fi rm -f fort.10 @@ -88,28 +88,28 @@ echo ${sdate} >> fort.10 export pgm=gldas_forcing . prep_step -$WGRIB -d -bin grib.12 -o fort.11 -$WGRIB -d -bin grib.18 -o fort.12 -$WGRIB -d -bin grib.00 -o fort.13 -$WGRIB -d -bin grib.06 -o fort.14 +${WGRIB} -d -bin grib.12 -o fort.11 +${WGRIB} -d -bin grib.18 -o fort.12 +${WGRIB} -d -bin grib.00 -o fort.13 +${WGRIB} -d -bin grib.06 -o fort.14 -ln -fs $xpath/cpc.$sdate/$cpc_precip fort.15 +ln -fs ${xpath}/cpc.${sdate}/${cpc_precip} fort.15 -$EXECgldas/gldas_forcing 1>&1 2>&2 +${EXECgldas}/gldas_forcing 1>&1 2>&2 export err=$? -$ERRSCRIPT || exit 3 +${ERRSCRIPT} || exit 3 -cp fort.21 $xpath/cpc.$sdat0/precip.gldas.${sdat0}12 -cp fort.22 $xpath/cpc.$sdat0/precip.gldas.${sdat0}18 -cp fort.23 $xpath/cpc.$sdate/precip.gldas.${sdate}00 -cp fort.24 $xpath/cpc.$sdate/precip.gldas.${sdate}06 +cp fort.21 ${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}12 +cp fort.22 ${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}18 +cp fort.23 ${xpath}/cpc.${sdate}/precip.gldas.${sdate}00 +cp fort.24 ${xpath}/cpc.${sdate}/precip.gldas.${sdate}06 rm -f fort.* grib.* #------------------------------- -sdate=$(sh $FINDDATE $sdate d+1) +sdate=$(sh ${FINDDATE} ${sdate} d+1) done #------------------------------- -exit $err +exit ${err} diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 24d358d431..fafa8cce8e 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -8,7 +8,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 -if [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then +if [ ${machine} = "HERA" ] || [ ${machine} = "WCOSS2" ]; then touch ./cfile fi @@ -16,46 +16,46 @@ fi ### RUNDIR = gldas forcing in grib2 format ### RUNDIR/force = gldas forcing in grib1 format export COMPONENT=${COMPONENT:-atmos} -fpath=$RUNDIR -gpath=$RUNDIR/force +fpath=${RUNDIR} +gpath=${RUNDIR}/force cycint=${assim_freq:-6} # get gdas flux files to force gldas. -# CPC precipitation is from 12z to 12z. One more day of gdas data is +# CPC precipitation is from 12z to 12z. One more day of gdas data is # needed to disaggregate daily CPC precipitation values to hourly values -cdate=$($NDATE -12 $bdate) +cdate=$(${NDATE} -12 ${bdate}) iter=0 #------------------------------- -while [ $cdate -lt $edate ]; do +while [ ${cdate} -lt ${edate} ]; do #------------------------------- - ymd=$(echo $cdate |cut -c 1-8) - cyc=$(echo $cdate |cut -c 9-10) - [[ ! -d $fpath/gdas.${ymd} ]] && mkdir -p $fpath/gdas.${ymd} - [[ ! -d $gpath/gdas.${ymd} ]] && mkdir -p $gpath/gdas.${ymd} + ymd=$(echo ${cdate} |cut -c 1-8) + cyc=$(echo ${cdate} |cut -c 9-10) + [[ ! -d ${fpath}/gdas.${ymd} ]] && mkdir -p ${fpath}/gdas.${ymd} + [[ ! -d ${gpath}/gdas.${ymd} ]] && mkdir -p ${gpath}/gdas.${ymd} f=1 -while [ $f -le $cycint ]; do - rflux=${COMINgdas}/gdas.$ymd/$cyc/$COMPONENT/gdas.t${cyc}z.sfluxgrbf00$f.grib2 - fflux=$fpath/gdas.$ymd/gdas.t${cyc}z.sfluxgrbf0$f.grib2 - gflux=$gpath/gdas.$ymd/gdas1.t${cyc}z.sfluxgrbf0$f - if [ ! -s $rflux ];then - echo "WARNING: GLDAS MISSING $rflux, WILL NOT RUN." +while [ ${f} -le ${cycint} ]; do + rflux=${COMINgdas}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 + fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 + gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} + if [ ! -s ${rflux} ];then + echo "WARNING: GLDAS MISSING ${rflux}, WILL NOT RUN." exit 2 fi - rm -f $fflux $gflux - touch $fflux $gflux + rm -f ${fflux} ${gflux} + touch ${fflux} ${gflux} fcsty=anl - if [ $f -ge 1 ]; then fcsty=fcst; fi + if [ ${f} -ge 1 ]; then fcsty=fcst; fi - if [ $machine = "WCOSS2" ]; then - echo "${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile - elif [ $machine = "HERA" ]; then - echo "$iter ${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f" >> ./cfile + if [ ${machine} = "WCOSS2" ]; then + echo "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + elif [ ${machine} = "HERA" ]; then + echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else - ${USHgldas}/gldas_process_data.sh $rflux $fcsty $fflux $gflux $f + ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f} fi iter=$((iter+1)) @@ -63,12 +63,12 @@ while [ $f -le $cycint ]; do done #------------------------------- - cdate=$($NDATE +$cycint $cdate) + cdate=$(${NDATE} +${cycint} ${cdate}) done #------------------------------- -if [ $machine = "HERA" ] || [ $machine = "WCOSS2" ]; then - $APRUN_GLDAS_DATA_PROC ./cfile +if [ ${machine} = "HERA" ] || [ ${machine} = "WCOSS2" ]; then + ${APRUN_GLDAS_DATA_PROC} ./cfile fi exit $? diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 0c4fa79c86..7d08ed20d9 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -11,34 +11,34 @@ date1=$1 date2=$2 grid=$3 -export yyyy1=$(echo $date1 | cut -c 1-4) -export mm1=$(echo $date1 | cut -c 5-6) -export dd1=$(echo $date1 | cut -c 7-8) -export hh1=$(echo $date1 | cut -c 9-10) -export yyyy2=$(echo $date2 | cut -c 1-4) -export mm2=$(echo $date2 | cut -c 5-6) -export dd2=$(echo $date2 | cut -c 7-8) -export hh2=$(echo $date2 | cut -c 9-10) -export grid=$grid +export yyyy1=$(echo ${date1} | cut -c 1-4) +export mm1=$(echo ${date1} | cut -c 5-6) +export dd1=$(echo ${date1} | cut -c 7-8) +export hh1=$(echo ${date1} | cut -c 9-10) +export yyyy2=$(echo ${date2} | cut -c 1-4) +export mm2=$(echo ${date2} | cut -c 5-6) +export dd2=$(echo ${date2} | cut -c 7-8) +export hh2=$(echo ${date2} | cut -c 9-10) +export grid=${grid} export PARM_LM=${PARMgldas} export LISCARD=lis.crd -rm -f $LISCARD -touch $LISCARD -cat $PARM_LM/lis.crd.T${grid}.tmp.1 >> $LISCARD -echo "LIS%t%SSS = 0 " >> $LISCARD -echo "LIS%t%SMN = 00 " >> $LISCARD -echo "LIS%t%SHR = $hh1 " >> $LISCARD -echo "LIS%t%SDA = $dd1 " >> $LISCARD -echo "LIS%t%SMO = $mm1 " >> $LISCARD -echo "LIS%t%SYR = $yyyy1" >> $LISCARD -echo "LIS%t%ENDCODE = 1 " >> $LISCARD -echo "LIS%t%ESS = 0 " >> $LISCARD -echo "LIS%t%EMN = 00 " >> $LISCARD -echo "LIS%t%EHR = $hh2 " >> $LISCARD -echo "LIS%t%EDA = $dd2 " >> $LISCARD -echo "LIS%t%EMO = $mm2 " >> $LISCARD -echo "LIS%t%EYR = $yyyy2" >> $LISCARD -cat $PARM_LM/lis.crd.T${grid}.tmp.2 >> $LISCARD +rm -f ${LISCARD} +touch ${LISCARD} +cat ${PARM_LM}/lis.crd.T${grid}.tmp.1 >> ${LISCARD} +echo "LIS%t%SSS = 0 " >> ${LISCARD} +echo "LIS%t%SMN = 00 " >> ${LISCARD} +echo "LIS%t%SHR = ${hh1} " >> ${LISCARD} +echo "LIS%t%SDA = ${dd1} " >> ${LISCARD} +echo "LIS%t%SMO = ${mm1} " >> ${LISCARD} +echo "LIS%t%SYR = ${yyyy1}" >> ${LISCARD} +echo "LIS%t%ENDCODE = 1 " >> ${LISCARD} +echo "LIS%t%ESS = 0 " >> ${LISCARD} +echo "LIS%t%EMN = 00 " >> ${LISCARD} +echo "LIS%t%EHR = ${hh2} " >> ${LISCARD} +echo "LIS%t%EDA = ${dd2} " >> ${LISCARD} +echo "LIS%t%EMO = ${mm2} " >> ${LISCARD} +echo "LIS%t%EYR = ${yyyy2}" >> ${LISCARD} +cat ${PARM_LM}/lis.crd.T${grid}.tmp.2 >> ${LISCARD} exit 0 diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh index bd9de60f81..fd1a9c7926 100755 --- a/ush/gldas_post.sh +++ b/ush/gldas_post.sh @@ -7,7 +7,7 @@ if [ $# -lt 2 ]; then err_exit 99 fi -cd $RUNDIR +cd ${RUNDIR} export pgm=gldas_post . prep_step @@ -16,10 +16,10 @@ gbin=$1 sfcanl=$2 rm -f fort.11 fort.12 fort.22 -cp $gbin fort.11 -cp $sfcanl fort.12 +cp ${gbin} fort.11 +cp ${sfcanl} fort.12 -${EXECgldas}/gldas_post >>$pgmout 2>errfile +${EXECgldas}/gldas_post >>${pgmout} 2>errfile export err=$?; err_chk cp fort.22 ./gldas.nemsio diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index 2f8a663983..a53a8b9949 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -8,24 +8,24 @@ fflux=$3 gflux=$4 f=$5 -$WGRIB2 $rflux | grep "TMP:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "SPFH:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "UGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "VGRD:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "HGT:1 hybrid" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "PRES:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "PRATE:surface" | grep ave | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "VEG:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "SFCR:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "SFEXC:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "TMP:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "WEASD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "SNOD:surface" | grep $fcsty | $WGRIB2 -i $rflux -append -grib $fflux +${WGRIB2} ${rflux} | grep "TMP:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "SPFH:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "UGRD:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "VGRD:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "HGT:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "PRES:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "PRATE:surface" | grep ave | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "VEG:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "SFCR:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "SFEXC:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "TMP:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "WEASD:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "SNOD:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -$WGRIB2 $rflux | grep "DSWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "DLWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux -$WGRIB2 $rflux | grep "USWRF:surface:$f hour fcst" | $WGRIB2 -i $rflux -append -grib $fflux +${WGRIB2} ${rflux} | grep "DSWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "DLWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} ${rflux} | grep "USWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -$CNVGRIB -g21 $fflux $gflux +${CNVGRIB} -g21 ${fflux} ${gflux} exit $? From dd6651fe0dca7f11401c5a8a5c83e853b2c271f3 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 12:22:37 -0500 Subject: [PATCH 14/36] Address SC2086 shellcheck warnings in GLDAS ush scripts Refs #1014 --- ush/gldas_forcing.sh | 60 +++++++++++++++++++-------------------- ush/gldas_get_data.sh | 32 ++++++++++----------- ush/gldas_liscrd.sh | 22 +++++++------- ush/gldas_process_data.sh | 34 +++++++++++----------- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index 784a9112b6..fb53dbb584 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -21,51 +21,51 @@ export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} #------------------------------- #--- extract variables of each timestep and create forcing files sdate=${bdate} -edate=$(sh ${FINDDATE} ${edate} d-1) -while [ ${sdate} -lt ${edate} ]; do +edate=$(sh "${FINDDATE}" "${edate}" d-1) +while [ "${sdate}" -lt "${edate}" ]; do #------------------------------- -sdat0=$(sh ${FINDDATE} ${sdate} d-1) -[[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p ${xpath}/cpc.${sdate} -[[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p ${xpath}/cpc.${sdat0} +sdat0=$(sh "${FINDDATE}" "${sdate}" d-1) +[[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p "${xpath}/cpc.${sdate}" +[[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p "${xpath}/cpc.${sdat0}" -cd ${xpath} +cd "${xpath}" rm -f fort.* grib.* COMPONENT=${COMPONENT:-"atmos"} pathp1=${CPCGAUGE}/gdas.${sdate}/00/${COMPONENT} pathp2=${DCOMIN}/${sdate}/wgrbbul/cpc_rcdas -yyyy=$(echo ${sdate} |cut -c 1-4) +yyyy=$(echo "${sdate}" |cut -c 1-4) cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" -if [ ${RUN_ENVIR} = "emc" ] && [ ${sdate} -gt ${bdate} ]; then +if [ "${RUN_ENVIR}" = "emc" ] && [ "${sdate}" -gt "${bdate}" ]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" fi cpc=${pathp1}/${cpc_precip} -if [ ! -s ${cpc} ]; then cpc=${pathp2}/${cpc_precip} ; fi -if [ ${RUN_ENVIR} = "nco" ]; then cpc=${pathp2}/${cpc_precip} ; fi -if [ ! -s ${cpc} ]; then +if [ ! -s "${cpc}" ]; then cpc=${pathp2}/${cpc_precip} ; fi +if [ "${RUN_ENVIR}" = "nco" ]; then cpc=${pathp2}/${cpc_precip} ; fi +if [ ! -s "${cpc}" ]; then echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." exit 3 fi -cp ${cpc} ${xpath}/cpc.${sdate}/. +cp "${cpc}" "${xpath}/cpc.${sdate}/." sflux=${fpath}/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 prate=gdas.${sdat0}12 -${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} +${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" sflux=${fpath}/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 prate=gdas.${sdat0}18 -${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} +${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" sflux=${fpath}/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 prate=gdas.${sdate}00 -${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} +${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 prate=gdas.${sdate}06 -${WGRIB} -s ${sflux} | grep "PRATE:sfc" | ${WGRIB} -i ${sflux} -grib -o ${prate} +${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" -if [ ${USE_CFP} = "YES" ] ; then +if [ "${USE_CFP}" = "YES" ] ; then rm -f ./cfile touch ./cfile echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile @@ -74,16 +74,16 @@ if [ ${USE_CFP} = "YES" ] ; then echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile ${APRUN_GLDAS_DATA_PROC} ./cfile else - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"12 grib.12 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"18 grib.18 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"00 grib.00 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"06 grib.06 fi rm -f fort.10 touch fort.10 -echo ${sdat0} >> fort.10 -echo ${sdate} >> fort.10 +echo "${sdat0}" >> fort.10 +echo "${sdate}" >> fort.10 export pgm=gldas_forcing . prep_step @@ -93,22 +93,22 @@ ${WGRIB} -d -bin grib.18 -o fort.12 ${WGRIB} -d -bin grib.00 -o fort.13 ${WGRIB} -d -bin grib.06 -o fort.14 -ln -fs ${xpath}/cpc.${sdate}/${cpc_precip} fort.15 +ln -fs "${xpath}/cpc.${sdate}/${cpc_precip}" fort.15 -${EXECgldas}/gldas_forcing 1>&1 2>&2 +"${EXECgldas}/gldas_forcing" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 3 -cp fort.21 ${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}12 -cp fort.22 ${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}18 -cp fort.23 ${xpath}/cpc.${sdate}/precip.gldas.${sdate}00 -cp fort.24 ${xpath}/cpc.${sdate}/precip.gldas.${sdate}06 +cp fort.21 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}12" +cp fort.22 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}18" +cp fort.23 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}00" +cp fort.24 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}06" rm -f fort.* grib.* #------------------------------- -sdate=$(sh ${FINDDATE} ${sdate} d+1) +sdate=$(sh "${FINDDATE}" "${sdate}" d+1) done #------------------------------- diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index fafa8cce8e..f6fc13d181 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -8,7 +8,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 -if [ ${machine} = "HERA" ] || [ ${machine} = "WCOSS2" ]; then +if [ "${machine}" = "HERA" ] || [ "${machine}" = "WCOSS2" ]; then touch ./cfile fi @@ -23,39 +23,39 @@ cycint=${assim_freq:-6} # get gdas flux files to force gldas. # CPC precipitation is from 12z to 12z. One more day of gdas data is # needed to disaggregate daily CPC precipitation values to hourly values -cdate=$(${NDATE} -12 ${bdate}) +cdate=$(${NDATE} -12 "${bdate}") iter=0 #------------------------------- -while [ ${cdate} -lt ${edate} ]; do +while [ "${cdate}" -lt "${edate}" ]; do #------------------------------- - ymd=$(echo ${cdate} |cut -c 1-8) - cyc=$(echo ${cdate} |cut -c 9-10) - [[ ! -d ${fpath}/gdas.${ymd} ]] && mkdir -p ${fpath}/gdas.${ymd} - [[ ! -d ${gpath}/gdas.${ymd} ]] && mkdir -p ${gpath}/gdas.${ymd} + ymd=$(echo "${cdate}" |cut -c 1-8) + cyc=$(echo "${cdate}" |cut -c 9-10) + [[ ! -d ${fpath}/gdas.${ymd} ]] && mkdir -p "${fpath}/gdas.${ymd}" + [[ ! -d ${gpath}/gdas.${ymd} ]] && mkdir -p "${gpath}/gdas.${ymd}" f=1 -while [ ${f} -le ${cycint} ]; do +while [ ${f} -le "${cycint}" ]; do rflux=${COMINgdas}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} - if [ ! -s ${rflux} ];then + if [ ! -s "${rflux}" ];then echo "WARNING: GLDAS MISSING ${rflux}, WILL NOT RUN." exit 2 fi - rm -f ${fflux} ${gflux} - touch ${fflux} ${gflux} + rm -f "${fflux}" "${gflux}" + touch "${fflux}" "${gflux}" fcsty=anl if [ ${f} -ge 1 ]; then fcsty=fcst; fi - if [ ${machine} = "WCOSS2" ]; then + if [ "${machine}" = "WCOSS2" ]; then echo "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile - elif [ ${machine} = "HERA" ]; then + elif [ "${machine}" = "HERA" ]; then echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else - ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f} + "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" fi iter=$((iter+1)) @@ -63,11 +63,11 @@ while [ ${f} -le ${cycint} ]; do done #------------------------------- - cdate=$(${NDATE} +${cycint} ${cdate}) + cdate=$(${NDATE} +"${cycint}" "${cdate}") done #------------------------------- -if [ ${machine} = "HERA" ] || [ ${machine} = "WCOSS2" ]; then +if [ "${machine}" = "HERA" ] || [ "${machine}" = "WCOSS2" ]; then ${APRUN_GLDAS_DATA_PROC} ./cfile fi diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 7d08ed20d9..9a180ba132 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -3,7 +3,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" if [ $# -lt 3 ]; then - echo usage $0 yyyymmddhh1 yyyymmddhh2 126/382/574/1534 + echo usage "$0" yyyymmddhh1 yyyymmddhh2 126/382/574/1534 exit $? fi @@ -11,21 +11,21 @@ date1=$1 date2=$2 grid=$3 -export yyyy1=$(echo ${date1} | cut -c 1-4) -export mm1=$(echo ${date1} | cut -c 5-6) -export dd1=$(echo ${date1} | cut -c 7-8) -export hh1=$(echo ${date1} | cut -c 9-10) -export yyyy2=$(echo ${date2} | cut -c 1-4) -export mm2=$(echo ${date2} | cut -c 5-6) -export dd2=$(echo ${date2} | cut -c 7-8) -export hh2=$(echo ${date2} | cut -c 9-10) +export yyyy1=$(echo "${date1}" | cut -c 1-4) +export mm1=$(echo "${date1}" | cut -c 5-6) +export dd1=$(echo "${date1}" | cut -c 7-8) +export hh1=$(echo "${date1}" | cut -c 9-10) +export yyyy2=$(echo "${date2}" | cut -c 1-4) +export mm2=$(echo "${date2}" | cut -c 5-6) +export dd2=$(echo "${date2}" | cut -c 7-8) +export hh2=$(echo "${date2}" | cut -c 9-10) export grid=${grid} export PARM_LM=${PARMgldas} export LISCARD=lis.crd rm -f ${LISCARD} touch ${LISCARD} -cat ${PARM_LM}/lis.crd.T${grid}.tmp.1 >> ${LISCARD} +cat "${PARM_LM}/lis.crd.T${grid}.tmp.1" >> ${LISCARD} echo "LIS%t%SSS = 0 " >> ${LISCARD} echo "LIS%t%SMN = 00 " >> ${LISCARD} echo "LIS%t%SHR = ${hh1} " >> ${LISCARD} @@ -39,6 +39,6 @@ echo "LIS%t%EHR = ${hh2} " >> ${LISCARD} echo "LIS%t%EDA = ${dd2} " >> ${LISCARD} echo "LIS%t%EMO = ${mm2} " >> ${LISCARD} echo "LIS%t%EYR = ${yyyy2}" >> ${LISCARD} -cat ${PARM_LM}/lis.crd.T${grid}.tmp.2 >> ${LISCARD} +cat "${PARM_LM}/lis.crd.T${grid}.tmp.2" >> ${LISCARD} exit 0 diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index a53a8b9949..920db9831b 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -8,24 +8,24 @@ fflux=$3 gflux=$4 f=$5 -${WGRIB2} ${rflux} | grep "TMP:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "SPFH:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "UGRD:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "VGRD:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "HGT:1 hybrid" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "PRES:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "PRATE:surface" | grep ave | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "VEG:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "SFCR:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "SFEXC:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "TMP:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "WEASD:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "SNOD:surface" | grep ${fcsty} | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} "${rflux}" | grep "TMP:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "SPFH:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "UGRD:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "VGRD:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "HGT:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "PRES:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "PRATE:surface" | grep ave | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "VEG:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "SFCR:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "SFEXC:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "TMP:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "WEASD:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "SNOD:surface" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" -${WGRIB2} ${rflux} | grep "DSWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "DLWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} -${WGRIB2} ${rflux} | grep "USWRF:surface:${f} hour fcst" | ${WGRIB2} -i ${rflux} -append -grib ${fflux} +${WGRIB2} "${rflux}" | grep "DSWRF:surface:${f} hour fcst" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "DLWRF:surface:${f} hour fcst" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" +${WGRIB2} "${rflux}" | grep "USWRF:surface:${f} hour fcst" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" -${CNVGRIB} -g21 ${fflux} ${gflux} +${CNVGRIB} -g21 "${fflux}" "${gflux}" exit $? From cae328be26becaae94a4a9f4ae8a35d9367aece2 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 14:03:39 -0500 Subject: [PATCH 15/36] Correct env sourcing in jobs/JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 474175c2cb..6e2f6e0eba 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -33,7 +33,7 @@ fi # Source machine runtime environment ########################################## # shellcheck source=env/WCOSS2.env -. "${HOMEgfs}/env/${machine:?}.env gldas" +. "${HOMEgfs}/env/${machine:?}.env" gldas status=$? [[ ${status} -ne 0 ]] && exit "${status}" From 341b96574ba0b99a43a6b920fc407fd24212886e Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 14:07:30 -0500 Subject: [PATCH 16/36] Address SC2086 warnings in scripts/exgdas_atmos_gldas.sh Refs #1014 --- scripts/exgdas_atmos_gldas.sh | 114 +++++++++++++++++----------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index 2fe8131ff6..2a441aacf3 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -34,76 +34,76 @@ export USE_CFP=${USE_CFP:-"NO"} export COMPONENT=${COMPONENT:-atmos} export assim_freq=${assim_freq:-6} export gldas_spinup_hours=${gldas_spinup_hours:-72} -export gldas_cdate=${CDATE} -export gldas_eymd=$(echo ${gldas_cdate} |cut -c 1-8) -export gldas_ecyc=$(echo ${gldas_cdate} |cut -c 9-10) -export gldas_sdate=$(${NDATE} -${gldas_spinup_hours} ${CDATE}) -export gldas_symd=$(echo ${gldas_sdate} |cut -c 1-8) -export gldas_scyc=$(echo ${gldas_sdate} |cut -c 9-10) +export gldas_cdate=${CDATE:?} +export gldas_eymd=$(echo "${gldas_cdate}" |cut -c 1-8) +export gldas_ecyc=$(echo "${gldas_cdate}" |cut -c 9-10) +export gldas_sdate=$(${NDATE} -"${gldas_spinup_hours}" "${CDATE}") +export gldas_symd=$(echo "${gldas_sdate}" |cut -c 1-8) +export gldas_scyc=$(echo "${gldas_sdate}" |cut -c 9-10) export iau_cdate=${CDATE} if [ "${DOIAU}" = "YES" ]; then IAU_OFFSET=${IAU_OFFSET:-0} IAUHALH=$((IAU_OFFSET/2)) - export iau_cdate=$(${NDATE} -${IAUHALH} ${CDATE}) + export iau_cdate=$(${NDATE} -${IAUHALH} "${CDATE}") fi -export iau_eymd=$(echo ${iau_cdate} |cut -c 1-8) -export iau_ecyc=$(echo ${iau_cdate} |cut -c 9-10) +export iau_eymd=$(echo "${iau_cdate}" |cut -c 1-8) +export iau_ecyc=$(echo "${iau_cdate}" |cut -c 9-10) echo "GLDAS runs from ${gldas_sdate} to ${iau_cdate}" export CASE=${CASE:-C768} -export res=$(echo ${CASE} |cut -c2-5) -export JCAP=$((2*res-2)) +export res=$(echo "${CASE}" |cut -c2-5) +export JCAP=$((2*res-2)) export nlat=$((2*res)) export nlon=$((4*res)) export FIXgldas=${FIXgldas:-${HOMEgfs}/fix} export topodir=${topodir:-${HOMEgfs}/fix/fix_fv3_gmted2010/${CASE}/} -DATA=${DATA:-${pwd}/gldastmp$$} +DATA=${DATA:-${pwd}/gldastmp$$} mkdata=NO -if [ ! -d ${DATA} ]; then +if [ ! -d "${DATA}" ]; then mkdata=YES - mkdir -p ${DATA} + mkdir -p "${DATA}" fi -cd ${DATA} || exit 1 +cd "${DATA}" || exit 1 export RUNDIR=${DATA} ################################# GDAS=${RUNDIR}/force -mkdir -p ${GDAS} +mkdir -p "${GDAS}" input1=${COMINgdas}/gdas.${gldas_symd}/${gldas_scyc}/${COMPONENT}/RESTART input2=${COMINgdas}/gdas.${gldas_eymd}/${gldas_ecyc}/${COMPONENT}/RESTART -[[ -d ${RUNDIR} ]] && rm -fr ${RUNDIR}/FIX -[[ -f ${RUNDIR}/LIS ]] && rm -fr ${RUNDIR}/LIS -[[ -d ${RUNDIR}/input ]] && rm -fr ${RUNDIR}/input -mkdir -p ${RUNDIR}/input -ln -fs ${GDAS} ${RUNDIR}/input/GDAS -ln -fs ${FIXgldas}/FIX_T${JCAP} ${RUNDIR}/FIX -ln -fs ${EXECgldas}/gldas_model ${RUNDIR}/LIS +[[ -d ${RUNDIR} ]] && rm -fr "${RUNDIR}/FIX" +[[ -f ${RUNDIR}/LIS ]] && rm -fr "${RUNDIR}/LIS" +[[ -d ${RUNDIR}/input ]] && rm -fr "${RUNDIR}/input" +mkdir -p "${RUNDIR}/input" +ln -fs "${GDAS}" "${RUNDIR}/input/GDAS" +ln -fs "${FIXgldas}/FIX_T${JCAP}" "${RUNDIR}/FIX" +ln -fs "${EXECgldas}/gldas_model" "${RUNDIR}/LIS" #--------------------------------------------------------------- ### 1) Get gdas 6-tile netcdf restart file and gdas forcing data #--------------------------------------------------------------- -${USHgldas}/gldas_get_data.sh ${gldas_sdate} ${gldas_cdate} +"${USHgldas}/gldas_get_data.sh" "${gldas_sdate}" "${gldas_cdate}" export err=$? ${ERRSCRIPT} || exit 2 #--------------------------------------------------------------- -### 2) Get CPC daily precip and temporally disaggreated +### 2) Get CPC daily precip and temporally disaggreated #--------------------------------------------------------------- -${USHgldas}/gldas_forcing.sh ${gldas_symd} ${gldas_eymd} +"${USHgldas}/gldas_forcing.sh" "${gldas_symd}" "${gldas_eymd}" export err=$? ${ERRSCRIPT} || exit 3 # spatially disaggregated -if [ ${JCAP} -eq 1534 ]; then +if [ ${JCAP} -eq 1534 ]; then gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' elif [ ${JCAP} -eq 766 ]; then gds='255 4 1536 768 89821 0 128 -89821 -234 234 384 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' @@ -118,44 +118,44 @@ else fi echo ${JCAP} -echo ${gds} -ymdpre=$(sh ${FINDDATE} ${gldas_symd} d-1) -ymdend=$(sh ${FINDDATE} ${gldas_eymd} d-2) +echo "${gds}" +ymdpre=$(sh "${FINDDATE}" "${gldas_symd}" d-1) +ymdend=$(sh "${FINDDATE}" "${gldas_eymd}" d-2) ymd=${ymdpre} -if [ ${USE_CFP} = "YES" ] ; then +if [ "${USE_CFP}" = "YES" ] ; then rm -f ./cfile touch ./cfile fi -while [ ${ymd} -le ${ymdend} ]; do - if [ ${ymd} -ne ${ymdpre} ]; then - if [ ${USE_CFP} = "YES" ] ; then +while [ "${ymd}" -le "${ymdend}" ]; do + if [ "${ymd}" -ne "${ymdpre}" ]; then + if [ "${USE_CFP}" = "YES" ] ; then echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00" >> ./cfile echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06" >> ./cfile else - ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00 - ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06 + ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00" "${RUNDIR}/cmap.gdas.${ymd}00" + ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06" "${RUNDIR}/cmap.gdas.${ymd}06" fi fi - if [ ${ymd} -ne ${ymdend} ]; then - if [ ${USE_CFP} = "YES" ] ; then + if [ "${ymd}" -ne "${ymdend}" ]; then + if [ "${USE_CFP}" = "YES" ] ; then echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12" >> ./cfile echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18" >> ./cfile else - ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12 - ${COPYGB} -i3 -g"${gds}" -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18 + ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12" "${RUNDIR}/cmap.gdas.${ymd}12" + ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18" "${RUNDIR}/cmap.gdas.${ymd}18" fi fi - ymd=$(sh ${FINDDATE} ${ymd} d+1) + ymd=$(sh "${FINDDATE}" "${ymd}" d+1) done -if [ ${USE_CFP} = "YES" ] ; then +if [ "${USE_CFP}" = "YES" ] ; then ${APRUN_GLDAS_DATA_PROC} ./cfile fi # create configure file -${USHgldas}/gldas_liscrd.sh ${gldas_sdate} ${iau_cdate} ${JCAP} +"${USHgldas}/gldas_liscrd.sh" "${gldas_sdate}" "${iau_cdate}" ${JCAP} export err=$? ${ERRSCRIPT} || exit 4 @@ -187,7 +187,7 @@ cp fort.141 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas . prep_step -${APRUN_GAUSSIAN} ${EXECgldas}/gdas2gldas 1>&1 2>&2 +${APRUN_GAUSSIAN} "${EXECgldas}/gdas2gldas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 5 @@ -199,11 +199,11 @@ ln -fs FIX/lmask_gfs_T${JCAP}.bfsa fort.11 ln -fs ${sfcanl} fort.12 export pgm=gldas_rst . prep_step -${EXECgldas}/gldas_rst 1>&1 2>&2 +"${EXECgldas}/gldas_rst" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 6 -mv ${sfcanl} ${sfcanl}.${gldas_symd} +mv ${sfcanl} "${sfcanl}.${gldas_symd}" #--------------------------------------------------------------- @@ -244,23 +244,23 @@ cp fort.241 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas . prep_step -${APRUN_GAUSSIAN} ${EXECgldas}/gdas2gldas 1>&1 2>&2 +${APRUN_GAUSSIAN} "${EXECgldas}/gdas2gldas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 8 # 5c) use gldas_post to replace soil moisture and temperature -yyyy=$(echo ${iau_eymd} | cut -c1-4) +yyyy=$(echo "${iau_eymd}" | cut -c1-4) gbin=${RUNDIR}/EXP901/NOAH/${yyyy}/${iau_eymd}/LIS.E901.${iau_eymd}${iau_ecyc}.NOAHgbin sfcanl=sfc.gaussian.nemsio rm -rf fort.11 fort.12 -ln -fs ${gbin} fort.11 +ln -fs "${gbin}" fort.11 ln -fs ${sfcanl} fort.12 export pgm=gldas_post . prep_step -${EXECgldas}/gldas_post 1>&1 2>&2 +"${EXECgldas}/gldas_post" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 9 @@ -279,7 +279,7 @@ EOF # copy/link gdas netcdf tiles k=1; while [ ${k} -le 6 ]; do - cp ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ./sfc_data.tile${k}.nc + cp "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" ./sfc_data.tile${k}.nc k=$((k+1)) done @@ -289,21 +289,21 @@ ln -fs FIX/stype_gfs_T${JCAP}.bfsa stype_gfs_T${JCAP}.bfsa export OMP_NUM_THREADS=1 export pgm=gldas2gdas . prep_step -${APRUN_GAUSSIAN} ${EXECgldas}/gldas2gdas 1>&1 2>&2 +${APRUN_GAUSSIAN} "${EXECgldas}/gldas2gdas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 10 # 5e) archive gldas results -if [ ${OFFLINE_GLDAS} = "YES" ]; then - ${USHgldas}/gldas_archive.sh ${gldas_symd} ${gldas_eymd} +if [ "${OFFLINE_GLDAS}" = "YES" ]; then + "${USHgldas}/gldas_archive.sh" "${gldas_symd}" "${gldas_eymd}" export err=$? ${ERRSCRIPT} || exit 11 else k=1; while [ ${k} -le 6 ]; do - mv ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas - cp sfc_data.tile${k}.nc ${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc + mv "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas" + cp "sfc_data.tile${k}.nc" "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" k=$((k+1)) done fi @@ -311,7 +311,7 @@ fi #------------------------------------------------------------------ # Clean up before leaving -if [ ${mkdata} = "YES" ]; then rm -rf ${DATA}; fi +if [ ${mkdata} = "YES" ]; then rm -rf "${DATA}"; fi exit ${err} From 5cc40f1c0957540373aeafe4e968c45f9755f5f8 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 14:08:55 -0500 Subject: [PATCH 17/36] Address SC2086 warnings in ush/gldas_get_data.sh Refs #1014 --- ush/gldas_get_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index f6fc13d181..5b66f186b7 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -55,7 +55,7 @@ while [ ${f} -le "${cycint}" ]; do elif [ "${machine}" = "HERA" ]; then echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else - "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" + "${USHgldas}/gldas_process_data.sh" ${rflux} ${fcsty} ${fflux} ${gflux} ${f} fi iter=$((iter+1)) From 1cf810e395327f3d21df6aa38f7f8071f56631be Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 14:42:33 -0500 Subject: [PATCH 18/36] Address a number of linter warnings in GLDAS scripts Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 14 +++--- scripts/exgdas_atmos_gldas.sh | 90 ++++++++++++++++++++--------------- ush/gldas_forcing.sh | 16 +++---- ush/gldas_get_data.sh | 18 +++---- ush/gldas_liscrd.sh | 36 +++++++------- 5 files changed, 93 insertions(+), 81 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 6e2f6e0eba..e5c44b9c69 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -16,17 +16,17 @@ for config in ${configs}; do done -if [ "${cyc:?}" -ne "${gldas_cyc:?}" ]; then +if [[ "${cyc:?}" -ne "${gldas_cyc:?}" ]]; then echo "GLDAS only runs for ${gldas_cyc} cycle; Skip GLDAS step for cycle ${cyc}" - exit 0 + exit 0 fi gldas_spinup_hours=${gldas_spinup_hours-:72} xtime=$((gldas_spinup_hours+12)) -if [ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]; then +if [[ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]]; then echo "GLDAS needs fluxes as forcing from cycles in previous ${xtime} hours" - echo "starting from ${SDATE}. This gldas cycle is skipped" - exit 0 + echo "starting from ${SDATE}. This gldas cycle is skipped" + exit 0 fi ########################################## @@ -85,7 +85,7 @@ export EXECgldas=${EXECgldas:-${HOMEgldas}/exec} export USHgldas=${USHgldas:-${HOMEgldas}/ush} export PARA_CONFIG=${HOMEgfs}/parm/config/config.gldas -if [ "${RUN_ENVIR:?}" = "nco" ]; then +if [[ "${RUN_ENVIR:?}" = "nco" ]]; then export COMIN=${COMIN:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} else @@ -115,7 +115,7 @@ status=$? ############################################## # Final processing ############################################## -if [ -e "${pgmout}" ] ; then +if [[ -e "${pgmout}" ]] ; then cat "${pgmout}" fi diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index 2a441aacf3..fa3f0d5626 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -24,7 +24,7 @@ export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} export CPCGAUGE=${CPCGAUGE:-/lfs/h2/emc/global/noscrub/emc.global/dump} export COMINgdas=${COMINgdas:-${ROTDIR}} export OFFLINE_GLDAS=${OFFLINE_GLDAS:-"NO"} -export ERRSCRIPT=${ERRSCRIPT:-"eval [[ $err = 0 ]]"} +export ERRSCRIPT=${ERRSCRIPT:-"eval [[ ${err} = 0 ]]"} ################################# @@ -42,10 +42,10 @@ export gldas_symd=$(echo "${gldas_sdate}" |cut -c 1-8) export gldas_scyc=$(echo "${gldas_sdate}" |cut -c 9-10) export iau_cdate=${CDATE} -if [ "${DOIAU}" = "YES" ]; then +if [[ "${DOIAU:?}" = "YES" ]]; then IAU_OFFSET=${IAU_OFFSET:-0} IAUHALH=$((IAU_OFFSET/2)) - export iau_cdate=$(${NDATE} -${IAUHALH} "${CDATE}") + export iau_cdate=$(${NDATE} -"${IAUHALH}" "${CDATE}") fi export iau_eymd=$(echo "${iau_cdate}" |cut -c 1-8) export iau_ecyc=$(echo "${iau_cdate}" |cut -c 9-10) @@ -62,7 +62,7 @@ export topodir=${topodir:-${HOMEgfs}/fix/fix_fv3_gmted2010/${CASE}/} DATA=${DATA:-${pwd}/gldastmp$$} mkdata=NO -if [ ! -d "${DATA}" ]; then +if [[ ! -d "${DATA}" ]]; then mkdata=YES mkdir -p "${DATA}" fi @@ -82,7 +82,7 @@ input2=${COMINgdas}/gdas.${gldas_eymd}/${gldas_ecyc}/${COMPONENT}/RESTART mkdir -p "${RUNDIR}/input" ln -fs "${GDAS}" "${RUNDIR}/input/GDAS" ln -fs "${FIXgldas}/FIX_T${JCAP}" "${RUNDIR}/FIX" -ln -fs "${EXECgldas}/gldas_model" "${RUNDIR}/LIS" +ln -fs "${EXECgldas:?}/gldas_model" "${RUNDIR}/LIS" #--------------------------------------------------------------- @@ -103,13 +103,13 @@ ${ERRSCRIPT} || exit 3 # spatially disaggregated -if [ ${JCAP} -eq 1534 ]; then +if [[ "${JCAP}" -eq 1534 ]]; then gds='255 4 3072 1536 89909 0 128 -89909 -117 117 768 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ ${JCAP} -eq 766 ]; then +elif [[ "${JCAP}" -eq 766 ]]; then gds='255 4 1536 768 89821 0 128 -89821 -234 234 384 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ ${JCAP} -eq 382 ]; then +elif [[ "${JCAP}" -eq 382 ]]; then gds='255 4 768 384 89641 0 128 -89641 -469 469 192 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' -elif [ ${JCAP} -eq 190 ]; then +elif [[ "${JCAP}" -eq 190 ]]; then gds='255 4 384 192 89284 0 128 -89284 -938 938 96 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0' else echo "JCAP=${JCAP} not supported, exit" @@ -117,31 +117,31 @@ else ${ERRSCRIPT} || exit 4 fi -echo ${JCAP} +echo "${JCAP}" echo "${gds}" ymdpre=$(sh "${FINDDATE}" "${gldas_symd}" d-1) ymdend=$(sh "${FINDDATE}" "${gldas_eymd}" d-2) ymd=${ymdpre} -if [ "${USE_CFP}" = "YES" ] ; then +if [[ "${USE_CFP}" = "YES" ]] ; then rm -f ./cfile touch ./cfile fi -while [ "${ymd}" -le "${ymdend}" ]; do - if [ "${ymd}" -ne "${ymdpre}" ]; then - if [ "${USE_CFP}" = "YES" ] ; then - echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00" >> ./cfile - echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06" >> ./cfile +while [[ "${ymd}" -le "${ymdend}" ]]; do + if [[ "${ymd}" -ne "${ymdpre}" ]]; then + if [[ "${USE_CFP}" = "YES" ]] ; then + echo "${COPYGB} -i3 '-g${gds}' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00 ${RUNDIR}/cmap.gdas.${ymd}00" >> ./cfile + echo "${COPYGB} -i3 '-g${gds}' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06 ${RUNDIR}/cmap.gdas.${ymd}06" >> ./cfile else ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}00" "${RUNDIR}/cmap.gdas.${ymd}00" ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}06" "${RUNDIR}/cmap.gdas.${ymd}06" fi fi - if [ "${ymd}" -ne "${ymdend}" ]; then - if [ "${USE_CFP}" = "YES" ] ; then - echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12" >> ./cfile - echo "${COPYGB} -i3 '-g"${gds}"' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18" >> ./cfile + if [[ "${ymd}" -ne "${ymdend}" ]]; then + if [[ "${USE_CFP}" = "YES" ]] ; then + echo "${COPYGB} -i3 '-g${gds}' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12 ${RUNDIR}/cmap.gdas.${ymd}12" >> ./cfile + echo "${COPYGB} -i3 '-g${gds}' -x ${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18 ${RUNDIR}/cmap.gdas.${ymd}18" >> ./cfile else ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}12" "${RUNDIR}/cmap.gdas.${ymd}12" ${COPYGB} -i3 -g"${gds}" -x "${GDAS}/cpc.${ymd}/precip.gldas.${ymd}18" "${RUNDIR}/cmap.gdas.${ymd}18" @@ -150,12 +150,12 @@ while [ "${ymd}" -le "${ymdend}" ]; do ymd=$(sh "${FINDDATE}" "${ymd}" d+1) done -if [ "${USE_CFP}" = "YES" ] ; then - ${APRUN_GLDAS_DATA_PROC} ./cfile +if [[ "${USE_CFP}" = "YES" ]] ; then + ${APRUN_GLDAS_DATA_PROC:?} ./cfile fi # create configure file -"${USHgldas}/gldas_liscrd.sh" "${gldas_sdate}" "${iau_cdate}" ${JCAP} +"${USHgldas}/gldas_liscrd.sh" "${gldas_sdate}" "${iau_cdate}" "${JCAP}" export err=$? ${ERRSCRIPT} || exit 4 @@ -186,32 +186,38 @@ cp fort.141 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas +# shellcheck disable=SC1091 . prep_step -${APRUN_GAUSSIAN} "${EXECgldas}/gdas2gldas" 1>&1 2>&2 +# shellcheck disable= +${APRUN_GAUSSIAN:?} "${EXECgldas}/gdas2gldas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 5 -# 3c)gldas_rst to generate noah.rst +# 3c)gldas_rst to generate noah.rst sfcanl=sfc.gaussian.nemsio -ln -fs FIX/lmask_gfs_T${JCAP}.bfsa fort.11 -ln -fs ${sfcanl} fort.12 +ln -fs "FIX/lmask_gfs_T${JCAP}.bfsa" fort.11 +ln -fs "${sfcanl}" fort.12 export pgm=gldas_rst +# shellcheck disable=SC1091 . prep_step +# shellcheck disable= "${EXECgldas}/gldas_rst" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 6 -mv ${sfcanl} "${sfcanl}.${gldas_symd}" +mv "${sfcanl}" "${sfcanl}.${gldas_symd}" #--------------------------------------------------------------- ### 4) run noah/noahmp model #--------------------------------------------------------------- export pgm=LIS +# shellcheck disable=SC1091 . prep_step -${APRUN_GLDAS} ./LIS 1>&1 2>&2 +# shellcheck disable= +${APRUN_GLDAS:?} ./LIS 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 7 @@ -234,7 +240,7 @@ cat >> fort.241 << EOF orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" i_target=${nlon} j_target=${nlat} - model="${model}" + model="${model:?}" / EOF cp fort.241 fort.41 @@ -243,7 +249,9 @@ cp fort.241 fort.41 export OMP_NUM_THREADS=1 export pgm=gdas2gldas +# shellcheck disable=SC1091 . prep_step +# shellcheck disable= ${APRUN_GAUSSIAN} "${EXECgldas}/gdas2gldas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 8 @@ -256,16 +264,18 @@ gbin=${RUNDIR}/EXP901/NOAH/${yyyy}/${iau_eymd}/LIS.E901.${iau_eymd}${iau_ecyc}.N sfcanl=sfc.gaussian.nemsio rm -rf fort.11 fort.12 ln -fs "${gbin}" fort.11 -ln -fs ${sfcanl} fort.12 +ln -fs "${sfcanl}" fort.12 export pgm=gldas_post +# shellcheck disable=SC1091 . prep_step +# shellcheck disable= "${EXECgldas}/gldas_post" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 9 cp fort.22 ./gldas.nemsio -mv fort.22 ${sfcanl}.gldas +mv fort.22 "${sfcanl}.gldas" # 5d) use gldas2gdas to create 6-tile restart tiles @@ -278,17 +288,19 @@ cat >> fort.42 << EOF EOF # copy/link gdas netcdf tiles -k=1; while [ ${k} -le 6 ]; do - cp "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" ./sfc_data.tile${k}.nc +k=1; while [[ "${k}" -le 6 ]]; do + cp "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" "./sfc_data.tile${k}.nc" k=$((k+1)) done # copy soil type -ln -fs FIX/stype_gfs_T${JCAP}.bfsa stype_gfs_T${JCAP}.bfsa +ln -fs "FIX/stype_gfs_T${JCAP}.bfsa" "stype_gfs_T${JCAP}.bfsa" export OMP_NUM_THREADS=1 export pgm=gldas2gdas +# shellcheck disable=SC1091 . prep_step +# shellcheck disable= ${APRUN_GAUSSIAN} "${EXECgldas}/gldas2gdas" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 10 @@ -296,12 +308,12 @@ ${ERRSCRIPT} || exit 10 # 5e) archive gldas results -if [ "${OFFLINE_GLDAS}" = "YES" ]; then +if [[ "${OFFLINE_GLDAS}" = "YES" ]]; then "${USHgldas}/gldas_archive.sh" "${gldas_symd}" "${gldas_eymd}" export err=$? ${ERRSCRIPT} || exit 11 else - k=1; while [ ${k} -le 6 ]; do + k=1; while [[ "${k}" -le 6 ]]; do mv "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc_bfgldas" cp "sfc_data.tile${k}.nc" "${input2}/${iau_eymd}.${iau_ecyc}0000.sfcanl_data.tile${k}.nc" k=$((k+1)) @@ -311,7 +323,7 @@ fi #------------------------------------------------------------------ # Clean up before leaving -if [ ${mkdata} = "YES" ]; then rm -rf "${DATA}"; fi +if [[ "${mkdata}" = "YES" ]]; then rm -rf "${DATA}"; fi -exit ${err} +exit "${err}" diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index fb53dbb584..70a361d5fa 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -22,14 +22,14 @@ export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} #--- extract variables of each timestep and create forcing files sdate=${bdate} edate=$(sh "${FINDDATE}" "${edate}" d-1) -while [ "${sdate}" -lt "${edate}" ]; do +while [[ "${sdate}" -lt "${edate}" ]]; do #------------------------------- sdat0=$(sh "${FINDDATE}" "${sdate}" d-1) [[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p "${xpath}/cpc.${sdate}" [[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p "${xpath}/cpc.${sdat0}" -cd "${xpath}" +cd "${xpath}" || exit rm -f fort.* grib.* COMPONENT=${COMPONENT:-"atmos"} @@ -37,13 +37,13 @@ pathp1=${CPCGAUGE}/gdas.${sdate}/00/${COMPONENT} pathp2=${DCOMIN}/${sdate}/wgrbbul/cpc_rcdas yyyy=$(echo "${sdate}" |cut -c 1-4) cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" -if [ "${RUN_ENVIR}" = "emc" ] && [ "${sdate}" -gt "${bdate}" ]; then +if [[ "${RUN_ENVIR}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" fi cpc=${pathp1}/${cpc_precip} -if [ ! -s "${cpc}" ]; then cpc=${pathp2}/${cpc_precip} ; fi -if [ "${RUN_ENVIR}" = "nco" ]; then cpc=${pathp2}/${cpc_precip} ; fi -if [ ! -s "${cpc}" ]; then +if [[ ! -s "${cpc}" ]]; then cpc=${pathp2}/${cpc_precip} ; fi +if [[ "${RUN_ENVIR}" = "nco" ]]; then cpc=${pathp2}/${cpc_precip} ; fi +if [[ ! -s "${cpc}" ]]; then echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." exit 3 fi @@ -65,7 +65,7 @@ sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 prate=gdas.${sdate}06 ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" -if [ "${USE_CFP}" = "YES" ] ; then +if [[ "${USE_CFP}" = "YES" ]] ; then rm -f ./cfile touch ./cfile echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile @@ -112,4 +112,4 @@ sdate=$(sh "${FINDDATE}" "${sdate}" d+1) done #------------------------------- -exit ${err} +exit "${err}" diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 5b66f186b7..e10502bca6 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -8,7 +8,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 -if [ "${machine}" = "HERA" ] || [ "${machine}" = "WCOSS2" ]; then +if [[ "${machine}" = "HERA" ]] || [[ "${machine}" = "WCOSS2" ]]; then touch ./cfile fi @@ -28,7 +28,7 @@ cdate=$(${NDATE} -12 "${bdate}") iter=0 #------------------------------- -while [ "${cdate}" -lt "${edate}" ]; do +while [[ "${cdate}" -lt "${edate}" ]]; do #------------------------------- ymd=$(echo "${cdate}" |cut -c 1-8) cyc=$(echo "${cdate}" |cut -c 9-10) @@ -36,11 +36,11 @@ while [ "${cdate}" -lt "${edate}" ]; do [[ ! -d ${gpath}/gdas.${ymd} ]] && mkdir -p "${gpath}/gdas.${ymd}" f=1 -while [ ${f} -le "${cycint}" ]; do +while [[ "${f}" -le "${cycint}" ]]; do rflux=${COMINgdas}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} - if [ ! -s "${rflux}" ];then + if [[ ! -s "${rflux}" ]];then echo "WARNING: GLDAS MISSING ${rflux}, WILL NOT RUN." exit 2 fi @@ -48,14 +48,14 @@ while [ ${f} -le "${cycint}" ]; do touch "${fflux}" "${gflux}" fcsty=anl - if [ ${f} -ge 1 ]; then fcsty=fcst; fi + if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi - if [ "${machine}" = "WCOSS2" ]; then + if [[ "${machine}" = "WCOSS2" ]]; then echo "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile - elif [ "${machine}" = "HERA" ]; then + elif [[ "${machine}" = "HERA" ]]; then echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else - "${USHgldas}/gldas_process_data.sh" ${rflux} ${fcsty} ${fflux} ${gflux} ${f} + "${USHgldas}/gldas_process_data.sh" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" fi iter=$((iter+1)) @@ -67,7 +67,7 @@ done done #------------------------------- -if [ "${machine}" = "HERA" ] || [ "${machine}" = "WCOSS2" ]; then +if [[ "${machine}" = "HERA" ]] || [[ "${machine}" = "WCOSS2" ]]; then ${APRUN_GLDAS_DATA_PROC} ./cfile fi diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 9a180ba132..9733dba9f9 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -2,7 +2,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" -if [ $# -lt 3 ]; then +if [[ $# -lt 3 ]]; then echo usage "$0" yyyymmddhh1 yyyymmddhh2 126/382/574/1534 exit $? fi @@ -23,22 +23,22 @@ export grid=${grid} export PARM_LM=${PARMgldas} export LISCARD=lis.crd -rm -f ${LISCARD} -touch ${LISCARD} -cat "${PARM_LM}/lis.crd.T${grid}.tmp.1" >> ${LISCARD} -echo "LIS%t%SSS = 0 " >> ${LISCARD} -echo "LIS%t%SMN = 00 " >> ${LISCARD} -echo "LIS%t%SHR = ${hh1} " >> ${LISCARD} -echo "LIS%t%SDA = ${dd1} " >> ${LISCARD} -echo "LIS%t%SMO = ${mm1} " >> ${LISCARD} -echo "LIS%t%SYR = ${yyyy1}" >> ${LISCARD} -echo "LIS%t%ENDCODE = 1 " >> ${LISCARD} -echo "LIS%t%ESS = 0 " >> ${LISCARD} -echo "LIS%t%EMN = 00 " >> ${LISCARD} -echo "LIS%t%EHR = ${hh2} " >> ${LISCARD} -echo "LIS%t%EDA = ${dd2} " >> ${LISCARD} -echo "LIS%t%EMO = ${mm2} " >> ${LISCARD} -echo "LIS%t%EYR = ${yyyy2}" >> ${LISCARD} -cat "${PARM_LM}/lis.crd.T${grid}.tmp.2" >> ${LISCARD} +rm -f "${LISCARD}" +touch "${LISCARD}" +cat "${PARM_LM}/lis.crd.T${grid}.tmp.1" >> "${LISCARD}" +echo "LIS%t%SSS = 0 " >> "${LISCARD}" +echo "LIS%t%SMN = 00 " >> "${LISCARD}" +echo "LIS%t%SHR = ${hh1} " >> "${LISCARD}" +echo "LIS%t%SDA = ${dd1} " >> "${LISCARD}" +echo "LIS%t%SMO = ${mm1} " >> "${LISCARD}" +echo "LIS%t%SYR = ${yyyy1}" >> "${LISCARD}" +echo "LIS%t%ENDCODE = 1 " >> "${LISCARD}" +echo "LIS%t%ESS = 0 " >> "${LISCARD}" +echo "LIS%t%EMN = 00 " >> "${LISCARD}" +echo "LIS%t%EHR = ${hh2} " >> "${LISCARD}" +echo "LIS%t%EDA = ${dd2} " >> "${LISCARD}" +echo "LIS%t%EMO = ${mm2} " >> "${LISCARD}" +echo "LIS%t%EYR = ${yyyy2}" >> "${LISCARD}" +cat "${PARM_LM}/lis.crd.T${grid}.tmp.2" >> "${LISCARD}" exit 0 From 9f94a975d95723b470ee801b9b3546401ca79001 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 14:58:18 -0500 Subject: [PATCH 19/36] Address some linter warnings in GLDAS scripts - Mostly address "referenced but not assigned" warnings Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 2 +- scripts/exgdas_atmos_gldas.sh | 2 +- ush/gldas_forcing.sh | 19 +++++++++++-------- ush/gldas_get_data.sh | 10 +++++----- ush/gldas_liscrd.sh | 2 +- ush/gldas_process_data.sh | 3 +++ 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index e5c44b9c69..97c84c12e5 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -9,7 +9,7 @@ export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config} configs="base gldas" config_path=${EXPDIR:-${NWROOT}/gfs.${gfs_ver}/parm/config} for config in ${configs}; do - # shellcheck source=parm/config/${config} + # shellcheck source=parm/config/config.${config} . "${config_path}/config.${config}" status=$? [[ ${status} -ne 0 ]] && exit "${status}" diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index fa3f0d5626..2f4b5202c3 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -176,7 +176,7 @@ cat >> fort.141 << EOF orog_files_input_grid="${CASE}_oro_data.tile1.nc","${CASE}_oro_data.tile2.nc","${CASE}_oro_data.tile3.nc","${CASE}_oro_data.tile4.nc","${CASE}_oro_data.tile5.nc","${CASE}_oro_data.tile6.nc" i_target=${nlon} j_target=${nlat} - model="${model}" + model="${model:?}" / EOF cp fort.141 fort.41 diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index 70a361d5fa..e31533285a 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -13,10 +13,12 @@ edate=$2 # EXECgldas - gldas exec directory # PARMgldas - gldas param directory # FIXgldas - gldas fix field directory -export LISDIR=${HOMEgldas} -export fpath=${RUNDIR}/force -export xpath=${RUNDIR}/force -export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} +export LISDIR=${HOMEgldas:?} +export fpath=${RUNDIR:?}/force +export xpath=${RUNDIR:?}/force +export WGRIB=${WGRIB:?} +export COPYGB=${COPYGB:?} +export ERRSCRIPT=${ERRSCRIPT:-"eval [[ $err = 0 ]]"} #------------------------------- #--- extract variables of each timestep and create forcing files @@ -33,9 +35,8 @@ cd "${xpath}" || exit rm -f fort.* grib.* COMPONENT=${COMPONENT:-"atmos"} -pathp1=${CPCGAUGE}/gdas.${sdate}/00/${COMPONENT} -pathp2=${DCOMIN}/${sdate}/wgrbbul/cpc_rcdas -yyyy=$(echo "${sdate}" |cut -c 1-4) +pathp1=${CPCGAUGE:?}/gdas.${sdate}/00/${COMPONENT} +pathp2=${DCOMIN:?}/${sdate}/wgrbbul/cpc_rcdas cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" if [[ "${RUN_ENVIR}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" @@ -72,7 +73,7 @@ if [[ "${USE_CFP}" = "YES" ]] ; then echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" >> ./cfile echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" >> ./cfile echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile - ${APRUN_GLDAS_DATA_PROC} ./cfile + ${APRUN_GLDAS_DATA_PROC:?} ./cfile else ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"12 grib.12 ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"18 grib.18 @@ -86,7 +87,9 @@ echo "${sdat0}" >> fort.10 echo "${sdate}" >> fort.10 export pgm=gldas_forcing +# shellcheck disable=SC1091 . prep_step +# shellcheck disable ${WGRIB} -d -bin grib.12 -o fort.11 ${WGRIB} -d -bin grib.18 -o fort.12 diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index e10502bca6..49d0848294 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -16,14 +16,14 @@ fi ### RUNDIR = gldas forcing in grib2 format ### RUNDIR/force = gldas forcing in grib1 format export COMPONENT=${COMPONENT:-atmos} -fpath=${RUNDIR} +fpath=${RUNDIR:?} gpath=${RUNDIR}/force cycint=${assim_freq:-6} # get gdas flux files to force gldas. # CPC precipitation is from 12z to 12z. One more day of gdas data is # needed to disaggregate daily CPC precipitation values to hourly values -cdate=$(${NDATE} -12 "${bdate}") +cdate=$(${NDATE:?} -12 "${bdate}") iter=0 @@ -37,7 +37,7 @@ while [[ "${cdate}" -lt "${edate}" ]]; do f=1 while [[ "${f}" -le "${cycint}" ]]; do - rflux=${COMINgdas}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 + rflux=${COMINgdas:?}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} if [[ ! -s "${rflux}" ]];then @@ -51,7 +51,7 @@ while [[ "${f}" -le "${cycint}" ]]; do if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi if [[ "${machine}" = "WCOSS2" ]]; then - echo "${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + echo "${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile elif [[ "${machine}" = "HERA" ]]; then echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else @@ -68,7 +68,7 @@ done #------------------------------- if [[ "${machine}" = "HERA" ]] || [[ "${machine}" = "WCOSS2" ]]; then - ${APRUN_GLDAS_DATA_PROC} ./cfile + ${APRUN_GLDAS_DATA_PROC:?} ./cfile fi exit $? diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 9733dba9f9..49988efa0d 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -20,7 +20,7 @@ export mm2=$(echo "${date2}" | cut -c 5-6) export dd2=$(echo "${date2}" | cut -c 7-8) export hh2=$(echo "${date2}" | cut -c 9-10) export grid=${grid} -export PARM_LM=${PARMgldas} +export PARM_LM=${PARMgldas:?} export LISCARD=lis.crd rm -f "${LISCARD}" diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index 920db9831b..2866cfc78f 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -8,6 +8,9 @@ fflux=$3 gflux=$4 f=$5 +WGRIB2=${WGRIB2:?} +CNVGRIB=${CNVGRIB:?} + ${WGRIB2} "${rflux}" | grep "TMP:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" ${WGRIB2} "${rflux}" | grep "SPFH:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" ${WGRIB2} "${rflux}" | grep "UGRD:1 hybrid" | grep "${fcsty}" | ${WGRIB2} -i "${rflux}" -append -grib "${fflux}" From 2e810c36a95961615c1db1b4ef29d3b591595cb2 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 13 Sep 2022 15:05:58 -0500 Subject: [PATCH 20/36] Address linter warnings in ush/gldas_archive.sh and ush/gldas_post.sh Refs #1014 --- ush/gldas_archive.sh | 64 +++++++++++++++++++++++--------------------- ush/gldas_post.sh | 18 +++++++------ 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh index 16282124fd..61335e1943 100755 --- a/ush/gldas_archive.sh +++ b/ush/gldas_archive.sh @@ -17,67 +17,69 @@ source "${HOMEgfs:?}/ush/preamble.sh" -if [ $# -lt 1 ]; then +if [[ $# -lt 1 ]]; then echo "usage: $0 sdate [edate]" exit $? fi +FINDDATE=${FINDDATE:?} + sdate=$1 -edate=$(sh ${FINDDATE} $1 d+1) -if [ $# -gt 1 ]; then edate=$2 ; fi +edate=$(sh "${FINDDATE}" "$1" d+1) +if [[ $# -gt 1 ]]; then edate=$2 ; fi -yyyy=$(echo ${sdate} | cut -c1-4) +yyyy=$(echo "${sdate}" | cut -c1-4) ### save all output to day1 directory -export COMDIR=${COM_OUT} +export COMDIR=${COM_OUT:?} -mkdir -p ${COMDIR}/gldas.${sdate} -yyyymmdd=$(sh ${FINDDATE} ${sdate} d+1) -while [ ${yyyymmdd} -le ${edate} ]; do +mkdir -p "${COMDIR}/gldas.${sdate}" +yyyymmdd=$(sh "${FINDDATE}" "${sdate}" d+1) +while [[ "${yyyymmdd}" -le "${edate}" ]]; do -mkdir -p ${COMDIR}/gldas.${yyyymmdd} +mkdir -p "${COMDIR}/gldas.${yyyymmdd}" -yyyy=$(echo ${yyyymmdd} | cut -c1-4) -cp ${RUNDIR}/EXP901/NOAH/${yyyy}/${yyyymmdd}/* ${COMDIR}/gldas.${sdate} +yyyy=$(echo "${yyyymmdd}" | cut -c1-4) +cp "${RUNDIR:?}/EXP901/NOAH/${yyyy}/${yyyymmdd}"/* "${COMDIR}/gldas.${sdate}" -yyyymmdd=$(sh ${FINDDATE} ${yyyymmdd} d+1) +yyyymmdd=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) done -cp ${RUNDIR}/sfc.gaussian.nemsio.${sdate} ${COMDIR}/gldas.${sdate} +cp "${RUNDIR}/sfc.gaussian.nemsio.${sdate}" "${COMDIR}/gldas.${sdate}" ### rename grb files yyyymmdd=${sdate} -while [ ${yyyymmdd} -lt ${edate} ]; do +while [[ "${yyyymmdd}" -lt "${edate}" ]]; do day1=${yyyymmdd} -day2=$(sh ${FINDDATE} ${yyyymmdd} d+1) -mv ${COMDIR}/gldas.${sdate}/LIS.E901.${day2}00.NOAH.grb ${COMDIR}/gldas.${sdate}/LIS.E901.${day1}00.NOAH.grb +day2=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) +mv "${COMDIR}/gldas.${sdate}/LIS.E901.${day2}00.NOAH.grb" "${COMDIR}/gldas.${sdate}/LIS.E901.${day1}00.NOAH.grb" -yyyymmdd=$(sh ${FINDDATE} ${yyyymmdd} d+1) +yyyymmdd=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) done ### save noah.rst.day2 to day2 directory for next day gldas restart -yyyymmdd=$(sh ${FINDDATE} ${sdate} d+1) -yyyy=$(echo ${yyyymmdd} | cut -c1-4) -mkdir -p ${COMDIR}/gldas.${edate} -cp ${RUNDIR}/EXP901/NOAH/${yyyy}/${edate}/LIS.E901.${edate}00.Noahrst ${COMDIR}/gldas.${yyyymmdd}/noah.rst.${edate} +yyyymmdd=$(sh "${FINDDATE}" "${sdate}" d+1) +yyyy=$(echo "${yyyymmdd}" | cut -c1-4) +mkdir -p "${COMDIR}/gldas.${edate}" +cp "${RUNDIR}/EXP901/NOAH/${yyyy}/${edate}/LIS.E901.${edate}00.Noahrst" "${COMDIR}/gldas.${yyyymmdd}/noah.rst.${edate}" ### generate and save gdas.t${cyc1}z.sfcanl.nemsio.gldas.day4 to day4 directory for next cycle gfs restart -mkdir -p ${COMDIR}/gldas.${edate} +mkdir -p "${COMDIR}/gldas.${edate}" gdate=${edate} gdas_date=${gdate}.${cyc}0000 -cp sfc_data.tile1.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile1.nc -cp sfc_data.tile2.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile2.nc -cp sfc_data.tile3.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile3.nc -cp sfc_data.tile4.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile4.nc -cp sfc_data.tile5.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile5.nc -cp sfc_data.tile6.nc ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc +cp sfc_data.tile1.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile1.nc" +cp sfc_data.tile2.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile2.nc" +cp sfc_data.tile3.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile3.nc" +cp sfc_data.tile4.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile4.nc" +cp sfc_data.tile5.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile5.nc" +cp sfc_data.tile6.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc" -cp sfc.gaussian.nemsio.gldas ${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gldas +cp sfc.gaussian.nemsio.gldas "${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gldas" -cp sfc.gaussian.nemsio ${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gdas +cp sfc.gaussian.nemsio "${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gdas" -echo ${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc +echo "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc" diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh index fd1a9c7926..8b5ff82653 100755 --- a/ush/gldas_post.sh +++ b/ush/gldas_post.sh @@ -2,31 +2,33 @@ source "${HOMEgfs:?}/ush/preamble.sh" -if [ $# -lt 2 ]; then +if [[ $# -lt 2 ]]; then echo "usage: $0 gldas.gbin gdas.sfcanl" err_exit 99 fi -cd ${RUNDIR} +cd "${RUNDIR:?}" || exit export pgm=gldas_post - . prep_step +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= gbin=$1 sfcanl=$2 rm -f fort.11 fort.12 fort.22 -cp ${gbin} fort.11 -cp ${sfcanl} fort.12 +cp "${gbin}" fort.11 +cp "${sfcanl}" fort.12 -${EXECgldas}/gldas_post >>${pgmout} 2>errfile +"${EXECgldas:?}/gldas_post" >>"${pgmout:?}" 2>errfile export err=$?; err_chk cp fort.22 ./gldas.nemsio -cp fort.22 ${sfcanl}.gldas +cp fort.22 "${sfcanl}.gldas" rm -f fort.11 fort.12 fort.22 -echo ${sfcanl}.gldas +echo "${sfcanl}.gldas" exit $? From 82780bd66c42a693adf92eb88f27cf392bf7e1a4 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 11:39:19 -0500 Subject: [PATCH 21/36] A couple syntax corrections in ush/gldas_forcing.sh Refs #1014 --- ush/gldas_forcing.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index e31533285a..4c2c6953c3 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -24,7 +24,7 @@ export ERRSCRIPT=${ERRSCRIPT:-"eval [[ $err = 0 ]]"} #--- extract variables of each timestep and create forcing files sdate=${bdate} edate=$(sh "${FINDDATE}" "${edate}" d-1) -while [[ "${sdate}" -lt "${edate}" ]]; do +while [[ "${sdate}" -lt "${edate}" ]] ; do #------------------------------- sdat0=$(sh "${FINDDATE}" "${sdate}" d-1) @@ -89,7 +89,7 @@ echo "${sdate}" >> fort.10 export pgm=gldas_forcing # shellcheck disable=SC1091 . prep_step -# shellcheck disable +# shellcheck disable= ${WGRIB} -d -bin grib.12 -o fort.11 ${WGRIB} -d -bin grib.18 -o fort.12 From 236c968f49cb4ed049753376fea868fb8394c60f Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 11:40:09 -0500 Subject: [PATCH 22/36] Address a couple linter warnings Refs #1014 --- scripts/exgdas_atmos_gldas.sh | 1 + ush/gldas_archive.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index 2f4b5202c3..ef54a3dc42 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -57,6 +57,7 @@ export JCAP=$((2*res-2)) export nlat=$((2*res)) export nlon=$((4*res)) +export USHgldas=${USHgldas:?} export FIXgldas=${FIXgldas:-${HOMEgfs}/fix} export topodir=${topodir:-${HOMEgfs}/fix/fix_fv3_gmted2010/${CASE}/} diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh index 61335e1943..709741821c 100755 --- a/ush/gldas_archive.sh +++ b/ush/gldas_archive.sh @@ -70,7 +70,7 @@ cp "${RUNDIR}/EXP901/NOAH/${yyyy}/${edate}/LIS.E901.${edate}00.Noahrst" "${COMDI mkdir -p "${COMDIR}/gldas.${edate}" gdate=${edate} -gdas_date=${gdate}.${cyc}0000 +gdas_date=${gdate}.${cyc:?}0000 cp sfc_data.tile1.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile1.nc" cp sfc_data.tile2.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile2.nc" cp sfc_data.tile3.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile3.nc" From a908c826752b6632589136c788752ccee36aa6fc Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 11:54:50 -0500 Subject: [PATCH 23/36] Removing gldas_archive.sh and gldas_post.sh After discussion with GLDAS code manager and confirming what GLDAS scripts are actually used at runtime, it was decided to not bring the ush/gldas_archive.sh and ush/gldas_post.sh scripts from GLDAS into global-workflow. Deleting them from this branch. Refs #1014 --- ush/gldas_archive.sh | 85 -------------------------------------------- ush/gldas_post.sh | 34 ------------------ 2 files changed, 119 deletions(-) delete mode 100755 ush/gldas_archive.sh delete mode 100755 ush/gldas_post.sh diff --git a/ush/gldas_archive.sh b/ush/gldas_archive.sh deleted file mode 100755 index 709741821c..0000000000 --- a/ush/gldas_archive.sh +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/env bash -# -######################################################### -# This script collects gldas output to archive directory -# Replace soil moisture and temperature for gdas nemsio file -# generate from Gaussian grid fileds to 6-tile netcdf file -# -# usage - gldas_archive.sh sdate edate -# sdate/edate in yyyymmdd -# -# HOMEgldas - software directory -# COMDIR - output archive directory -# RUNDIR - run directory -# GDAS - /lfs/h1/ops/prod/com/gfs/prod -# -######################################################### - -source "${HOMEgfs:?}/ush/preamble.sh" - -if [[ $# -lt 1 ]]; then - echo "usage: $0 sdate [edate]" - exit $? -fi - -FINDDATE=${FINDDATE:?} - -sdate=$1 -edate=$(sh "${FINDDATE}" "$1" d+1) -if [[ $# -gt 1 ]]; then edate=$2 ; fi - -yyyy=$(echo "${sdate}" | cut -c1-4) - -### save all output to day1 directory -export COMDIR=${COM_OUT:?} - -mkdir -p "${COMDIR}/gldas.${sdate}" -yyyymmdd=$(sh "${FINDDATE}" "${sdate}" d+1) -while [[ "${yyyymmdd}" -le "${edate}" ]]; do - -mkdir -p "${COMDIR}/gldas.${yyyymmdd}" - -yyyy=$(echo "${yyyymmdd}" | cut -c1-4) -cp "${RUNDIR:?}/EXP901/NOAH/${yyyy}/${yyyymmdd}"/* "${COMDIR}/gldas.${sdate}" - -yyyymmdd=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) -done - -cp "${RUNDIR}/sfc.gaussian.nemsio.${sdate}" "${COMDIR}/gldas.${sdate}" - -### rename grb files - -yyyymmdd=${sdate} -while [[ "${yyyymmdd}" -lt "${edate}" ]]; do - -day1=${yyyymmdd} -day2=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) -mv "${COMDIR}/gldas.${sdate}/LIS.E901.${day2}00.NOAH.grb" "${COMDIR}/gldas.${sdate}/LIS.E901.${day1}00.NOAH.grb" - -yyyymmdd=$(sh "${FINDDATE}" "${yyyymmdd}" d+1) -done - -### save noah.rst.day2 to day2 directory for next day gldas restart - -yyyymmdd=$(sh "${FINDDATE}" "${sdate}" d+1) -yyyy=$(echo "${yyyymmdd}" | cut -c1-4) -mkdir -p "${COMDIR}/gldas.${edate}" -cp "${RUNDIR}/EXP901/NOAH/${yyyy}/${edate}/LIS.E901.${edate}00.Noahrst" "${COMDIR}/gldas.${yyyymmdd}/noah.rst.${edate}" - -### generate and save gdas.t${cyc1}z.sfcanl.nemsio.gldas.day4 to day4 directory for next cycle gfs restart - -mkdir -p "${COMDIR}/gldas.${edate}" -gdate=${edate} -gdas_date=${gdate}.${cyc:?}0000 -cp sfc_data.tile1.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile1.nc" -cp sfc_data.tile2.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile2.nc" -cp sfc_data.tile3.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile3.nc" -cp sfc_data.tile4.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile4.nc" -cp sfc_data.tile5.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile5.nc" -cp sfc_data.tile6.nc "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc" - -cp sfc.gaussian.nemsio.gldas "${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gldas" - -cp sfc.gaussian.nemsio "${COMDIR}/gldas.${edate}/${gdas_date}.sfc.gaussian.nemsio.gdas" - -echo "${COMDIR}/gldas.${edate}/${gdas_date}.sfcanl_data.tile6.nc" diff --git a/ush/gldas_post.sh b/ush/gldas_post.sh deleted file mode 100755 index 8b5ff82653..0000000000 --- a/ush/gldas_post.sh +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env bash - -source "${HOMEgfs:?}/ush/preamble.sh" - -if [[ $# -lt 2 ]]; then - echo "usage: $0 gldas.gbin gdas.sfcanl" - err_exit 99 -fi - -cd "${RUNDIR:?}" || exit - -export pgm=gldas_post -# shellcheck disable=SC1091 -. prep_step -# shellcheck disable= - -gbin=$1 -sfcanl=$2 - -rm -f fort.11 fort.12 fort.22 -cp "${gbin}" fort.11 -cp "${sfcanl}" fort.12 - -"${EXECgldas:?}/gldas_post" >>"${pgmout:?}" 2>errfile -export err=$?; err_chk - -cp fort.22 ./gldas.nemsio -cp fort.22 "${sfcanl}.gldas" -rm -f fort.11 fort.12 fort.22 - -echo "${sfcanl}.gldas" - -exit $? - From c2b3e201d218b71c7384db2c4196032da4ef8b83 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 13:27:41 -0500 Subject: [PATCH 24/36] Address linter warnings in jobs/JGDAS_ATMOS_GLDAS and ush/gldas_forcing.sh Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 4 +++- ush/gldas_forcing.sh | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 97c84c12e5..62196154b7 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -2,6 +2,8 @@ source "${HOMEgfs:?}/ush/preamble.sh" +export RUN_ENVIR=${RUN_ENVIR:-"nco"} + ############################# # Source relevant config files ############################# @@ -85,7 +87,7 @@ export EXECgldas=${EXECgldas:-${HOMEgldas}/exec} export USHgldas=${USHgldas:-${HOMEgldas}/ush} export PARA_CONFIG=${HOMEgfs}/parm/config/config.gldas -if [[ "${RUN_ENVIR:?}" = "nco" ]]; then +if [[ "${RUN_ENVIR}" = "nco" ]]; then export COMIN=${COMIN:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/${COMPONENT}} else diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index 4c2c6953c3..a9c95e29ea 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -18,16 +18,16 @@ export fpath=${RUNDIR:?}/force export xpath=${RUNDIR:?}/force export WGRIB=${WGRIB:?} export COPYGB=${COPYGB:?} -export ERRSCRIPT=${ERRSCRIPT:-"eval [[ $err = 0 ]]"} +export ERRSCRIPT=${ERRSCRIPT:-"eval [[ ${err} = 0 ]]"} #------------------------------- #--- extract variables of each timestep and create forcing files sdate=${bdate} -edate=$(sh "${FINDDATE}" "${edate}" d-1) +edate=$(sh "${FINDDATE:?}" "${edate}" d-1) while [[ "${sdate}" -lt "${edate}" ]] ; do #------------------------------- -sdat0=$(sh "${FINDDATE}" "${sdate}" d-1) +sdat0=$(sh "${FINDDATE:?}" "${sdate}" d-1) [[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p "${xpath}/cpc.${sdate}" [[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p "${xpath}/cpc.${sdat0}" @@ -38,12 +38,12 @@ COMPONENT=${COMPONENT:-"atmos"} pathp1=${CPCGAUGE:?}/gdas.${sdate}/00/${COMPONENT} pathp2=${DCOMIN:?}/${sdate}/wgrbbul/cpc_rcdas cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" -if [[ "${RUN_ENVIR}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then +if [[ "${RUN_ENVIR:?}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" fi cpc=${pathp1}/${cpc_precip} if [[ ! -s "${cpc}" ]]; then cpc=${pathp2}/${cpc_precip} ; fi -if [[ "${RUN_ENVIR}" = "nco" ]]; then cpc=${pathp2}/${cpc_precip} ; fi +if [[ "${RUN_ENVIR:?}" = "nco" ]]; then cpc=${pathp2}/${cpc_precip} ; fi if [[ ! -s "${cpc}" ]]; then echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." exit 3 @@ -66,7 +66,7 @@ sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 prate=gdas.${sdate}06 ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" -if [[ "${USE_CFP}" = "YES" ]] ; then +if [[ "${USE_CFP:?}" = "YES" ]] ; then rm -f ./cfile touch ./cfile echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile @@ -98,7 +98,7 @@ ${WGRIB} -d -bin grib.06 -o fort.14 ln -fs "${xpath}/cpc.${sdate}/${cpc_precip}" fort.15 -"${EXECgldas}/gldas_forcing" 1>&1 2>&2 +"${EXECgldas:?}/gldas_forcing" 1>&1 2>&2 export err=$? ${ERRSCRIPT} || exit 3 From 235a85bd8ee3b3cd9e3463ea70c54882f457e9da Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 13:30:50 -0500 Subject: [PATCH 25/36] Convert GLDAS script to replace machine checks with CFP variables - Remove checks for machine in ush/gldas_get_data.sh and replace with existing CFP variables in system (USE_CFP and CFP_MP). - Update Hera and Orion env files to set USE_CFP and CFP_MP as needed. - Similar env variable settings will be added into WCOSS2.env in that branch. Refs #1014 --- env/HERA.env | 3 +++ env/ORION.env | 2 ++ ush/gldas_get_data.sh | 16 +++++++++------- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/env/HERA.env b/env/HERA.env index 51a7c85a33..83afd9b3e7 100755 --- a/env/HERA.env +++ b/env/HERA.env @@ -125,6 +125,9 @@ elif [ $step = "sfcanl" ]; then elif [ $step = "gldas" ]; then + export USE_CFP="YES" + export CFP_MP="YES" + nth_max=$(($npe_node_max / $npe_node_gldas)) export NTHREADS_GLDAS=${nth_gldas:-$nth_max} diff --git a/env/ORION.env b/env/ORION.env index 8dc267631f..dc3b934891 100755 --- a/env/ORION.env +++ b/env/ORION.env @@ -123,6 +123,8 @@ elif [ $step = "sfcanl" ]; then elif [ $step = "gldas" ]; then + export USE_CFP="NO" + nth_max=$(($npe_node_max / $npe_node_gldas)) export NTHREADS_GLDAS=${nth_gldas:-$nth_max} diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 49d0848294..022acb6c34 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -8,7 +8,7 @@ source "${HOMEgfs:?}/ush/preamble.sh" bdate=$1 edate=$2 -if [[ "${machine}" = "HERA" ]] || [[ "${machine}" = "WCOSS2" ]]; then +if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then touch ./cfile fi @@ -50,12 +50,14 @@ while [[ "${f}" -le "${cycint}" ]]; do fcsty=anl if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi - if [[ "${machine}" = "WCOSS2" ]]; then - echo "${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile - elif [[ "${machine}" = "HERA" ]]; then - echo "${iter} ${USHgldas}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then + if [ ${CFP_MP:-"NO"} = "YES" ]; then + echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + else + echo "${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + fi else - "${USHgldas}/gldas_process_data.sh" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" + "${USHgldas:?}/gldas_process_data.sh" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" fi iter=$((iter+1)) @@ -67,7 +69,7 @@ done done #------------------------------- -if [[ "${machine}" = "HERA" ]] || [[ "${machine}" = "WCOSS2" ]]; then +if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then ${APRUN_GLDAS_DATA_PROC:?} ./cfile fi From 887ba666c00a1a2b205fa1f777ea07d3beadce68 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 13:38:56 -0500 Subject: [PATCH 26/36] Address double quote linter warning in ush/gldas_get_data.sh Refs #1014 --- ush/gldas_get_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 022acb6c34..4ddca6d724 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -51,7 +51,7 @@ while [[ "${f}" -le "${cycint}" ]]; do if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then - if [ ${CFP_MP:-"NO"} = "YES" ]; then + if [[ "${CFP_MP:-"NO"}" = "YES" ]]; then echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else echo "${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile From 617d4250fef8f08be78192e64aec666913e79f08 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 13:56:51 -0500 Subject: [PATCH 27/36] Remove exports of local variables in scripts/exgdas_atmos_gldas.sh Refs #1014 --- scripts/exgdas_atmos_gldas.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index ef54a3dc42..2bd0154cb4 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -34,28 +34,30 @@ export USE_CFP=${USE_CFP:-"NO"} export COMPONENT=${COMPONENT:-atmos} export assim_freq=${assim_freq:-6} export gldas_spinup_hours=${gldas_spinup_hours:-72} -export gldas_cdate=${CDATE:?} -export gldas_eymd=$(echo "${gldas_cdate}" |cut -c 1-8) -export gldas_ecyc=$(echo "${gldas_cdate}" |cut -c 9-10) -export gldas_sdate=$(${NDATE} -"${gldas_spinup_hours}" "${CDATE}") -export gldas_symd=$(echo "${gldas_sdate}" |cut -c 1-8) -export gldas_scyc=$(echo "${gldas_sdate}" |cut -c 9-10) - -export iau_cdate=${CDATE} + +# Local date variables +gldas_cdate=${CDATE:?} +gldas_eymd=$(echo "${gldas_cdate}" |cut -c 1-8) +gldas_ecyc=$(echo "${gldas_cdate}" |cut -c 9-10) +gldas_sdate=$(${NDATE} -"${gldas_spinup_hours}" "${CDATE}") +gldas_symd=$(echo "${gldas_sdate}" |cut -c 1-8) +gldas_scyc=$(echo "${gldas_sdate}" |cut -c 9-10) + +iau_cdate=${CDATE} if [[ "${DOIAU:?}" = "YES" ]]; then IAU_OFFSET=${IAU_OFFSET:-0} IAUHALH=$((IAU_OFFSET/2)) - export iau_cdate=$(${NDATE} -"${IAUHALH}" "${CDATE}") + iau_cdate=$(${NDATE} -"${IAUHALH}" "${CDATE}") fi -export iau_eymd=$(echo "${iau_cdate}" |cut -c 1-8) -export iau_ecyc=$(echo "${iau_cdate}" |cut -c 9-10) +iau_eymd=$(echo "${iau_cdate}" |cut -c 1-8) +iau_ecyc=$(echo "${iau_cdate}" |cut -c 9-10) echo "GLDAS runs from ${gldas_sdate} to ${iau_cdate}" -export CASE=${CASE:-C768} -export res=$(echo "${CASE}" |cut -c2-5) -export JCAP=$((2*res-2)) -export nlat=$((2*res)) -export nlon=$((4*res)) +CASE=${CASE:-C768} +res=$(echo "${CASE}" |cut -c2-5) +JCAP=$((2*res-2)) +nlat=$((2*res)) +nlon=$((4*res)) export USHgldas=${USHgldas:?} export FIXgldas=${FIXgldas:-${HOMEgfs}/fix} From 7f35d55799acdc0aee4f89482c04c8b83b3608e6 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 14:02:15 -0500 Subject: [PATCH 28/36] Removing exports for local variables in ush/gldas_liscrd.sh Refs #1014 --- ush/gldas_liscrd.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 49988efa0d..17c88c3685 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -11,17 +11,18 @@ date1=$1 date2=$2 grid=$3 -export yyyy1=$(echo "${date1}" | cut -c 1-4) -export mm1=$(echo "${date1}" | cut -c 5-6) -export dd1=$(echo "${date1}" | cut -c 7-8) -export hh1=$(echo "${date1}" | cut -c 9-10) -export yyyy2=$(echo "${date2}" | cut -c 1-4) -export mm2=$(echo "${date2}" | cut -c 5-6) -export dd2=$(echo "${date2}" | cut -c 7-8) -export hh2=$(echo "${date2}" | cut -c 9-10) -export grid=${grid} -export PARM_LM=${PARMgldas:?} -export LISCARD=lis.crd +yyyy1=$(echo "${date1}" | cut -c 1-4) +mm1=$(echo "${date1}" | cut -c 5-6) +dd1=$(echo "${date1}" | cut -c 7-8) +hh1=$(echo "${date1}" | cut -c 9-10) +yyyy2=$(echo "${date2}" | cut -c 1-4) +mm2=$(echo "${date2}" | cut -c 5-6) +dd2=$(echo "${date2}" | cut -c 7-8) +hh2=$(echo "${date2}" | cut -c 9-10) + +grid=${grid} +PARM_LM=${PARMgldas:?} +LISCARD=lis.crd rm -f "${LISCARD}" touch "${LISCARD}" From 272539c3da8281a03b2ba0f25d34f3e83352044e Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Wed, 14 Sep 2022 14:04:46 -0500 Subject: [PATCH 29/36] Remove unnecessary variable setting in ush/gldas_liscrd.sh Refs #1014 --- ush/gldas_liscrd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 17c88c3685..075ff957ea 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -20,7 +20,6 @@ mm2=$(echo "${date2}" | cut -c 5-6) dd2=$(echo "${date2}" | cut -c 7-8) hh2=$(echo "${date2}" | cut -c 9-10) -grid=${grid} PARM_LM=${PARMgldas:?} LISCARD=lis.crd From 9a6a112f583fa794b4b45681c7d530dabb2ab829 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 19 Sep 2022 09:12:09 -0500 Subject: [PATCH 30/36] GLDAS fix file updates for FRAC_GRID - Updates to set GLDAS fix files based on FRAC_GRID setting. - Update scripts/exgdas_atmos_gldas.sh to set FIXgldas subfolder based on value of FRAC_GRID: use "frac_grid" subfolder when .true. or use "nonfrac_grid" subfolder when .false. - Move FRAC_GRID variable from config.fcst to config.base since it will now be used in more than just the forecast job. - Also correct FIXgldas default in scripts/exgdas_atmos_gldas.sh to add missing "/fix_gldas" path. Refs #1014 --- parm/config/config.base.emc.dyn | 1 + parm/config/config.fcst | 1 - scripts/exgdas_atmos_gldas.sh | 9 +++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/parm/config/config.base.emc.dyn b/parm/config/config.base.emc.dyn index af18173d60..e01682051c 100755 --- a/parm/config/config.base.emc.dyn +++ b/parm/config/config.base.emc.dyn @@ -162,6 +162,7 @@ export CCPP_SUITE="FV3_GFS_v17_p8" export WAVE_CDUMP="" # When to include wave suite: gdas, gfs, or both export DOBNDPNT_WAVE="NO" export cplwav2atm=".false." +export FRAC_GRID=".true." case "${APP}" in ATM) diff --git a/parm/config/config.fcst b/parm/config/config.fcst index cb1add3fff..51bee1e243 100755 --- a/parm/config/config.fcst +++ b/parm/config/config.fcst @@ -252,7 +252,6 @@ export DO_OCN_SPPT=${DO_OCN_SPPT:-"NO"} export DO_OCN_PERT_EPBL=${DO_OCN_PERT_EPBL:-"NO"} #coupling settings -export FRAC_GRID=".true." export cplmode="nems_frac" if [ $FRAC_GRID = ".false." ]; then export cplmode="nems_orig" diff --git a/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh index 2bd0154cb4..4cae6f83f5 100755 --- a/scripts/exgdas_atmos_gldas.sh +++ b/scripts/exgdas_atmos_gldas.sh @@ -60,7 +60,7 @@ nlat=$((2*res)) nlon=$((4*res)) export USHgldas=${USHgldas:?} -export FIXgldas=${FIXgldas:-${HOMEgfs}/fix} +export FIXgldas=${FIXgldas:-${HOMEgfs}/fix/fix_gldas} export topodir=${topodir:-${HOMEgfs}/fix/fix_fv3_gmted2010/${CASE}/} DATA=${DATA:-${pwd}/gldastmp$$} @@ -84,9 +84,14 @@ input2=${COMINgdas}/gdas.${gldas_eymd}/${gldas_ecyc}/${COMPONENT}/RESTART [[ -d ${RUNDIR}/input ]] && rm -fr "${RUNDIR}/input" mkdir -p "${RUNDIR}/input" ln -fs "${GDAS}" "${RUNDIR}/input/GDAS" -ln -fs "${FIXgldas}/FIX_T${JCAP}" "${RUNDIR}/FIX" ln -fs "${EXECgldas:?}/gldas_model" "${RUNDIR}/LIS" +# Set FIXgldas subfolder based on FRAC_GRID value +if [[ "${FRAC_GRID:-".true."}" = ".true." ]] ; then + ln -fs "${FIXgldas}/frac_grid/FIX_T${JCAP}" "${RUNDIR}/FIX" +else + ln -fs "${FIXgldas}/nonfrac_grid/FIX_T${JCAP}" "${RUNDIR}/FIX" +fi #--------------------------------------------------------------- ### 1) Get gdas 6-tile netcdf restart file and gdas forcing data From 38a5f98afbc49d7a25e26b0ac2b655508c0781c5 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 19 Sep 2022 11:10:28 -0500 Subject: [PATCH 31/36] Address linter warnings and use iter as argument to gldas_process_data.sh - Update GLDAS scripts and config.fcst to address linter/shellcheck warnings. - Update gldas_get_data.sh and gldas_process_data.sh to pass $iter variable as argument in gldas_process_data.sh and give to preamble. Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 7 +++-- parm/config/config.fcst | 62 +++++++++++++++++++-------------------- ush/gldas_forcing.sh | 10 ++++--- ush/gldas_get_data.sh | 6 ++-- ush/gldas_liscrd.sh | 32 ++++++++++---------- ush/gldas_process_data.sh | 12 ++++---- 6 files changed, 68 insertions(+), 61 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index 62196154b7..a60a04fe36 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -94,13 +94,16 @@ else export COMIN="${ROTDIR}/${CDUMP}.${PDY}/${cyc}/${COMPONENT}" export COMOUT="${ROTDIR}/${CDUMP}.${PDY}/${cyc}/${COMPONENT}" fi -[[ ! -d ${COMOUT} ]] && mkdir -m 775 -p "${COMOUT}" +if [[ ! -d ${COMOUT} ]]; then + mkdir -p "${COMOUT}" + chmod 775 "${COMOUT}" +fi export COMINgdas=${COMINgdas:-${ROTDIR}} export DCOMIN=${DCOMIN:-${DCOMROOT:-"/lfs/h1/ops/prod/dcom"}} export model=${model:-noah} -export MODEL=${MODEL:-$(echo "${model} |tr 'a-z' 'A-Z'")} +export MODEL=${MODEL:-"${model} |tr 'a-z' 'A-Z'"} ############################################################### diff --git a/parm/config/config.fcst b/parm/config/config.fcst index 51bee1e243..644d7a8589 100755 --- a/parm/config/config.fcst +++ b/parm/config/config.fcst @@ -29,7 +29,7 @@ done export domains_stack_size="16000000" -if [ $DONST = "YES" ]; then +if [[ "$DONST" = "YES" ]]; then . $EXPDIR/config.nsst fi @@ -54,20 +54,20 @@ export cplwav=".false." # cpl changes based on APP -if [ $DO_COUPLED = "YES" ]; then +if [[ "$DO_COUPLED" = "YES" ]]; then export cpl=".true." fi -if [ $DO_AERO = "YES" ]; then +if [[ "$DO_AERO" = "YES" ]]; then export cplchm=".true." fi -if [ $DO_ICE = "YES" ]; then +if [[ "$DO_ICE" = "YES" ]]; then export cplice=".true." export cplflx=".true." fi -if [ $DO_OCN = "YES" ]; then +if [[ "$DO_OCN" = "YES" ]]; then export cplflx=".true." fi -if [ $DO_WAVE = "YES" ]; then +if [[ "$DO_WAVE" = "YES" ]]; then export cplwav=".true." fi @@ -98,7 +98,7 @@ export gwd_opt=2 # --GFS.v16 uGWD.v0, used for suite FV3_GFS_v16 and UFS p6 etc # do_ugwp=T: use unified CGWD and OGWD, and turbulent orographic form drag (TOFD) # do_ugwp=F: use unified CGWD but old OGWD, TOFD is not uded. -if [ $gwd_opt -eq 1 ]; then +if [[ "$gwd_opt" -eq 1 ]]; then export knob_ugwp_version=0 export do_ugwp=".false." export do_tofd=".false." @@ -107,7 +107,7 @@ fi # -- uGWD.v1, for suite FV3_GFS_v17 and FV3_GFS_v17p8b etc -if [ $gwd_opt -eq 2 ]; then +if [[ "$gwd_opt" -eq 2 ]]; then #--used for UFS p7 and p8a #export knob_ugwp_version=1 @@ -147,7 +147,7 @@ export d2_bg_k1=0.20 export d2_bg_k2=0.04 export dz_min=6 export n_sponge=42 -if [ $LEVS = "128" -a "$CDUMP" = "gdas" ]; then +if [[ "$LEVS" = "128" -a "$CDUMP" = "gdas" ]]; then export tau=5.0 export rf_cutoff=1.0e3 export d2_bg_k1=0.20 @@ -159,13 +159,13 @@ export hybedmf=".false." export satmedmf=".true." export isatmedmf=1 tbf="" -if [ $satmedmf = ".true." ]; then tbf="_satmedmf" ; fi +if [[ "$satmedmf" = ".true." ]]; then tbf="_satmedmf" ; fi -# Radiation options +# Radiation options export IAER=1011 ; #spectral band mapping method for aerosol optical properties -export iovr_lw=3 ; #de-correlation length cloud overlap method (Barker, 2008) -export iovr_sw=3 ; #de-correlation length cloud overlap method (Barker, 2008) -export iovr=3 ; #de-correlation length cloud overlap method (Barker, 2008) +export iovr_lw=3 ; #de-correlation length cloud overlap method (Barker, 2008) +export iovr_sw=3 ; #de-correlation length cloud overlap method (Barker, 2008) +export iovr=3 ; #de-correlation length cloud overlap method (Barker, 2008) export icliq_sw=2 ; #cloud optical coeffs from AER's newer version v3.9-v4.0 for hu and stamnes export isubc_sw=2 export isubc_lw=2 @@ -186,17 +186,17 @@ export cal_pre=".true." export do_sat_adj=".false." export random_clds=".true." -if [ $imp_physics -eq 99 ]; then # ZhaoCarr +if [[ "$imp_physics" -eq 99 ]]; then # ZhaoCarr export ncld=1 export FIELD_TABLE="$HOMEgfs/parm/parm_fv3diag/field_table_zhaocarr${tbf}" export nwat=2 -elif [ $imp_physics -eq 6 ]; then # WSM6 +elif [[ "$imp_physics" -eq 6 ]]; then # WSM6 export ncld=2 export FIELD_TABLE="$HOMEgfs/parm/parm_fv3diag/field_table_wsm6${tbf}" export nwat=6 -elif [ $imp_physics -eq 8 ]; then # Thompson +elif [[ "$imp_physics" -eq 8 ]]; then # Thompson export ncld=2 export FIELD_TABLE="$HOMEgfs/parm/parm_fv3diag/field_table_thompson_noaero_tke" export nwat=6 @@ -209,7 +209,7 @@ elif [ $imp_physics -eq 8 ]; then # Thompson export ttendlim="-999" export dt_inner=$((DELTIM/2)) export sedi_semi=.true. - if [ $sedi_semi = .true. ]; then export dt_inner=$DELTIM ; fi + if [[ "$sedi_semi" = .true. ]]; then export dt_inner=$DELTIM ; fi export decfl=10 export hord_mt_nh_nonmono=5 @@ -218,7 +218,7 @@ elif [ $imp_physics -eq 8 ]; then # Thompson export nord=2 export dddmp=0.1 export d4_bg=0.12 -elif [ $imp_physics -eq 11 ]; then # GFDL +elif [[ "$imp_physics" -eq 11 ]]; then # GFDL export ncld=5 export FIELD_TABLE="$HOMEgfs/parm/parm_fv3diag/field_table_gfdl${tbf}" export nwat=6 @@ -253,7 +253,7 @@ export DO_OCN_PERT_EPBL=${DO_OCN_PERT_EPBL:-"NO"} #coupling settings export cplmode="nems_frac" -if [ $FRAC_GRID = ".false." ]; then +if [[ "${FRAC_GRID:-".true."}" = ".false." ]]; then export cplmode="nems_orig" fi export psm_bc="1" @@ -283,7 +283,7 @@ export USE_COUPLER_RES="NO" if [[ "$CDUMP" == "gdas" ]] ; then # GDAS cycle specific parameters # Variables used in DA cycling - if [ $QUILTING = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]; then + if [[ "$QUILTING" = ".true." -a "$OUTPUT_GRID" = "gaussian_grid" ]]; then export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_da" else export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_da_orig" @@ -300,12 +300,12 @@ if [[ "$CDUMP" == "gdas" ]] ; then # GDAS cycle specific parameters export restart_interval=${restart_interval:-6} # For IAU, write restarts at beginning of window also - if [ $DOIAU = "YES" ]; then + if [[ "$DOIAU" = "YES" ]]; then export restart_interval="3 6" fi # Choose coupling with wave - if [ $DO_WAVE = "YES" ]; then export cplwav=".true." ; fi + if [[ "$DO_WAVE" = "YES" ]]; then export cplwav=".true." ; fi # Turn on dry mass adjustment in GDAS export adjust_dry_mass=".true." @@ -313,15 +313,15 @@ if [[ "$CDUMP" == "gdas" ]] ; then # GDAS cycle specific parameters elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters # Write more variables to output - if [ $QUILTING = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]; then + if [[ "$QUILTING" = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]]; then export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table" else export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_orig" fi - # Write gfs restart files to rerun fcst from any break point + # Write gfs restart files to rerun fcst from any break point export restart_interval_gfs=${restart_interval_gfs:-0} - if [ $restart_interval_gfs -le 0 ]; then + if [[ "$restart_interval_gfs" -le 0 ]]; then export restart_interval="$FHMAX_GFS" else rst_list="" @@ -335,7 +335,7 @@ elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters export restart_interval="$rst_list" fi - if [ $DO_AERO = "YES" ]; then + if [[ "$DO_AERO" = "YES" ]]; then # Make sure a restart file is written at the cadence time if [[ ! "${restart_interval[*]}" =~ "$STEP_GFS" ]]; then export restart_interval="$STEP_GFS $restart_interval" @@ -343,7 +343,7 @@ elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters fi # Choose coupling with wave - if [ $DO_WAVE = "YES" -a "$WAVE_CDUMP" != "gdas" ]; then + if [[ "$DO_WAVE" = "YES" -a "$WAVE_CDUMP" != "gdas" ]]; then export cplwav=".true." fi @@ -351,7 +351,7 @@ elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters export adjust_dry_mass=".false." # Write each restart file in 16 small files to save time - if [ $CASE = C768 ]; then + if [[ "$CASE" = C768 ]]; then export io_layout="4,4" else export io_layout="1,1" @@ -359,11 +359,11 @@ elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters fi -if [[ $DO_COUPLED = "YES" ]] ; then # coupled model +if [[ "$DO_COUPLED" = "YES" ]] ; then # coupled model export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_cpl" fi -if [ $DO_AERO = "YES" ]; then # temporary settings for aerosol coupling +if [[ "$DO_AERO" = "YES" ]]; then # temporary settings for aerosol coupling export AERO_DIAG_TABLE="${AERO_DIAG_TABLE:-$HOMEgfs/parm/parm_fv3diag/diag_table.aero}" export AERO_FIELD_TABLE="${AERO_FIELD_TABLE:-$HOMEgfs/parm/parm_fv3diag/field_table.aero}" export AERO_EMIS_FIRE=$( echo "${AERO_EMIS_FIRE:-none}" | awk '{ print tolower($1) }' ) diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index a9c95e29ea..ae4f56cd03 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -69,10 +69,12 @@ ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${p if [[ "${USE_CFP:?}" = "YES" ]] ; then rm -f ./cfile touch ./cfile - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" >> ./cfile - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" >> ./cfile - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" >> ./cfile - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" >> ./cfile + { + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" + } >> ./cfile ${APRUN_GLDAS_DATA_PROC:?} ./cfile else ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"12 grib.12 diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index 4ddca6d724..eb2891643e 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -52,12 +52,12 @@ while [[ "${f}" -le "${cycint}" ]]; do if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then if [[ "${CFP_MP:-"NO"}" = "YES" ]]; then - echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile else - echo "${USHgldas:?}/gldas_process_data.sh ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + echo "${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile fi else - "${USHgldas:?}/gldas_process_data.sh" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" + "${USHgldas:?}/gldas_process_data.sh" "${iter}" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" fi iter=$((iter+1)) diff --git a/ush/gldas_liscrd.sh b/ush/gldas_liscrd.sh index 075ff957ea..7c0f446035 100755 --- a/ush/gldas_liscrd.sh +++ b/ush/gldas_liscrd.sh @@ -25,20 +25,22 @@ LISCARD=lis.crd rm -f "${LISCARD}" touch "${LISCARD}" -cat "${PARM_LM}/lis.crd.T${grid}.tmp.1" >> "${LISCARD}" -echo "LIS%t%SSS = 0 " >> "${LISCARD}" -echo "LIS%t%SMN = 00 " >> "${LISCARD}" -echo "LIS%t%SHR = ${hh1} " >> "${LISCARD}" -echo "LIS%t%SDA = ${dd1} " >> "${LISCARD}" -echo "LIS%t%SMO = ${mm1} " >> "${LISCARD}" -echo "LIS%t%SYR = ${yyyy1}" >> "${LISCARD}" -echo "LIS%t%ENDCODE = 1 " >> "${LISCARD}" -echo "LIS%t%ESS = 0 " >> "${LISCARD}" -echo "LIS%t%EMN = 00 " >> "${LISCARD}" -echo "LIS%t%EHR = ${hh2} " >> "${LISCARD}" -echo "LIS%t%EDA = ${dd2} " >> "${LISCARD}" -echo "LIS%t%EMO = ${mm2} " >> "${LISCARD}" -echo "LIS%t%EYR = ${yyyy2}" >> "${LISCARD}" -cat "${PARM_LM}/lis.crd.T${grid}.tmp.2" >> "${LISCARD}" +{ + cat "${PARM_LM}/lis.crd.T${grid}.tmp.1" + echo "LIS%t%SSS = 0 " + echo "LIS%t%SMN = 00 " + echo "LIS%t%SHR = ${hh1} " + echo "LIS%t%SDA = ${dd1} " + echo "LIS%t%SMO = ${mm1} " + echo "LIS%t%SYR = ${yyyy1}" + echo "LIS%t%ENDCODE = 1 " + echo "LIS%t%ESS = 0 " + echo "LIS%t%EMN = 00 " + echo "LIS%t%EHR = ${hh2} " + echo "LIS%t%EDA = ${dd2} " + echo "LIS%t%EMO = ${mm2} " + echo "LIS%t%EYR = ${yyyy2}" + cat "${PARM_LM}/lis.crd.T${grid}.tmp.2" +} >> "${LISCARD}" exit 0 diff --git a/ush/gldas_process_data.sh b/ush/gldas_process_data.sh index 2866cfc78f..4770170a97 100755 --- a/ush/gldas_process_data.sh +++ b/ush/gldas_process_data.sh @@ -1,12 +1,12 @@ #! /usr/bin/env bash -source "${HOMEgfs:?}/ush/preamble.sh" +source "${HOMEgfs:?}/ush/preamble.sh" "$1" -rflux=$1 -fcsty=$2 -fflux=$3 -gflux=$4 -f=$5 +rflux=$2 +fcsty=$3 +fflux=$4 +gflux=$5 +f=$6 WGRIB2=${WGRIB2:?} CNVGRIB=${CNVGRIB:?} From dbf588dce297f99780e3b6a0cf6dccb53e6dc8d3 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 19 Sep 2022 11:36:05 -0500 Subject: [PATCH 32/36] Address linter warnings in config.fcst for SC2108 Refs #1014 --- parm/config/config.fcst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parm/config/config.fcst b/parm/config/config.fcst index 644d7a8589..6a57a804a5 100755 --- a/parm/config/config.fcst +++ b/parm/config/config.fcst @@ -147,7 +147,7 @@ export d2_bg_k1=0.20 export d2_bg_k2=0.04 export dz_min=6 export n_sponge=42 -if [[ "$LEVS" = "128" -a "$CDUMP" = "gdas" ]]; then +if [[ "$LEVS" = "128" && "$CDUMP" = "gdas" ]]; then export tau=5.0 export rf_cutoff=1.0e3 export d2_bg_k1=0.20 @@ -283,7 +283,7 @@ export USE_COUPLER_RES="NO" if [[ "$CDUMP" == "gdas" ]] ; then # GDAS cycle specific parameters # Variables used in DA cycling - if [[ "$QUILTING" = ".true." -a "$OUTPUT_GRID" = "gaussian_grid" ]]; then + if [[ "$QUILTING" = ".true." && "$OUTPUT_GRID" = "gaussian_grid" ]]; then export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_da" else export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_da_orig" @@ -313,7 +313,7 @@ if [[ "$CDUMP" == "gdas" ]] ; then # GDAS cycle specific parameters elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters # Write more variables to output - if [[ "$QUILTING" = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]]; then + if [[ "$QUILTING" = ".true." && $OUTPUT_GRID = "gaussian_grid" ]]; then export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table" else export DIAG_TABLE="$HOMEgfs/parm/parm_fv3diag/diag_table_orig" @@ -341,9 +341,9 @@ elif [[ "$CDUMP" == "gfs" ]] ; then # GFS cycle specific parameters export restart_interval="$STEP_GFS $restart_interval" fi fi - + # Choose coupling with wave - if [[ "$DO_WAVE" = "YES" -a "$WAVE_CDUMP" != "gdas" ]]; then + if [[ "$DO_WAVE" = "YES" && "$WAVE_CDUMP" != "gdas" ]]; then export cplwav=".true." fi From e0e271a587613037fcab1ba46a12c39e632e34da Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 19 Sep 2022 11:46:12 -0500 Subject: [PATCH 33/36] Add shellcheck disable for SC1091 in JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index a60a04fe36..dde1088e54 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -11,8 +11,9 @@ export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config} configs="base gldas" config_path=${EXPDIR:-${NWROOT}/gfs.${gfs_ver}/parm/config} for config in ${configs}; do - # shellcheck source=parm/config/config.${config} + # shellcheck disable=SC1091 . "${config_path}/config.${config}" + # shellcheck disable= status=$? [[ ${status} -ne 0 ]] && exit "${status}" done @@ -34,8 +35,9 @@ fi ########################################## # Source machine runtime environment ########################################## -# shellcheck source=env/WCOSS2.env +# shellcheck disable=SC1091 . "${HOMEgfs}/env/${machine:?}.env" gldas +# shellcheck disable= status=$? [[ ${status} -ne 0 ]] && exit "${status}" From f53f1ee57a11161570f007b7203ad71df9218357 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Mon, 19 Sep 2022 11:51:15 -0500 Subject: [PATCH 34/36] Also disable SC1090 in JGDAS_ATMOS_GLDAS Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index dde1088e54..f392299aea 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -11,7 +11,7 @@ export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config} configs="base gldas" config_path=${EXPDIR:-${NWROOT}/gfs.${gfs_ver}/parm/config} for config in ${configs}; do - # shellcheck disable=SC1091 + # shellcheck disable=SC1090-SC1091 . "${config_path}/config.${config}" # shellcheck disable= status=$? @@ -35,7 +35,7 @@ fi ########################################## # Source machine runtime environment ########################################## -# shellcheck disable=SC1091 +# shellcheck disable=SC1090-SC1091 . "${HOMEgfs}/env/${machine:?}.env" gldas # shellcheck disable= status=$? From 2aa8d5118032302d41191aaa681538bae12fb2c5 Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Tue, 20 Sep 2022 14:38:02 -0500 Subject: [PATCH 35/36] Indent while loops in GLDAS scripts - Add missing indentation into ush/gldas_forcing.sh and ush/gldas_get_data.sh. Refs #1014 --- ush/gldas_forcing.sh | 168 +++++++++++++++++++++--------------------- ush/gldas_get_data.sh | 48 ++++++------ 2 files changed, 107 insertions(+), 109 deletions(-) diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh index ae4f56cd03..ca5562f459 100755 --- a/ush/gldas_forcing.sh +++ b/ush/gldas_forcing.sh @@ -25,95 +25,93 @@ export ERRSCRIPT=${ERRSCRIPT:-"eval [[ ${err} = 0 ]]"} sdate=${bdate} edate=$(sh "${FINDDATE:?}" "${edate}" d-1) while [[ "${sdate}" -lt "${edate}" ]] ; do -#------------------------------- -sdat0=$(sh "${FINDDATE:?}" "${sdate}" d-1) -[[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p "${xpath}/cpc.${sdate}" -[[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p "${xpath}/cpc.${sdat0}" + sdat0=$(sh "${FINDDATE:?}" "${sdate}" d-1) + [[ ! -d ${xpath}/cpc.${sdate} ]] && mkdir -p "${xpath}/cpc.${sdate}" + [[ ! -d ${xpath}/cpc.${sdat0} ]] && mkdir -p "${xpath}/cpc.${sdat0}" -cd "${xpath}" || exit -rm -f fort.* grib.* + cd "${xpath}" || exit + rm -f fort.* grib.* -COMPONENT=${COMPONENT:-"atmos"} -pathp1=${CPCGAUGE:?}/gdas.${sdate}/00/${COMPONENT} -pathp2=${DCOMIN:?}/${sdate}/wgrbbul/cpc_rcdas -cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" -if [[ "${RUN_ENVIR:?}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then + COMPONENT=${COMPONENT:-"atmos"} + pathp1=${CPCGAUGE:?}/gdas.${sdate}/00/${COMPONENT} + pathp2=${DCOMIN:?}/${sdate}/wgrbbul/cpc_rcdas + cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT" + if [[ "${RUN_ENVIR:?}" = "emc" ]] && [[ "${sdate}" -gt "${bdate}" ]]; then cpc_precip="PRCP_CU_GAUGE_V1.0GLB_0.125deg.lnx.${sdate}.RT_early" -fi -cpc=${pathp1}/${cpc_precip} -if [[ ! -s "${cpc}" ]]; then cpc=${pathp2}/${cpc_precip} ; fi -if [[ "${RUN_ENVIR:?}" = "nco" ]]; then cpc=${pathp2}/${cpc_precip} ; fi -if [[ ! -s "${cpc}" ]]; then - echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." - exit 3 -fi -cp "${cpc}" "${xpath}/cpc.${sdate}/." - -sflux=${fpath}/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 -prate=gdas.${sdat0}12 -${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" - -sflux=${fpath}/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 -prate=gdas.${sdat0}18 -${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" - -sflux=${fpath}/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 -prate=gdas.${sdate}00 -${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" - -sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 -prate=gdas.${sdate}06 -${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" - -if [[ "${USE_CFP:?}" = "YES" ]] ; then - rm -f ./cfile - touch ./cfile - { - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" - echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" - } >> ./cfile - ${APRUN_GLDAS_DATA_PROC:?} ./cfile -else - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"12 grib.12 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"18 grib.18 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"00 grib.00 - ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"06 grib.06 -fi - -rm -f fort.10 -touch fort.10 -echo "${sdat0}" >> fort.10 -echo "${sdate}" >> fort.10 - -export pgm=gldas_forcing -# shellcheck disable=SC1091 -. prep_step -# shellcheck disable= - -${WGRIB} -d -bin grib.12 -o fort.11 -${WGRIB} -d -bin grib.18 -o fort.12 -${WGRIB} -d -bin grib.00 -o fort.13 -${WGRIB} -d -bin grib.06 -o fort.14 - -ln -fs "${xpath}/cpc.${sdate}/${cpc_precip}" fort.15 - -"${EXECgldas:?}/gldas_forcing" 1>&1 2>&2 - -export err=$? -${ERRSCRIPT} || exit 3 - -cp fort.21 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}12" -cp fort.22 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}18" -cp fort.23 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}00" -cp fort.24 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}06" - -rm -f fort.* grib.* - -#------------------------------- -sdate=$(sh "${FINDDATE}" "${sdate}" d+1) + fi + cpc=${pathp1}/${cpc_precip} + if [[ ! -s "${cpc}" ]]; then cpc=${pathp2}/${cpc_precip} ; fi + if [[ "${RUN_ENVIR:?}" = "nco" ]]; then cpc=${pathp2}/${cpc_precip} ; fi + if [[ ! -s "${cpc}" ]]; then + echo "WARNING: GLDAS MISSING ${cpc}, WILL NOT RUN." + exit 3 + fi + cp "${cpc}" "${xpath}/cpc.${sdate}/." + + sflux=${fpath}/gdas.${sdat0}/gdas1.t12z.sfluxgrbf06 + prate=gdas.${sdat0}12 + ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" + + sflux=${fpath}/gdas.${sdat0}/gdas1.t18z.sfluxgrbf06 + prate=gdas.${sdat0}18 + ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" + + sflux=${fpath}/gdas.${sdate}/gdas1.t00z.sfluxgrbf06 + prate=gdas.${sdate}00 + ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" + + sflux=${fpath}/gdas.${sdate}/gdas1.t06z.sfluxgrbf06 + prate=gdas.${sdate}06 + ${WGRIB} -s "${sflux}" | grep "PRATE:sfc" | ${WGRIB} -i "${sflux}" -grib -o "${prate}" + + if [[ "${USE_CFP:?}" = "YES" ]] ; then + rm -f ./cfile + touch ./cfile + { + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}12 grib.12" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdat0}18 grib.18" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}00 grib.00" + echo "${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas.${sdate}06 grib.06" + } >> ./cfile + ${APRUN_GLDAS_DATA_PROC:?} ./cfile + else + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"12 grib.12 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdat0}"18 grib.18 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"00 grib.00 + ${COPYGB} -i3 '-g255 0 2881 1441 90000 0 128 -90000 360000 125 125' -x gdas."${sdate}"06 grib.06 + fi + + rm -f fort.10 + touch fort.10 + echo "${sdat0}" >> fort.10 + echo "${sdate}" >> fort.10 + + export pgm=gldas_forcing + # shellcheck disable=SC1091 + . prep_step + # shellcheck disable= + + ${WGRIB} -d -bin grib.12 -o fort.11 + ${WGRIB} -d -bin grib.18 -o fort.12 + ${WGRIB} -d -bin grib.00 -o fort.13 + ${WGRIB} -d -bin grib.06 -o fort.14 + + ln -fs "${xpath}/cpc.${sdate}/${cpc_precip}" fort.15 + + "${EXECgldas:?}/gldas_forcing" 1>&1 2>&2 + + export err=$? + ${ERRSCRIPT} || exit 3 + + cp fort.21 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}12" + cp fort.22 "${xpath}/cpc.${sdat0}/precip.gldas.${sdat0}18" + cp fort.23 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}00" + cp fort.24 "${xpath}/cpc.${sdate}/precip.gldas.${sdate}06" + + rm -f fort.* grib.* + + sdate=$(sh "${FINDDATE}" "${sdate}" d+1) done #------------------------------- diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh index eb2891643e..3416309119 100755 --- a/ush/gldas_get_data.sh +++ b/ush/gldas_get_data.sh @@ -29,40 +29,40 @@ iter=0 #------------------------------- while [[ "${cdate}" -lt "${edate}" ]]; do -#------------------------------- + ymd=$(echo "${cdate}" |cut -c 1-8) cyc=$(echo "${cdate}" |cut -c 9-10) [[ ! -d ${fpath}/gdas.${ymd} ]] && mkdir -p "${fpath}/gdas.${ymd}" [[ ! -d ${gpath}/gdas.${ymd} ]] && mkdir -p "${gpath}/gdas.${ymd}" -f=1 -while [[ "${f}" -le "${cycint}" ]]; do - rflux=${COMINgdas:?}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 - fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 - gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} - if [[ ! -s "${rflux}" ]];then - echo "WARNING: GLDAS MISSING ${rflux}, WILL NOT RUN." - exit 2 - fi - rm -f "${fflux}" "${gflux}" - touch "${fflux}" "${gflux}" + f=1 + while [[ "${f}" -le "${cycint}" ]]; do + rflux=${COMINgdas:?}/gdas.${ymd}/${cyc}/${COMPONENT}/gdas.t${cyc}z.sfluxgrbf00${f}.grib2 + fflux=${fpath}/gdas.${ymd}/gdas.t${cyc}z.sfluxgrbf0${f}.grib2 + gflux=${gpath}/gdas.${ymd}/gdas1.t${cyc}z.sfluxgrbf0${f} + if [[ ! -s "${rflux}" ]];then + echo "WARNING: GLDAS MISSING ${rflux}, WILL NOT RUN." + exit 2 + fi + rm -f "${fflux}" "${gflux}" + touch "${fflux}" "${gflux}" - fcsty=anl - if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi + fcsty=anl + if [[ "${f}" -ge 1 ]]; then fcsty=fcst; fi - if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then - if [[ "${CFP_MP:-"NO"}" = "YES" ]]; then - echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; then + if [[ "${CFP_MP:-"NO"}" = "YES" ]]; then + echo "${iter} ${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + else + echo "${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + fi else - echo "${USHgldas:?}/gldas_process_data.sh ${iter} ${rflux} ${fcsty} ${fflux} ${gflux} ${f}" >> ./cfile + "${USHgldas:?}/gldas_process_data.sh" "${iter}" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" fi - else - "${USHgldas:?}/gldas_process_data.sh" "${iter}" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" - fi - iter=$((iter+1)) - f=$((f+1)) -done + iter=$((iter+1)) + f=$((f+1)) + done #------------------------------- cdate=$(${NDATE} +"${cycint}" "${cdate}") From 37d869e7f6e4f914d95a8ec3e564f488c248a2af Mon Sep 17 00:00:00 2001 From: "kate.friedman" Date: Thu, 22 Sep 2022 10:07:10 -0500 Subject: [PATCH 36/36] Provide exit code values in JGDAS_ATMOS_GLDAS - Provide a value of "1" for new exit statements in GLDAS JJOB script. Refs #1014 --- jobs/JGDAS_ATMOS_GLDAS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS index f392299aea..2c09f83b6d 100755 --- a/jobs/JGDAS_ATMOS_GLDAS +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -50,7 +50,7 @@ export outid=${outid:-"LL${job}"} export DATA=${DATA:-${DATAROOT}/${jobid:?}} mkdir -p "${DATA}" -cd "${DATA}" || exit +cd "${DATA}" || exit 1 ############################################## @@ -129,7 +129,7 @@ fi ########################################## # Remove the Temporary working directory ########################################## -cd "${DATAROOT}" || exit +cd "${DATAROOT}" || exit 1 [[ ${KEEPDATA:?} = "NO" ]] && rm -rf "${DATA}" exit 0