Skip to content

Commit

Permalink
Update cycle prefixes and add analysis file checks
Browse files Browse the repository at this point in the history
- Replace r_prefix with either m_prefix or o_prefix
- Add path_exists checks for analysis ICs

Refs NOAA-EMC#2475
  • Loading branch information
KateFriedman-NOAA committed Aug 5, 2024
1 parent 68c121f commit deec1af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
3 changes: 3 additions & 0 deletions jobs/JGLOBAL_STAGE_IC
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ current_cycle="${PDY}${cyc}"
previous_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${assim_freq} hours" +%Y%m%d%H)
current_cycle_begin=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${half_window} hours" +%Y%m%d%H)
current_cycle_end=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${half_window} hours" +%Y%m%d%H)
current_cycle_offset=$(date --utc -d "${PDY} ${cyc} + ${OFFSET_START_HOUR} hours" +%Y%m%d%H)
export current_cycle_offset

# Define model start date for current_cycle as the time the forecast will start
if [[ "${DOIAU:-NO}" == "YES" ]]; then
model_start_date_current_cycle="${current_cycle_begin}"
Expand Down
29 changes: 16 additions & 13 deletions parm/stage/stage.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

# Set variables used below
{% set cycle_HH = current_cycle | strftime("%H") %}
{% set r_prefix = model_start_date_current_cycle | to_YMD + "." + model_start_date_current_cycle | strftime("%H") + "0000" %}
{% set m_prefix = model_start_date_current_cycle | to_YMD + "." + model_start_date_current_cycle | strftime("%H") + "0000" %}
{% set o_prefix = current_cycle_offset | to_YMD + "." + current_cycle_offset | strftime("%H") + "0000" %}

#############################################################
# Initial condition to stage
Expand All @@ -30,8 +31,10 @@ analysis:
mkdir:
- "{{ COMOUT_ATMOS_ANALYSIS }}"
copy:
{% for ftype in ["abias", "abias_air", "abias_pc", "radstat"] %}
{% for ftype in ["abias", "abias_air", "abias_int", "abias_pc", "atminc.nc", "radstat"] %}
{% if path_exists(ICSDIR ~ "/" ~ COMOUT_ATMOS_ANALYSIS | relpath(ROTDIR) ~ "/" ~ RUN ~ ".t" ~ cycle_HH ~ "z." ~ ftype) %}
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_ANALYSIS | relpath(ROTDIR) }}/{{ RUN }}.t{{ cycle_HH }}z.{{ ftype }}", "{{ COMOUT_ATMOS_ANALYSIS }}"]
{% endif %}
{% endfor %}
{% endif %}

Expand All @@ -41,11 +44,11 @@ atmosphere_warm:
- "{{ COMOUT_ATMOS_RESTART_PREV }}"
copy:
{% for ftype in ["coupler.res", "fv_core.res.nc"] %}
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.{{ ftype }}", "{{ COMOUT_ATMOS_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ m_prefix }}.{{ ftype }}", "{{ COMOUT_ATMOS_RESTART_PREV }}"]
{% endfor %}
{% for ftype in ["ca_data", "fv_core.res", "fv_srf_wnd.res", "fv_tracer.res", "phy_data", "sfc_data"] %}
{% for ntile in range(1, ntiles + 1) %}
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.{{ ftype }}.tile{{ ntile }}.nc", "{{ COMOUT_ATMOS_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ m_prefix }}.{{ ftype }}.tile{{ ntile }}.nc", "{{ COMOUT_ATMOS_RESTART_PREV }}"]
{% endfor %} # ntile
{% endfor %} # ftype
{% else %}
Expand All @@ -66,7 +69,7 @@ atmosphere_perturbation:
mkdir:
- "{{ COMOUT_ATMOS_ANALYSIS }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_ANALYSIS | relpath(ROTDIR) }}/{{ r_prefix }}.fv3_perturbation.nc", "{{ COMOUT_ATMOS_ANALYSIS }}/{{ RUN }}.t{{ cycle_HH }}z.atminc.nc"]
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_ANALYSIS | relpath(ROTDIR) }}/{{ m_prefix }}.fv3_perturbation.nc", "{{ COMOUT_ATMOS_ANALYSIS }}/{{ RUN }}.t{{ cycle_HH }}z.atminc.nc"]
{% endif %}

