Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IAU to snow DA (and its test) #2610

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b0656aa
start to add new task
CoryMartin-NOAA May 9, 2024
d16119d
add new j-job
CoryMartin-NOAA May 9, 2024
b4c97f8
Save to do some initial testing
CoryMartin-NOAA May 9, 2024
3667349
more updates
CoryMartin-NOAA May 9, 2024
accc4f4
Merge branch 'NOAA-EMC:develop' into feature/snow-ensemble
CoryMartin-NOAA May 14, 2024
e565f21
Merge branch 'develop' into feature/snow-ensemble
CoryMartin-NOAA May 16, 2024
81b7b6e
end of day commit
CoryMartin-NOAA May 16, 2024
3aaa8f6
End of day/week commit
CoryMartin-NOAA May 17, 2024
7085716
Merge branch 'NOAA-EMC:develop' into feature/snow-ensemble
CoryMartin-NOAA May 17, 2024
29641b2
save
CoryMartin-NOAA May 20, 2024
531136a
Merge branch 'feature/snow-ensemble' of https://github.com/CoryMartin…
CoryMartin-NOAA May 20, 2024
c124a41
Pull ensemble snow DA work out of this branch
CoryMartin-NOAA May 20, 2024
9d53f4b
turn on iau
CoryMartin-NOAA May 20, 2024
ad566e0
make norm happy again
CoryMartin-NOAA May 20, 2024
fae970d
Apply suggestions from code review
CoryMartin-NOAA May 20, 2024
5612d23
address great reviewer comments
CoryMartin-NOAA May 21, 2024
aa638e8
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA May 22, 2024
0d0bfa1
Merge branch 'develop' into feature/snow-iau
aerorahul May 24, 2024
30bd93e
clean-up exglobal_atmos_sfcanl.sh and update the j-job for COMIN/COMOUT
aerorahul May 24, 2024
a625a11
shellcheck j-job
aerorahul May 24, 2024
15ec7f1
shellcheck exscript
aerorahul May 24, 2024
d4a2d97
Merge pull request #2 from aerorahul/patch/2610
CoryMartin-NOAA May 24, 2024
33e3d7c
Apply suggestions from code review
aerorahul May 24, 2024
9f0b727
Apply suggestions from code review
aerorahul May 24, 2024
ea7a371
Apply suggestions from code review
aerorahul May 24, 2024
840150b
Update exglobal_atmos_sfcanl.sh
CoryMartin-NOAA May 28, 2024
50d8d23
Update exglobal_atmos_sfcanl.sh
CoryMartin-NOAA May 28, 2024
57c7811
Merge branch 'develop' into feature/snow-iau
aerorahul May 28, 2024
6c05085
Merge branch 'develop' into feature/snow-iau
WalterKolczynski-NOAA May 28, 2024
8992431
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA May 31, 2024
e870421
Merge branch 'develop' into feature/snow-iau
CoryMartin-NOAA Jun 3, 2024
3e5eea6
Revert CDATE for IAU beginning of window
CoryMartin-NOAA Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/cases/yamls/atmaerosnowDA_defaults_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defaults:
!INC {{ HOMEgfs }}/parm/config/gfs/yaml/defaults.yaml
base:
DOIAU: "NO"
DO_JEDISNOWDA: "YES"
ACCOUNT: {{ 'HPC_ACCOUNT' | getenv }}
41 changes: 18 additions & 23 deletions jobs/JGLOBAL_ATMOS_SFCANL
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,35 @@ source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" -e "sfcanl" -c "base sfcanl"


##############################################
# Set variables used in the script
##############################################
export CDUMP="${RUN/enkf}"


