Skip to content

Commit

Permalink
Address linter warnings and use iter as argument to gldas_process_dat…
Browse files Browse the repository at this point in the history
…a.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 NOAA-EMC#1014
  • Loading branch information
KateFriedman-NOAA committed Sep 19, 2022
1 parent 9a6a112 commit 38a5f98
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 61 deletions.
7 changes: 5 additions & 2 deletions jobs/JGDAS_ATMOS_GLDAS
Original file line number Diff line number Diff line change
Expand Up @@ -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'"}


###############################################################
Expand Down
62 changes: 31 additions & 31 deletions parm/config/config.fcst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ done
export domains_stack_size="16000000"


if [ $DONST = "YES" ]; then
if [[ "$DONST" = "YES" ]]; then
. $EXPDIR/config.nsst
fi

Expand All @@ -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

Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -300,28 +300,28 @@ 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."

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=""
Expand All @@ -335,35 +335,35 @@ 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"
fi
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

# Turn off dry mass adjustment in GFS
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"
fi

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) }' )
Expand Down
10 changes: 6 additions & 4 deletions ush/gldas_forcing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ush/gldas_get_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
32 changes: 17 additions & 15 deletions ush/gldas_liscrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions ush/gldas_process_data.sh
Original file line number Diff line number Diff line change
@@ -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:?}
Expand Down

0 comments on commit 38a5f98

Please sign in to comment.