From 64bc1793bdb945399be7598079f6fae75108d746 Mon Sep 17 00:00:00 2001 From: Walter Kolczynski - NOAA Date: Mon, 2 Dec 2024 16:53:28 -0500 Subject: [PATCH] Fix wave restart for cold start and add ic version file (#3112) 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 #3109 --- ci/cases/pr/C48mx500_3DVarAOWCDA.yaml | 2 +- ci/cases/pr/C48mx500_hybAOWCDA.yaml | 2 +- ci/cases/pr/C96C48_hybatmDA.yaml | 2 +- ci/cases/pr/C96C48_hybatmaerosnowDA.yaml | 2 +- ci/cases/pr/C96C48_ufs_hybatmDA.yaml | 2 +- ci/cases/pr/C96_atm3DVar.yaml | 2 +- ci/cases/pr/C96_atm3DVar_extended.yaml | 2 +- ci/cases/weekly/C384C192_hybatmda.yaml | 2 +- ci/cases/weekly/C384_atm3DVar.yaml | 2 +- parm/config/gefs/config.stage_ic | 10 +++-- parm/config/gfs/config.stage_ic | 9 +++-- parm/stage/master_gfs.yaml.j2 | 7 +--- ush/forecast_postdet.sh | 50 +++++++++++------------- versions/ic.ver | 22 +++++++++++ 14 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 versions/ic.ver diff --git a/ci/cases/pr/C48mx500_3DVarAOWCDA.yaml b/ci/cases/pr/C48mx500_3DVarAOWCDA.yaml index 2de5fea7ff..762d2c3fbe 100644 --- a/ci/cases/pr/C48mx500_3DVarAOWCDA.yaml +++ b/ci/cases/pr/C48mx500_3DVarAOWCDA.yaml @@ -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 diff --git a/ci/cases/pr/C48mx500_hybAOWCDA.yaml b/ci/cases/pr/C48mx500_hybAOWCDA.yaml index 036aa8ca60..ca477b5fba 100644 --- a/ci/cases/pr/C48mx500_hybAOWCDA.yaml +++ b/ci/cases/pr/C48mx500_hybAOWCDA.yaml @@ -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 diff --git a/ci/cases/pr/C96C48_hybatmDA.yaml b/ci/cases/pr/C96C48_hybatmDA.yaml index b527903d69..c0833acf14 100644 --- a/ci/cases/pr/C96C48_hybatmDA.yaml +++ b/ci/cases/pr/C96C48_hybatmDA.yaml @@ -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 diff --git a/ci/cases/pr/C96C48_hybatmaerosnowDA.yaml b/ci/cases/pr/C96C48_hybatmaerosnowDA.yaml index 57d0989ae3..93abda95e5 100644 --- a/ci/cases/pr/C96C48_hybatmaerosnowDA.yaml +++ b/ci/cases/pr/C96C48_hybatmaerosnowDA.yaml @@ -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 diff --git a/ci/cases/pr/C96C48_ufs_hybatmDA.yaml b/ci/cases/pr/C96C48_ufs_hybatmDA.yaml index 031054079a..240f04c090 100644 --- a/ci/cases/pr/C96C48_ufs_hybatmDA.yaml +++ b/ci/cases/pr/C96C48_ufs_hybatmDA.yaml @@ -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 diff --git a/ci/cases/pr/C96_atm3DVar.yaml b/ci/cases/pr/C96_atm3DVar.yaml index fc09beeacf..6286d74dc4 100644 --- a/ci/cases/pr/C96_atm3DVar.yaml +++ b/ci/cases/pr/C96_atm3DVar.yaml @@ -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 diff --git a/ci/cases/pr/C96_atm3DVar_extended.yaml b/ci/cases/pr/C96_atm3DVar_extended.yaml index 8ab67a750e..45a0cdd6d2 100644 --- a/ci/cases/pr/C96_atm3DVar_extended.yaml +++ b/ci/cases/pr/C96_atm3DVar_extended.yaml @@ -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 diff --git a/ci/cases/weekly/C384C192_hybatmda.yaml b/ci/cases/weekly/C384C192_hybatmda.yaml index 6053f73124..ecaea3757f 100644 --- a/ci/cases/weekly/C384C192_hybatmda.yaml +++ b/ci/cases/weekly/C384C192_hybatmda.yaml @@ -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 diff --git a/ci/cases/weekly/C384_atm3DVar.yaml b/ci/cases/weekly/C384_atm3DVar.yaml index 1a14059ab1..4409a73ac1 100644 --- a/ci/cases/weekly/C384_atm3DVar.yaml +++ b/ci/cases/weekly/C384_atm3DVar.yaml @@ -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 diff --git a/parm/config/gefs/config.stage_ic b/parm/config/gefs/config.stage_ic index 92c6bb2a9b..5822f2e794 100644 --- a/parm/config/gefs/config.stage_ic +++ b/parm/config/gefs/config.stage_ic @@ -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 @@ -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 diff --git a/parm/config/gfs/config.stage_ic b/parm/config/gfs/config.stage_ic index d0113fac63..f30e402c93 100644 --- a/parm/config/gfs/config.stage_ic +++ b/parm/config/gfs/config.stage_ic @@ -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 @@ -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 diff --git a/parm/stage/master_gfs.yaml.j2 b/parm/stage/master_gfs.yaml.j2 index 5204221c9b..e862005094 100644 --- a/parm/stage/master_gfs.yaml.j2 +++ b/parm/stage/master_gfs.yaml.j2 @@ -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) %} @@ -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)%} diff --git a/ush/forecast_postdet.sh b/ush/forecast_postdet.sh index 310fcf0afa..aade469ddc 100755 --- a/ush/forecast_postdet.sh +++ b/ush/forecast_postdet.sh @@ -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" diff --git a/versions/ic.ver b/versions/ic.ver new file mode 100644 index 0000000000..e7bd8358ef --- /dev/null +++ b/versions/ic.ver @@ -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