##############################################
# Begin JOB SPECIFIC work
##############################################
# Ignore possible spelling error (nothing is misspelled)
# shellcheck disable=SC2153
GDATE=$(${NDATE} -"${assim_freq}" "${PDY}${cyc}")
# shellcheck disable=
gPDY=${GDATE:0:8}
gcyc=${GDATE:8:2}
export GDUMP="gdas"
GDATE=$(date --utc -d "${PDY} ${cyc} - ${assim_freq} hours" +%Y%m%d%H)
export GDATE

RUN="gdas" YMD=${GDATE:0:8} HH=${GDATE:8:2} declare_from_tmpl -rx \
COMIN_OBS_PREV:COM_OBS_TMPL \
COMIN_ATMOS_RESTART_PREV:COM_ATMOS_RESTART_TMPL

YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
COMIN_OBS:COM_OBS_TMPL \
COMIN_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL \
COMIN_SNOW_ANALYSIS:COM_SNOW_ANALYSIS_TMPL

export OPREFIX="${CDUMP}.t${cyc}z."
export GPREFIX="${GDUMP}.t${gcyc}z."
export APREFIX="${CDUMP}.t${cyc}z."
YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
COMOUT_ATMOS_RESTART:COM_ATMOS_RESTART_TMPL

YMD=${PDY} HH=${cyc} declare_from_tmpl -rx COM_OBS COM_ATMOS_ANALYSIS COM_ATMOS_RESTART \
COM_SNOW_ANALYSIS
mkdir -p "${COMOUT_ATMOS_RESTART}"

RUN=${GDUMP} YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
COM_OBS_PREV:COM_OBS_TMPL \
COM_ATMOS_RESTART_PREV:COM_ATMOS_RESTART_TMPL

###############################################################
# Run relevant script

${SFCANALSH:-${SCRgfs}/exglobal_atmos_sfcanl.sh}
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
(( status != 0 )) && exit "${status}"


##############################################
Expand All @@ -48,14 +43,14 @@ status=$?
# Final processing
##############################################
if [[ -e "${pgmout}" ]] ; then
cat ${pgmout}
cat "${pgmout}"
fi

##########################################
# Remove the Temporary working directory
##########################################
cd ${DATAROOT}
[[ ${KEEPDATA} = "NO" ]] && rm -rf ${DATA}
cd "${DATAROOT}"
[[ "${KEEPDATA}" == "NO" ]] && rm -rf "${DATA}"


exit 0
223 changes: 76 additions & 147 deletions scripts/exglobal_atmos_sfcanl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,198 +22,127 @@
source "${USHgfs}/preamble.sh"

# Directories.
pwd=$(pwd)
cd "${DATA}" || exit 99

# Derived base variables
# Ignore possible spelling error (nothing is misspelled)
# shellcheck disable=SC2153
GDATE=$(${NDATE} -"${assim_freq}" "${PDY}${cyc}")
BDATE=$(${NDATE} -3 "${PDY}${cyc}")
bPDY=${BDATE:0:8}
bcyc=${BDATE:8:2}

# Utilities
export CHGRP_CMD=${CHGRP_CMD:-"chgrp ${group_name:-rstprod}"}
export NCLEN=${NCLEN:-${USHgfs}/getncdimlen}
COMPRESS=${COMPRESS:-gzip}
UNCOMPRESS=${UNCOMPRESS:-gunzip}
APRUNCFP=${APRUNCFP:-""}

# IAU
DOIAU=${DOIAU:-"NO"}
export IAUFHRS=${IAUFHRS:-"6"}

# Surface cycle related parameters
# Dependent Scripts and Executables
CYCLESH=${CYCLESH:-${USHgfs}/global_cycle.sh}
export CYCLEXEC=${CYCLEXEC:-${EXECgfs}/global_cycle}
NTHREADS_CYCLE=${NTHREADS_CYCLE:-24}
APRUN_CYCLE=${APRUN_CYCLE:-${APRUN:-""}}

# Surface cycle related parameters
export SNOW_NUDGE_COEFF=${SNOW_NUDGE_COEFF:-'-2.'}
export CYCLVARS=${CYCLVARS:-""}
export FHOUR=${FHOUR:-0}
export DELTSFC=${DELTSFC:-6}

