Skip to content

Commit

Permalink
Fix wave restart for cold start and add ic version file (NOAA-EMC#3112)
Browse files Browse the repository at this point in the history
The stage job was incorrectly putting wave restarts into the gfs
directory. The forecast job looks for them in the gdas directory, so
this is updated.

Additionally, the restarts were also not being copied from the staged
directory to `$DATA`, so now they are. The process is identical to that
of non-RERUN warm starts, so the code is refactored a bit to avoid
duplication.

As part of updating the ICs with the new restart location, an IC version
file is added to support different version numbers for different IC
directories. Unlike other version files, this one uses an associative
array rather than individual variables.

Resolves NOAA-EMC#3109
  • Loading branch information
WalterKolczynski-NOAA authored Dec 2, 2024
1 parent 6b2d84e commit 64bc179
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 50 deletions.
2 changes: 1 addition & 1 deletion ci/cases/pr/C48mx500_3DVarAOWCDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ arguments:
resdetocean: 5.0
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C48mx500/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C48mx500/20241120
idate: 2021032412
edate: 2021032418
nens: 0
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C48mx500_hybAOWCDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arguments:
resensatmos: 48
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C48mx500/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C48mx500/20241120
idate: 2021032412
edate: 2021032418
nens: 3
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C96C48_hybatmDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arguments:
resensatmos: 48
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20241120
idate: 2021122018
edate: 2021122106
nens: 2
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C96C48_hybatmaerosnowDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ arguments:
resensatmos: 48
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20241120
idate: 2021122012
edate: 2021122100
nens: 2
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C96C48_ufs_hybatmDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ arguments:
resensatmos: 48
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20241120
idate: 2024022318
edate: 2024022406
nens: 2
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C96_atm3DVar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ arguments:
resdetatmos: 96
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20241120
idate: 2021122018
edate: 2021122106
nens: 0
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/pr/C96_atm3DVar_extended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ arguments:
resdetatmos: 96
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20240610
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96C48/20241120
idate: 2021122018
edate: 2021122118
nens: 0
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/weekly/C384C192_hybatmda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arguments:
resensatmos: 192
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C384C192
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C384C192/20240610
idate: 2023040118
edate: 2023040200
nens: 2
Expand Down
2 changes: 1 addition & 1 deletion ci/cases/weekly/C384_atm3DVar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arguments:
resensatmos: 192
comroot: {{ 'RUNTESTS' | getenv }}/COMROOT
expdir: {{ 'RUNTESTS' | getenv }}/EXPDIR
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C384C192
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C384C192/20240610
idate: 2023040118
edate: 2023040200
nens: 0
Expand Down
10 changes: 6 additions & 4 deletions parm/config/gefs/config.stage_ic
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export BASE_IC="@BASE_IC@" # Platform home for staged ICs

export STAGE_IC_YAML_TMPL="${PARMgfs}/stage/master_gefs.yaml.j2"

# Set ICSDIR
source "${HOMEgfs}/versions/ic.ver"

# Set ICSDIR (if not defined)
if [[ -z "${ICSDIR}" ]] ; then

ic_ver="20240610"

if (( NMEM_ENS > 0 )) ; then
ensic="${CASE_ENS}"
fi
Expand All @@ -26,7 +25,10 @@ if [[ -z "${ICSDIR}" ]] ; then
ocnic="mx${OCNRES}"
fi

export ICSDIR="${BASE_IC}/${CASE}${ensic:-}${ocnic:-}/${ic_ver}"
dir_name="${CASE}${ensic:-}${ocnic:-}"
ic_ver="${ic_versions[${dir_name}]}"

export ICSDIR="${BASE_IC}/${dir_name}/${ic_ver}"

fi

Expand Down
9 changes: 6 additions & 3 deletions parm/config/gfs/config.stage_ic
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export BASE_IC="@BASE_IC@" # Platform home for staged ICs

export STAGE_IC_YAML_TMPL="${PARMgfs}/stage/master_gfs.yaml.j2"

source "${HOMEgfs}/versions/ic.ver"

# Set ICSDIR (if not defined)
if [[ -z "${ICSDIR}" ]] ; then

ic_ver="20240610"

if (( NMEM_ENS > 0 )) ; then
ensic="${CASE_ENS}"
fi
Expand All @@ -25,7 +25,10 @@ if [[ -z "${ICSDIR}" ]] ; then
ocnic="mx${OCNRES}"
fi

export ICSDIR="${BASE_IC}/${CASE}${ensic:-}${ocnic:-}/${ic_ver}"
dir_name="${CASE}${ensic:-}${ocnic:-}"
ic_ver="${ic_versions[${dir_name}]}"

export ICSDIR="${BASE_IC}/${dir_name}/${ic_ver}"

fi

Expand Down
7 changes: 1 addition & 6 deletions parm/stage/master_gfs.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@
'${YMD}':previous_cycle_YMD,
'${HH}':previous_cycle_HH,
'${MEMDIR}': mem_char }) %}
{% set previous_cycle_and_run_dict = ({ '${ROTDIR}':ROTDIR,
'${RUN}':RUN,
'${YMD}':previous_cycle_YMD,
'${HH}':previous_cycle_HH,
'${MEMDIR}': mem_char }) %}

