From 94a43fe965c174725420b7b148b20bb1e6b0e7ff Mon Sep 17 00:00:00 2001 From: David Huber Date: Mon, 9 Feb 2026 12:56:18 -0500 Subject: [PATCH 1/4] Create dir.* directories and link instead of moving --- dev/scripts/exglobal_atmos_analysis.sh | 35 ++++++++------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/dev/scripts/exglobal_atmos_analysis.sh b/dev/scripts/exglobal_atmos_analysis.sh index eb2d0e557ab..5a4634ccf39 100755 --- a/dev/scripts/exglobal_atmos_analysis.sh +++ b/dev/scripts/exglobal_atmos_analysis.sh @@ -670,6 +670,17 @@ if [[ "${USE_SELECT}" == "YES" ]]; then fi fi +# If diags are to be generated, create the gsi.* directories in GSIDIAGDIR and link them here. +# This will allow the GSI to write directly to the GSIDIAGDIR. +if [[ "${GENDIAG}" == "YES" ]]; then + # The number of directories is controlled by the number of tasks (one each) + for task in $(seq 1 "${NTASKS_GSI}"); do + dir="dir.$(printf %04d "${task}")" + mkdir -p "${GSIDIAGDIR}/${dir}" + ${NLN} "${GSIDIAGDIR}/${dir}" "./${dir}" + done +fi + ############################################################## # If requested, copy and de-tar guess radstat file if [[ "${USE_RADSTAT}" == "YES" ]]; then @@ -907,30 +918,6 @@ fi echo "${rCDUMP} ${PDY}${cyc} atminc done at $(date)" > "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}increment.done.txt" -if [[ "${GENDIAG}" == "YES" ]]; then - # Move the gsidiags dir.* directories to pCOMOUT_ATMOS_ANALYSIS for diagnostic jobs - # First, check that the directories exist (we need at least one, so stop after the first match) - count_dirs=$(find . -maxdepth 1 -type d -name 'dir.????' -printf "." -quit | wc -c) - if [[ ${count_dirs:-0} -gt 0 ]]; then - mkdir -p "${GSIDIAGDIR}" - err=$? - - if [[ ! -d "${GSIDIAGDIR}" || ${err} -ne 0 ]]; then - err_exit "Failed to create gsidiags directory at ${GSIDIAGDIR}" - fi - - for dir in dir.????; do - mv "${dir}" "${GSIDIAGDIR}/" - export err=$? - if [[ ${err} -ne 0 ]]; then - err_exit "Failed to move ${dir} to ${GSIDIAGDIR}/" - fi - done - else - echo "WARNING: No gsidiags dir.* directories found to move." - fi -fi - ################################################################################ exit "${err}" From 865aa51603974d1d8afaede7dc580b59f16d55fd Mon Sep 17 00:00:00 2001 From: David Huber Date: Thu, 12 Feb 2026 10:34:04 -0500 Subject: [PATCH 2/4] Remove GSIDIAGDIR before re-populating it; correct dir.XXXX numbering --- dev/scripts/exglobal_atmos_analysis.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/scripts/exglobal_atmos_analysis.sh b/dev/scripts/exglobal_atmos_analysis.sh index 5a4634ccf39..1668a5dfbdc 100755 --- a/dev/scripts/exglobal_atmos_analysis.sh +++ b/dev/scripts/exglobal_atmos_analysis.sh @@ -421,6 +421,8 @@ if [[ "${GENDIAG}" == "YES" ]]; then fi # Make the gsidiags directory to house the GSI diagnostic data GSIDIAGDIR=${GSIDIAGDIR:-"${pCOMOUT_ATMOS_ANALYSIS}/gsidiags"} + rm -rf "${GSIDIAGDIR}" + mkdir -p "${GSIDIAGDIR}" fi ############################################################## @@ -674,7 +676,7 @@ fi # This will allow the GSI to write directly to the GSIDIAGDIR. if [[ "${GENDIAG}" == "YES" ]]; then # The number of directories is controlled by the number of tasks (one each) - for task in $(seq 1 "${NTASKS_GSI}"); do + for task in $(seq 0 $((ntasks - 1))); do dir="dir.$(printf %04d "${task}")" mkdir -p "${GSIDIAGDIR}/${dir}" ${NLN} "${GSIDIAGDIR}/${dir}" "./${dir}" From 663dfded700bd21a4978c0d3cd6163b731dab1c6 Mon Sep 17 00:00:00 2001 From: David Huber Date: Thu, 12 Feb 2026 11:16:58 -0500 Subject: [PATCH 3/4] Add one more mkdir --- dev/scripts/exglobal_atmos_analysis.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/scripts/exglobal_atmos_analysis.sh b/dev/scripts/exglobal_atmos_analysis.sh index 1668a5dfbdc..72f0319b1b0 100755 --- a/dev/scripts/exglobal_atmos_analysis.sh +++ b/dev/scripts/exglobal_atmos_analysis.sh @@ -675,8 +675,9 @@ fi # If diags are to be generated, create the gsi.* directories in GSIDIAGDIR and link them here. # This will allow the GSI to write directly to the GSIDIAGDIR. if [[ "${GENDIAG}" == "YES" ]]; then - # The number of directories is controlled by the number of tasks (one each) - for task in $(seq 0 $((ntasks - 1))); do + # The number of directories is controlled by the number of tasks + # (one each + 1, though the last will contain no data) + for task in $(seq 0 ${ntasks}); do dir="dir.$(printf %04d "${task}")" mkdir -p "${GSIDIAGDIR}/${dir}" ${NLN} "${GSIDIAGDIR}/${dir}" "./${dir}" From 5f8c4a2572ed81f004502929b1f168de64469961 Mon Sep 17 00:00:00 2001 From: David Huber <69919478+DavidHuber-NOAA@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:39:44 -0500 Subject: [PATCH 4/4] Double-quote ntasks Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- dev/scripts/exglobal_atmos_analysis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/scripts/exglobal_atmos_analysis.sh b/dev/scripts/exglobal_atmos_analysis.sh index 72f0319b1b0..94314be9e95 100755 --- a/dev/scripts/exglobal_atmos_analysis.sh +++ b/dev/scripts/exglobal_atmos_analysis.sh @@ -677,7 +677,7 @@ fi if [[ "${GENDIAG}" == "YES" ]]; then # The number of directories is controlled by the number of tasks # (one each + 1, though the last will contain no data) - for task in $(seq 0 ${ntasks}); do + for task in $(seq 0 "${ntasks}"); do dir="dir.$(printf %04d "${task}")" mkdir -p "${GSIDIAGDIR}/${dir}" ${NLN} "${GSIDIAGDIR}/${dir}" "./${dir}"