# FV3 specific info (required for global_cycle)
export CASE=${CASE:-"C384"}
ntiles=${ntiles:-6}

# IAU
DOIAU=${DOIAU:-"NO"}
export IAUFHRS=${IAUFHRS:-"6"}

# Dependent Scripts and Executables
export NTHREADS_CALCINC=${NTHREADS_CALCINC:-1}
export APRUN_CALCINC=${APRUN_CALCINC:-${APRUN:-""}}
export APRUN_CALCANL=${APRUN_CALCANL:-${APRUN:-""}}
export APRUN_CHGRES=${APRUN_CALCANL:-${APRUN:-""}}

export CALCANLEXEC=${CALCANLEXEC:-${EXECgfs}/calc_analysis.x}
export CHGRESNCEXEC=${CHGRESNCEXEC:-${EXECgfs}/enkf_chgres_recenter_nc.x}
export CHGRESINCEXEC=${CHGRESINCEXEC:-${EXECgfs}/interp_inc.x}
export NTHREADS_CHGRES=${NTHREADS_CHGRES:-1}
CALCINCPY=${CALCINCPY:-${USHgfs}/calcinc_gfs.py}
CALCANLPY=${CALCANLPY:-${USHgfs}/calcanl_gfs.py}

export APRUN_CHGRES=${APRUN_CALCANL:-${APRUN:-""}}
CHGRESEXEC=${CHGRESEXEC:-${EXECgfs}/enkf_chgres_recenter.x}

# OPS flags
RUN=${RUN:-""}
SENDECF=${SENDECF:-"NO"}
SENDDBN=${SENDDBN:-"NO"}
# Other info used in this script
RUN_GETGES=${RUN_GETGES:-"NO"}
GETGESSH=${GETGESSH:-"getges.sh"}
export gesenvir=${gesenvir:-${envir}}
# Ignore possible spelling error (nothing is misspelled)
# shellcheck disable=SC2153
GPREFIX="gdas.t${GDATE:8:2}z."
OPREFIX="${RUN/enkf}.t${cyc}z."
APREFIX="${RUN/enkf}.t${cyc}z."

# Observations
OPREFIX=${OPREFIX:-""}
OSUFFIX=${OSUFFIX:-""}

# Guess files
GPREFIX=${GPREFIX:-""}
ntiles=6

# Analysis files
export APREFIX=${APREFIX:-""}
DTFANL=${DTFANL:-${COM_ATMOS_ANALYSIS}/${APREFIX}dtfanl.nc}

##############################################################
# Get dimension information based on CASE
res=$(echo ${CASE} | cut -c2-)
res="${CASE:1}"
JCAP_CASE=$((res*2-2))
LATB_CASE=$((res*2))
LONB_CASE=$((res*4))

################################################################################
# Preprocessing
mkdata=NO
if [[ ! -d ${DATA} ]]; then
mkdata=YES
mkdir -p ${DATA}
fi

cd ${DATA} || exit 99

if [[ ${DONST} = "YES" ]]; then
export NSSTBF="${COM_OBS}/${OPREFIX}nsstbufr"
${NLN} ${NSSTBF} nsstbufr
fi


##############################################################
# Required model guess files


##############################################################
# Output files
if [[ ${DONST} = "YES" ]]; then
${NLN} ${DTFANL} dtfanl
fi


##############################################################
# Update surface fields in the FV3 restart's using global_cycle
mkdir -p "${COM_ATMOS_RESTART}"