{% if DO_NEST %}
Expand All @@ -77,7 +80,7 @@ atmosphere_nest:
copy:
{% if EXP_WARM_START == True %}
{% for ftype in ["ca_data", "fv_core.res", "fv_srf_wnd.res", "fv_tracer.res", "phy_data", "sfc_data"] %}
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.{{ ftype }}.tile{{ ntile }}.nc", "{{ COMOUT_ATMOS_RESTART_PREV }}/{{ r_prefix }}.{{ ftype }}.nest0{{ ntile-5 }}.tile{{ ntile }}.nc"]
- ["{{ ICSDIR }}/{{ COMOUT_ATMOS_RESTART_PREV | relpath(ROTDIR) }}/{{ m_prefix }}.{{ ftype }}.tile{{ ntile }}.nc", "{{ COMOUT_ATMOS_RESTART_PREV }}/{{ m_prefix }}.{{ ftype }}.nest0{{ ntile-5 }}.tile{{ ntile }}.nc"]
{% endfor %} # ftype
{% else %}
{% for ftype in ["gfs_data", "sfc_data"] %}
Expand All @@ -91,18 +94,18 @@ ice:
mkdir:
- "{{ COMOUT_ICE_RESTART_PREV }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_ICE_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.cice_model.res.nc", "{{ COMOUT_ICE_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_ICE_RESTART_PREV | relpath(ROTDIR) }}/{{ o_prefix }}.cice_model.res.nc", "{{ COMOUT_ICE_RESTART_PREV }}"]
{% endif %}

{% if DO_OCN %}
ocean:
mkdir:
- "{{ COMOUT_OCEAN_RESTART_PREV }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.MOM.res.nc", "{{ COMOUT_OCEAN_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_RESTART_PREV | relpath(ROTDIR) }}/{{ o_prefix }}.MOM.res.nc", "{{ COMOUT_OCEAN_RESTART_PREV }}"]
{% if OCNRES == "025" %}
{% for nn in range(1, 3) %}
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.MOM.res_{{ nn }}.nc", "{{ COMOUT_OCEAN_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_RESTART_PREV | relpath(ROTDIR) }}/{{ o_prefix }}.MOM.res_{{ nn }}.nc", "{{ COMOUT_OCEAN_RESTART_PREV }}"]
{% endfor %}
{% endif %}

Expand All @@ -111,16 +114,16 @@ replay:
mkdir:
- "{{ COMOUT_OCEAN_ANALYSIS }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_ANALYSIS | relpath(ROTDIR) }}/{{ r_prefix }}.mom6_perturbation.nc", "{{ COMOUT_OCEAN_ANALYSIS }}/mom6_increment.nc"]
- ["{{ ICSDIR }}/{{ COMOUT_OCEAN_ANALYSIS | relpath(ROTDIR) }}/{{ o_prefix }}.mom6_perturbation.nc", "{{ COMOUT_OCEAN_ANALYSIS }}/mom6_increment.nc"]
{% endif %}

{% if EXP_WARM_START == True %}
{% if path_exists(ICSDIR ~ "/" ~ COMOUT_MED_RESTART_PREV | relpath(ROTDIR) ~ "/" ~ r_prefix ~ ".ufs.cpld.cpl.r.nc") %}
{% if path_exists(ICSDIR ~ "/" ~ COMOUT_MED_RESTART_PREV | relpath(ROTDIR) ~ "/" ~ m_prefix ~ ".ufs.cpld.cpl.r.nc") %}
mediator:
mkdir:
- "{{ COMOUT_MED_RESTART_PREV }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_MED_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.ufs.cpld.cpl.r.nc", "{{ COMOUT_MED_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_MED_RESTART_PREV | relpath(ROTDIR) }}/{{ m_prefix }}.ufs.cpld.cpl.r.nc", "{{ COMOUT_MED_RESTART_PREV }}"]
{% endif %} # path exists
{% endif %} # warm start true

Expand All @@ -131,5 +134,5 @@ wave:
mkdir:
- "{{ COMOUT_WAVE_RESTART_PREV }}"
copy:
- ["{{ ICSDIR }}/{{ COMOUT_WAVE_RESTART_PREV | relpath(ROTDIR) }}/{{ r_prefix }}.restart.{{ waveGRD }}", "{{ COMOUT_WAVE_RESTART_PREV }}"]
- ["{{ ICSDIR }}/{{ COMOUT_WAVE_RESTART_PREV | relpath(ROTDIR) }}/{{ o_prefix }}.restart.{{ waveGRD }}", "{{ COMOUT_WAVE_RESTART_PREV }}"]
{% endif %}
4 changes: 2 additions & 2 deletions scripts/exglobal_stage_ic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def main():
stage = Stage(config)

# Pull out all the configuration keys needed to run stage job
keys = ['RUN', 'MODE', 'EXP_WARM_START',
'current_cycle', 'model_start_date_current_cycle',
keys = ['RUN', 'MODE', 'EXP_WARM_START', 'current_cycle',
'current_cycle_offset', 'model_start_date_current_cycle',
'ROTDIR', 'ICSDIR', 'STAGE_IC_YAML_TMPL',
'OCNRES', 'waveGRD', 'ntiles',
'REPLAY_ICS', 'DO_WAVE', 'DO_OCN', 'DO_ICE', 'DO_NEST']
Expand Down

0 comments on commit deec1af

Please sign in to comment.