Skip to content

Commit 37168f3

Browse files
v17: Use DATAROOT space for gsidiags in dev/gfs.v17 (#4537)
This will bring in PRs #4476 and #4487 to the dev/gfs.v17 branch to enable the use of DATAROOT space for gsi diagnostic files, which allows easy use of links rather than sending a tarball to COM.
1 parent 8f3142d commit 37168f3

7 files changed

Lines changed: 141 additions & 16 deletions

File tree

dev/jobs/JGLOBAL_ATMOS_ANALYSIS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ RUN=${GDUMP} YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
3636
MEMDIR='ensstat' RUN=${GDUMP_ENS} YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
3737
COMIN_ATMOS_HISTORY_ENS_PREV:COM_ATMOS_HISTORY_TMPL
3838

39+
# shellcheck disable=SC2153
3940
mkdir -p "${COMOUT_ATMOS_ANALYSIS}"
4041

4142
export ATMGES="${COMIN_ATMOS_HISTORY_PREV}/${GPREFIX}atm.f006.nc"
@@ -45,6 +46,15 @@ if [[ ! -f "${ATMGES}" ]]; then
4546
err_exit "FILE MISSING: ATMGES == ${ATMGES}"
4647
fi
4748

49+
export GENDIAG="${GENDIAG:-YES}"
50+
51+
# Create a DATAROOT directory variable for the gsidiags if GENDIAG is YES
52+
if [[ "${GENDIAG}" == "YES" ]]; then
53+
# shellcheck disable=SC2311
54+
pCOMOUT_ATMOS_ANALYSIS="$(dataroot_com_path "${COMOUT_ATMOS_ANALYSIS}")"
55+
export pCOMOUT_ATMOS_ANALYSIS
56+
fi
57+
4858
# Get LEVS
4959
export LEVS
5060
LEVS=$(${NCLEN} "${ATMGES}" pfull) && true

dev/jobs/JGLOBAL_ATMOS_ANALYSIS_DIAG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
2626
COMOUT_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL
2727
mkdir -m 775 -p "${COMOUT_ATMOS_ANALYSIS}"
2828

29+
# Create a DATAROOT directory variable where the gsidiags live
30+
# shellcheck disable=SC2153,SC2311
31+
pCOMIN_ATMOS_ANALYSIS="$(dataroot_com_path "${COMIN_ATMOS_ANALYSIS}")"
32+
export pCOMIN_ATMOS_ANALYSIS
33+
2934
###############################################################
3035
# Run relevant script
3136
${ANALDIAGSH:-${SCRgfs}/exglobal_diag.sh} && true

dev/jobs/JGLOBAL_ENKF_DIAG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ MEMDIR="ensstat" YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
2929
COMIN_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL \
3030
COMOUT_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL
3131

32+
# Create a DATAROOT directory variable where the gsidiags live
33+
# shellcheck disable=SC2153,SC2311
34+
pCOMIN_ATMOS_ANALYSIS="$(dataroot_com_path "${COMIN_ATMOS_ANALYSIS}")"
35+
export pCOMIN_ATMOS_ANALYSIS
36+
3237
#RUN=${GDUMP} YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
3338
# COMIN_OBS_PREV:COM_OBS_TMPL \
3439
# COMIN_ATMOS_ANALYSIS_DET_PREV:COM_ATMOS_ANALYSIS_TMPL

dev/jobs/JGLOBAL_ENKF_SELECT_OBS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUN=${RUN/enkf/} YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
2828
COMIN_OBS:COM_OBS_TMPL
2929
MEMDIR='ensstat' YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
3030
COMOUT_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL
31+
# shellcheck disable=SC2153
3132
declare -rx COMOUT_ATMOS_ANALYSIS_ENS="${COMOUT_ATMOS_ANALYSIS}"
3233

3334
RUN=${RUN/enkf/} YMD=${PDY} HH=${cyc} declare_from_tmpl -r \
@@ -40,6 +41,7 @@ MEMDIR='ensstat' RUN=${GDUMP_ENS} YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
4041
RUN="${GDUMP}" YMD=${gPDY} HH=${gcyc} declare_from_tmpl -r \
4142
COMIN_ATMOS_ANALYSIS_DET_PREV:COM_ATMOS_ANALYSIS_TMPL
4243

44+
# shellcheck disable=SC2153
4345
mkdir -p "${COMOUT_ATMOS_ANALYSIS}"
4446

4547
export ATMGES_ENSMEAN="${COMIN_ATMOS_HISTORY_PREV}/${GPREFIX}${GSUFFIX}atm.f006.nc"
@@ -48,6 +50,15 @@ if [[ ! -f ${ATMGES_ENSMEAN} ]]; then
4850
err_exit "FILE MISSING: ATMGES_ENSMEAN == ${ATMGES_ENSMEAN}"
4951
fi
5052

53+
export GENDIAG="${GENDIAG:-YES}"
54+
55+
# Create a DATAROOT directory variable for the gsidiags if GENDIAG is YES
56+
if [[ "${GENDIAG}" == "YES" ]]; then
57+
# shellcheck disable=SC2311
58+
pCOMOUT_ATMOS_ANALYSIS="$(dataroot_com_path "${COMOUT_ATMOS_ANALYSIS}")"
59+
export pCOMOUT_ATMOS_ANALYSIS
60+
fi
61+
5162
LEVS=$(${NCLEN} "${ATMGES}" pfull) && true
5263
export err=$?
5364
set_strict

dev/scripts/exglobal_atmos_analysis.sh

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ else
410410
echo "not using correlated obs error"
411411
fi
412412

413+
# If GENDIAG is selected, verify that pCOMOUT_ATMOS_ANALYSIS is set
414+
if [[ "${GENDIAG}" == "YES" ]]; then
415+
if [[ -z "${pCOMOUT_ATMOS_ANALYSIS}" ]]; then
416+
export err=1
417+
err_exit "pCOMOUT_ATMOS_ANALYSIS must be set when GENDIAG=YES"
418+
fi
419+
# Make the gsidiags directory to house the GSI diagnostic data
420+
GSIDIAGDIR=${GSIDIAGDIR:-"${pCOMOUT_ATMOS_ANALYSIS}/gsidiags"}
421+
fi
422+
413423
##############################################################
414424
# CRTM Spectral and Transmittance coefficients
415425
mkdir -p crtm_coeffs
@@ -896,20 +906,36 @@ if [[ "${SENDECF}" == "YES" && "${RUN}" != "enkf" ]]; then
896906
ecflow_client --event release_fcst
897907
fi
898908

909+
# shellcheck disable=SC2312
910+
echo "${rCDUMP} ${PDY}${cyc} atminc done at $(date)" > "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}increment.done.txt"
911+
899912
# Diagnostic files
900913
# if requested, GSI diagnostic file directories for use later
901914
if [[ "${GENDIAG}" == "YES" ]]; then
902-
tar -cvf gsidiags.tar dir.????
903-
export err=$?
904-
if [[ ${err} -ne 0 ]]; then
905-
err_exit "Failed to tar GSI diagnostic directories!"
915+
# Move the gsidiags dir.* directories to pCOMOUT_ATMOS_ANALYSIS for diagnostic jobs
916+
# First, check that the directories exist (we need at least one, so stop after the first match)
917+
# shellcheck disable=SC2312
918+
count_dirs=$(find . -maxdepth 1 -type d -name 'dir.????' -printf "." -quit | wc -c)
919+
if [[ ${count_dirs:-0} -gt 0 ]]; then
920+
mkdir -p "${GSIDIAGDIR}"
921+
err=$?
922+
923+
if [[ ! -d "${GSIDIAGDIR}" || ${err} -ne 0 ]]; then
924+
err_exit "Failed to create gsidiags directory at ${GSIDIAGDIR}"
925+
fi
926+
927+
for dir in dir.????; do
928+
mv "${dir}" "${GSIDIAGDIR}/"
929+
export err=$?
930+
if [[ ${err} -ne 0 ]]; then
931+
err_exit "Failed to move ${dir} to ${GSIDIAGDIR}/"
932+
fi
933+
done
934+
else
935+
echo "WARNING: No gsidiags dir.* directories found to move."
906936
fi
907-
cpfs gsidiags.tar "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}gsidiags${DIAG_SUFFIX:-}.tar"
908937
fi
909938

910-
# shellcheck disable=SC2312
911-
echo "${rCDUMP} ${PDY}${cyc} atminc done at $(date)" > "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}increment.done.txt"
912-
913939
################################################################################
914940

915941
exit "${err}"

dev/scripts/exglobal_diag.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rm -f "${RADSTAT}" "${PCPSTAT}" "${CNVSTAT}" "${OZNSTAT}"
3939

4040
# Obs diag
4141
GENDIAG=${GENDIAG:-"YES"}
42-
GSIDIAG=${GSIDIAG:-"${COMIN_ATMOS_ANALYSIS}/${APREFIX}gsidiags${DIAG_SUFFIX:-}.tar"}
42+
GSIDIAGDIR=${GSIDIAGDIR:-"${pCOMIN_ATMOS_ANALYSIS}/gsidiags"}
4343
USE_BUILD_GSINFO=${USE_BUILD_GSINFO:-"NO"}
4444
DIAG_COMPRESS=${DIAG_COMPRESS:-"YES"}
4545
if [[ "${DIAG_COMPRESS:-}" == "YES" ]]; then
@@ -55,15 +55,33 @@ if [[ "${GENDIAG}" != "YES" ]]; then
5555
exit 0
5656
fi
5757

58+
# Check that the gsidiags directory exists
59+
60+
if [[ ! -d "${GSIDIAGDIR}" ]]; then
61+
export err=1
62+
err_exit "gsidiags directory ${GSIDIAGDIR} does not exist"
63+
fi
64+
5865
################################################################################
59-
# Copy gsidiags.tar file from COMIN to DATA and untar
60-
cpreq "${GSIDIAG}" ./gsidiags.tar
61-
tar -xvf gsidiags.tar
62-
export err=$?
63-
if [[ ${err} -ne 0 ]]; then
64-
err_exit "Unable to unpack gsidiags.tar file!"
66+
# Link to the gsidiags directory if it is populated
67+
# shellcheck disable=SC2312
68+
count_dirs=$(find "${GSIDIAGDIR}" -maxdepth 1 -type d -name "dir.*" | wc -l)
69+
if [[ ${count_dirs} -eq 0 ]]; then
70+
export err=1
71+
err_exit "No gsidiags directories found in ${GSIDIAGDIR}"
72+
fi
73+
74+
# Continue if there is at least one file to process
75+
# Note -quit stops find after the first match
76+
# shellcheck disable=SC2312
77+
count_files=$(find "${GSIDIAGDIR}"/dir.* -maxdepth 1 -type f -printf '.' -quit | wc -c)
78+
if [[ ${count_files} -eq 0 ]]; then
79+
echo "WARNING: No diagnostic files found to process!"
80+
exit 0
6581
fi
6682

83+
${NLN} "${GSIDIAGDIR}/"dir.* .
84+
6785
# Set up lists and variables for various types of diagnostic files.
6886
ntype=3
6987

ush/bash_utils.sh

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function declare_from_tmpl() {
3636
# MEMDIR='mem001' YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
3737
# COMOUT_ATMOS_HISTORY:COM_ATMOS_HISTORY_TMPL
3838
#
39-
if [[ ${DEBUG_WORKFLOW:-"NO"} == "NO" ]]; then set +x; fi
39+
if [[ ${DEBUG_WORKFLOW:-"NO"} == "NO" ]]; then
40+
set +x
41+
fi
4042
local opts="-g"
4143
local OPTIND=1
4244
while getopts "rx" option; do
@@ -110,6 +112,53 @@ function wait_for_file() {
110112
return 1
111113
}
112114

115+
# This utility is to be used to create a COM structure in the DATAROOT
116+
# It will replace the root path (up to $COMROOT) with $DATAROOT
117+
# Use realpath --relative-to to get the relative path from $COMROOT to the target file
118+
# and then prepend $DATAROOT to that path to get the new target path
119+
function dataroot_com_path() {
120+
#
121+
# Generate a COM path in the DATAROOT based on an existing COM path.
122+
#
123+
# This function takes an existing COM path and generates a corresponding
124+
# path in the DATAROOT by replacing the root directory with DATAROOT.
125+
#
126+
# Syntax:
127+
# dataroot_com_path original_com_path
128+
#
129+
# original_com_path: The original COM path to be transformed.
130+
#
131+
# Example:
132+
# # Declare COMOUT_ATMOS_ANALYSIS using template
133+
# YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \
134+
# COMOUT_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL
135+
# # Get the DATAROOT version of the COM path
136+
# pCOMOUT_ATMOS_ANALYSIS=$(dataroot_com_path "${COMOUT_ATMOS_ANALYSIS}")
137+
# echo "New COM path in DATAROOT: ${pCOMOUT_ATMOS_ANALYSIS}"
138+
#
139+
140+
set +x
141+
if [[ $# -ne 1 ]]; then
142+
echo "FATAL ERROR in dataroot_com_path: Incorrect number of arguments!"
143+
echo "Usage: dataroot_com_path original_com_path"
144+
exit 2
145+
fi
146+
147+
local original_com_path=${1}
148+
149+
if [[ -z "${COMROOT:-}" || -z "${DATAROOT:-}" ]]; then
150+
echo "FATAL ERROR in dataroot_com_path: COMROOT and DATAROOT must be defined!"
151+
exit 2
152+
fi
153+
154+
local relative_path
155+
relative_path=$(realpath --relative-to="${COMROOT}" "${original_com_path}")
156+
local new_com_path="${DATAROOT}/${relative_path}"
157+
158+
echo "${new_com_path}"
159+
set_trace
160+
}
161+
113162
# Initialize stacks for tick-tock profiling (initialize only once)
114163
if [[ -z ${_GW_TIMER_STACK+x} ]]; then
115164
declare -xa _GW_TIMER_STACK=()
@@ -198,5 +247,6 @@ tock() {
198247

199248
declare -xf declare_from_tmpl
200249
declare -xf wait_for_file
250+
declare -xf dataroot_com_path
201251
declare -xf tick
202252
declare -xf tock

0 commit comments

Comments
 (0)