# Global cycle requires these files
export FNTSFA=${FNTSFA:-${COM_OBS}/${OPREFIX}rtgssthr.grb}
export FNACNA=${FNACNA:-${COM_OBS}/${OPREFIX}seaice.5min.blend.grb}
export FNSNOA=${FNSNOA:-${COM_OBS}/${OPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f ${FNSNOA} ]] && export FNSNOA="${COM_OBS}/${OPREFIX}snogrb_t1534.3072.1536"
FNSNOG=${FNSNOG:-${COM_OBS_PREV}/${GPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f ${FNSNOG} ]] && FNSNOG="${COM_OBS_PREV}/${GPREFIX}snogrb_t1534.3072.1536"
export FNTSFA=${FNTSFA:-${COMIN_OBS}/${OPREFIX}rtgssthr.grb}
export FNACNA=${FNACNA:-${COMIN_OBS}/${OPREFIX}seaice.5min.blend.grb}
export FNSNOA=${FNSNOA:-${COMIN_OBS}/${OPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f ${FNSNOA} ]] && export FNSNOA="${COMIN_OBS}/${OPREFIX}snogrb_t1534.3072.1536"
FNSNOG=${FNSNOG:-${COMIN_OBS_PREV}/${GPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f ${FNSNOG} ]] && FNSNOG="${COMIN_OBS_PREV}/${GPREFIX}snogrb_t1534.3072.1536"

# Set CYCLVARS by checking grib date of current snogrb vs that of prev cycle
if [[ ${RUN_GETGES} = "YES" ]]; then
snoprv=$(${GETGESSH} -q -t snogrb_${JCAP_CASE} -e ${gesenvir} -n ${GDUMP} -v ${GDATE})
snoprv=$(${GETGESSH} -q -t "snogrb_${JCAP_CASE}" -e "${gesenvir}" -n "${GDUMP}" -v "${GDATE}")
else
snoprv=${snoprv:-${FNSNOG}}
snoprv=${snoprv:-${FNSNOG}}
fi

if [[ $(${WGRIB} -4yr ${FNSNOA} 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') -le \
$(${WGRIB} -4yr ${snoprv} 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') ]] ; then
export FNSNOA=" "
export CYCLVARS="FSNOL=99999.,FSNOS=99999.,"
if [[ $(${WGRIB} -4yr "${FNSNOA}" 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') -le \
$(${WGRIB} -4yr "${snoprv}" 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') ]] ; then
export FNSNOA=" "
export CYCLVARS="FSNOL=99999.,FSNOS=99999.,"
else
export SNOW_NUDGE_COEFF=${SNOW_NUDGE_COEFF:-0.}
export CYCLVARS="FSNOL=${SNOW_NUDGE_COEFF},${CYCLVARS}"
export CYCLVARS="FSNOL=${SNOW_NUDGE_COEFF},${CYCLVARS}"
fi

if [[ ${DONST} = "YES" ]]; then
export NST_FILE=${GSI_FILE:-${COM_ATMOS_ANALYSIS}/${APREFIX}dtfanl.nc}
# determine where the input snow restart files come from
if [[ "${DO_JEDISNOWDA:-}" == "YES" ]]; then
sfcdata_dir="${COMIN_SNOW_ANALYSIS}"
else
export NST_FILE="NULL"
sfcdata_dir="${COMIN_ATMOS_RESTART_PREV}"
fi

if [[ ${DOIAU} = "YES" ]]; then
# update surface restarts at the beginning of the window, if IAU
# For now assume/hold dtfanl.nc valid at beginning of window
for n in $(seq 1 ${ntiles}); do
${NCP} "${COM_ATMOS_RESTART_PREV}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${bPDY}.${bcyc}0000.sfcanl_data.tile${n}.nc"
${NLN} "${COM_ATMOS_RESTART_PREV}/${bPDY}.${bcyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
${NLN} "${COM_ATMOS_RESTART}/${bPDY}.${bcyc}0000.sfcanl_data.tile${n}.nc" "${DATA}/fnbgso.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${n}.nc" "${DATA}/fngrid.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${n}.nc" "${DATA}/fnorog.00${n}"
done