{% set COMOUT_ATMOS_INPUT_MEM = COM_ATMOS_INPUT_TMPL | replace_tmpl(current_cycle_dict) %}
{% set COMOUT_ATMOS_RESTART_PREV_MEM = COM_ATMOS_RESTART_TMPL | replace_tmpl(previous_cycle_dict) %}
Expand All @@ -108,7 +103,7 @@
{% set COMOUT_OCEAN_RESTART_PREV_MEM = COM_OCEAN_RESTART_TMPL | replace_tmpl(previous_cycle_dict) %}
{% set COMOUT_OCEAN_ANALYSIS_MEM = COM_OCEAN_ANALYSIS_TMPL | replace_tmpl(current_cycle_dict) %}
{% set COMOUT_MED_RESTART_PREV_MEM = COM_MED_RESTART_TMPL | replace_tmpl(previous_cycle_dict) %}
{% set COMOUT_WAVE_RESTART_PREV_MEM = COM_WAVE_RESTART_TMPL | replace_tmpl(previous_cycle_and_run_dict) %}
{% set COMOUT_WAVE_RESTART_PREV_MEM = COM_WAVE_RESTART_TMPL | replace_tmpl(previous_cycle_dict) %}

# Append the member COM directories
{% do COMOUT_ATMOS_INPUT_MEM_list.append(COMOUT_ATMOS_INPUT_MEM)%}
Expand Down
50 changes: 22 additions & 28 deletions ush/forecast_postdet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -328,39 +328,33 @@ WW3_postdet() {

local ww3_grid first_ww3_restart_out ww3_restart_file
# Copy initial condition files:
if [[ "${warm_start}" == ".true." ]]; then
local restart_date restart_dir
if [[ "${RERUN}" == "YES" ]]; then
restart_date="${RERUN_DATE}"
restart_dir="${DATArestart}/WW3_RESTART"
else
restart_date="${model_start_date_current_cycle}"
restart_dir="${COMIN_WAVE_RESTART_PREV}"
fi
echo "Copying WW3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'"
ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3"
if [[ -f "${ww3_restart_file}" ]]; then
${NCP} "${ww3_restart_file}" "${DATA}/restart.ww3" \
local restart_date restart_dir
if [[ "${RERUN}" == "YES" ]]; then
restart_date="${RERUN_DATE}"
restart_dir="${DATArestart}/WW3_RESTART"
else
restart_date="${model_start_date_current_cycle}"
restart_dir="${COMIN_WAVE_RESTART_PREV}"
fi

echo "Copying WW3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'"
ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3"
if [[ -s "${ww3_restart_file}" ]]; then
${NCP} "${ww3_restart_file}" "${DATA}/restart.ww3" \
|| ( echo "FATAL ERROR: Unable to copy WW3 IC, ABORT!"; exit 1 )
first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H)
else
if [[ "${RERUN}" == "YES" ]]; then
# In the case of a RERUN, the WW3 restart file is required
echo "FATAL ERROR: WW3 restart file '${ww3_restart_file}' not found for RERUN='${RERUN}', ABORT!"
exit 1
else
if [[ "${RERUN}" == "YES" ]]; then
# In the case of a RERUN, the WW3 restart file is required
echo "FATAL ERROR: WW3 restart file '${ww3_restart_file}' not found for RERUN='${RERUN}', ABORT!"
exit 1
else
echo "WARNING: WW3 restart file '${ww3_restart_file}' not found for warm_start='${warm_start}', will start from rest!"
fi
echo "WARNING: WW3 restart file '${ww3_restart_file}' not found for warm_start='${warm_start}', will start from rest!"
first_ww3_restart_out=${model_start_date_current_cycle}
fi

first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H)
else # cold start
echo "WW3 will start from rest!"
first_ww3_restart_out="${model_start_date_current_cycle}"
fi # [[ "${warm_start}" == ".true." ]]
fi

# Link restart files
local ww3_restart_file
# Use restart_date if it was determined above, otherwise use initialization date
for (( vdate = first_ww3_restart_out; vdate <= forecast_end_cycle;
vdate = $(date --utc -d "${vdate:0:8} ${vdate:8:2} + ${restart_interval} hours" +%Y%m%d%H) )); do
ww3_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3"
Expand Down
22 changes: 22 additions & 0 deletions versions/ic.ver
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Initial condition subfolder versions

#shellcheck disable=SC2034
declare -A ic_versions

ic_versions['C48']=20241120
ic_versions['C48mx500']=20241120
ic_versions['C48C48mx500']=20241120

ic_versions['C96']=20241120
ic_versions['C96C48']=20241120
ic_versions['C96mx100']=20240610

ic_versions['C384C192']=20240610
ic_versions['C384mx025']=20241120

ic_versions['C768']=20241120
ic_versions['C768mx025']=20241120

ic_versions['C1152']=20241120
ic_versions['C1152mx025']=20241120

0 comments on commit 64bc179

Please sign in to comment.