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 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/jobs/JGDAS_ATMOS_GLDAS b/jobs/JGDAS_ATMOS_GLDAS new file mode 100755 index 0000000000..2c09f83b6d --- /dev/null +++ b/jobs/JGDAS_ATMOS_GLDAS @@ -0,0 +1,136 @@ +#! /usr/bin/env bash + +source "${HOMEgfs:?}/ush/preamble.sh" + +export RUN_ENVIR=${RUN_ENVIR:-"nco"} + +############################# +# 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 + # shellcheck disable=SC1090-SC1091 + . "${config_path}/config.${config}" + # shellcheck disable= + 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 + +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" + echo "starting from ${SDATE}. This gldas cycle is skipped" + exit 0 +fi + +########################################## +# Source machine runtime environment +########################################## +# shellcheck disable=SC1090-SC1091 +. "${HOMEgfs}/env/${machine:?}.env" gldas +# shellcheck disable= +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}" || exit 1 + + +############################################## +# Run setpdy and initialize PDY variables +############################################## +export cycle="t${cyc}z" +setpdy.sh +# shellcheck disable=SC1091 +. ./PDY +# shellcheck disable= + + +############################################## +# 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 +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:-"${model} |tr 'a-z' 'A-Z'"} + + +############################################################### +# Run relevant exglobal script + +${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 + +########################################## +# Remove the Temporary working directory +########################################## +cd "${DATAROOT}" || exit 1 +[[ ${KEEPDATA:?} = "NO" ]] && rm -rf "${DATA}" + +exit 0 + 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..6a57a804a5 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" && "$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 @@ -252,9 +252,8 @@ 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 +if [[ "${FRAC_GRID:-".true."}" = ".false." ]]; then export cplmode="nems_orig" fi export psm_bc="1" @@ -284,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" @@ -301,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." @@ -314,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." && $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="" @@ -336,15 +335,15 @@ 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" && "$WAVE_CDUMP" != "gdas" ]]; then export cplwav=".true." fi @@ -352,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" @@ -360,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/scripts/exgdas_atmos_gldas.sh b/scripts/exgdas_atmos_gldas.sh new file mode 100755 index 0000000000..4cae6f83f5 --- /dev/null +++ b/scripts/exgdas_atmos_gldas.sh @@ -0,0 +1,337 @@ +#! /usr/bin/env bash + +################################################################################ +#### UNIX Script Documentation Block +# . . +# Script name: exgdas_atmos_gldas.sh +# Script description: Runs the global land analysis +# +################################################################################ + +source "${HOMEgfs:?}/ush/preamble.sh" + +################################# +# 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} + +# 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)) + iau_cdate=$(${NDATE} -"${IAUHALH}" "${CDATE}") +fi +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}" + +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/fix_gldas} +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 "${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 +#--------------------------------------------------------------- + +"${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} 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) +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 +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= +${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 +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= +"${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 +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= +${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 +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= +${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 +# 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" + + +# 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 +# shellcheck disable=SC1091 +. prep_step +# shellcheck disable= +${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 + +exit "${err}" + 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 #----------------------------------- diff --git a/ush/gldas_forcing.sh b/ush/gldas_forcing.sh new file mode 100755 index 0000000000..ca5562f459 --- /dev/null +++ b/ush/gldas_forcing.sh @@ -0,0 +1,118 @@ +#! /usr/bin/env bash +########################################################################### +# this script gets cpc daily precipitation and using gdas hourly precipitation +# to disaggregate daily value into hourly value +########################################################################### + +source "${HOMEgfs:?}/ush/preamble.sh" + +bdate=$1 +edate=$2 + +# 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 WGRIB=${WGRIB:?} +export COPYGB=${COPYGB:?} +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}" || 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 + 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) +done +#------------------------------- + +exit "${err}" diff --git a/ush/gldas_get_data.sh b/ush/gldas_get_data.sh new file mode 100755 index 0000000000..3416309119 --- /dev/null +++ b/ush/gldas_get_data.sh @@ -0,0 +1,76 @@ +#! /usr/bin/env bash +######################################################### +# This script generate gldas forcing from gdas prod sflux +######################################################### + +source "${HOMEgfs:?}/ush/preamble.sh" + +bdate=$1 +edate=$2 + +if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; 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 [[ "${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 + "${USHgldas:?}/gldas_process_data.sh" "${iter}" "${rflux}" "${fcsty}" "${fflux}" "${gflux}" "${f}" + fi + + iter=$((iter+1)) + f=$((f+1)) + done + +#------------------------------- + cdate=$(${NDATE} +"${cycint}" "${cdate}") +done +#------------------------------- + +if [[ "${USE_CFP:-"NO"}" = "YES" ]] ; 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..7c0f446035 --- /dev/null +++ b/ush/gldas_liscrd.sh @@ -0,0 +1,46 @@ +#! /usr/bin/env bash + +source "${HOMEgfs:?}/ush/preamble.sh" + +if [[ $# -lt 3 ]]; then + echo usage "$0" yyyymmddhh1 yyyymmddhh2 126/382/574/1534 + exit $? +fi + +date1=$1 +date2=$2 +grid=$3 + +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) + +PARM_LM=${PARMgldas:?} +LISCARD=lis.crd + +rm -f "${LISCARD}" +touch "${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 new file mode 100755 index 0000000000..4770170a97 --- /dev/null +++ b/ush/gldas_process_data.sh @@ -0,0 +1,34 @@ +#! /usr/bin/env bash + +source "${HOMEgfs:?}/ush/preamble.sh" "$1" + +rflux=$2 +fcsty=$3 +fflux=$4 +gflux=$5 +f=$6 + +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}" +${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}" + +${CNVGRIB} -g21 "${fflux}" "${gflux}" + +exit $?