export APRUNCY=${APRUN_CYCLE}
export OMP_NUM_THREADS_CY=${NTHREADS_CYCLE}
export MAX_TASKS_CY=${ntiles}

CDATE="${PDY}${cyc}" ${CYCLESH}
export err=$?; err_chk
fi

# Update surface restarts at middle of window
for n in $(seq 1 ${ntiles}); do
if [[ ${DO_JEDISNOWDA:-"NO"} = "YES" ]]; then
${NCP} "${COM_SNOW_ANALYSIS}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc"
else
${NCP} "${COM_ATMOS_RESTART_PREV}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" \
"${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc"
fi
${NLN} "${COM_ATMOS_RESTART_PREV}/${PDY}.${cyc}0000.sfc_data.tile${n}.nc" "${DATA}/fnbgsi.00${n}"
${NLN} "${COM_ATMOS_RESTART}/${PDY}.${cyc}0000.sfcanl_data.tile${n}.nc" "${DATA}/fnbgso.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${n}.nc" "${DATA}/fngrid.00${n}"
${NLN} "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${n}.nc" "${DATA}/fnorog.00${n}"
done

# global_cycle executable specific variables
export APRUNCY=${APRUN_CYCLE}
export OMP_NUM_THREADS_CY=${NTHREADS_CYCLE}
export MAX_TASKS_CY=${ntiles}

CDATE="${PDY}${cyc}" ${CYCLESH}
export err=$?; err_chk
# Copy fix files required by global_cycle to DATA just once
for (( nn=1; nn <= ntiles; nn++ )); do
${NCP} "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${nn}.nc" "${DATA}/fngrid.00${nn}"
${NCP} "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${nn}.nc" "${DATA}/fnorog.00${nn}"
done

# Copy the NSST analysis file for global_cycle
# There is only a single NSST analysis at the middle of the window
# For now use/assume it is the same at the beginning of the window if doing IAU
if [[ "${DONST}" == "YES" ]]; then
${NCP} "${COMIN_ATMOS_ANALYSIS}/${APREFIX}dtfanl.nc" "${DATA}/dtfanl"
export NST_FILE="dtfanl"
else
export NST_FILE="NULL"
fi

################################################################################
# Postprocessing
cd ${pwd}
[[ ${mkdata} = "YES" ]] && rm -rf ${DATA}
# Collect the dates in the window to update surface restarts
gcycle_dates=("${PDY}${cyc}") # Always update surface restarts at middle of window
if [[ "${DOIAU:-}" == "YES" ]]; then # Update surface restarts at beginning of window
half_window=$(( assim_freq / 2 ))
BDATE=$(date --utc -d "${PDY} ${cyc} - ${half_window} hours" +%Y%m%d%H)
gcycle_dates+=("${BDATE}")
fi

# Loop over the dates in the window to update the surface restarts
for gcycle_date in "${gcycle_dates[@]}"; do

echo "Updating surface restarts for ${gcycle_date} ..."

datestr="${gcycle_date:0:8}.${gcycle_date:8:2}0000"

# Copy inputs from COMIN to DATA
for (( nn=1; nn <= ntiles; nn++ )); do
${NCP} "${sfcdata_dir}/${datestr}.sfc_data.tile${nn}.nc" "${DATA}/fnbgsi.00${nn}"
${NCP} "${DATA}/fnbgsi.00${nn}" "${DATA}/fnbgso.00${nn}"
done

CDATE="${PDY}${cyc}" ${CYCLESH}
export err=$?; err_chk

# Copy outputs from DATA to COMOUT
for (( nn=1; nn <= ntiles; nn++ )); do
${NCP} "${DATA}/fnbgso.00${nn}" "${COMOUT_ATMOS_RESTART}/${datestr}.sfcanl_data.tile${nn}.nc"
done

done


################################################################################

exit ${err}
exit "${err}"

################################################################################
Loading
Loading