Skip to content

Commit

Permalink
Merge branch 'feature/prepobs_fit2obs_versions' of https://github.com…
Browse files Browse the repository at this point in the history
…/KateFriedman-NOAA/global-workflow into feature/prepobs_fit2obs_versions

* 'feature/prepobs_fit2obs_versions' of https://github.com/KateFriedman-NOAA/global-workflow:
  Adds contents of constructor and initialize methods to marine LETKF class (NOAA-EMC#2635)
  Fix GDAS group B restart archiving (NOAA-EMC#2735)
  Add fcst dependency to ocnanalprep (NOAA-EMC#2728)
  • Loading branch information
KateFriedman-NOAA committed Jul 11, 2024
2 parents 1540921 + 3a0e553 commit 4293469
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 235 deletions.
10 changes: 5 additions & 5 deletions env/HERA.env
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ elif [[ "${step}" = "ocnanalecen" ]]; then
[[ ${NTHREADS_OCNANALECEN} -gt ${nth_max} ]] && export NTHREADS_OCNANALECEN=${nth_max}
export APRUN_OCNANALECEN="${launcher} -n ${npe_ocnanalecen} --cpus-per-task=${NTHREADS_OCNANALECEN}"

elif [[ "${step}" = "ocnanalletkf" ]]; then
elif [[ "${step}" = "marineanalletkf" ]]; then

nth_max=$((npe_node_max / npe_node_ocnanalletkf))
nth_max=$((npe_node_max / npe_node_marineanalletkf))

export NTHREADS_OCNANALLETKF=${nth_ocnanalletkf:-${nth_max}}
[[ ${NTHREADS_OCNANALLETKF} -gt ${nth_max} ]] && export NTHREADS_OCNANALLETKF=${nth_max}
export APRUN_OCNANALLETKF="${launcher} -n ${npe_ocnanalletkf} --cpus-per-task=${NTHREADS_OCNANALLETKF}"
export NTHREADS_MARINEANALLETKF=${nth_marineanalletkf:-${nth_max}}
[[ ${NTHREADS_MARINEANALLETKF} -gt ${nth_max} ]] && export NTHREADS_MARINEANALLETKF=${nth_max}
export APRUN_MARINEANALLETKF="${launcher} -n ${npe_marineanalletkf} --cpus-per-task=${NTHREADS_MARINEANALLETKF}"

elif [[ "${step}" = "anal" ]] || [[ "${step}" = "analcalc" ]]; then

Expand Down
10 changes: 5 additions & 5 deletions env/ORION.env
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ elif [[ "${step}" = "ocnanalecen" ]]; then
[[ ${NTHREADS_OCNANALECEN} -gt ${nth_max} ]] && export NTHREADS_OCNANALECEN=${nth_max}
export APRUN_OCNANALECEN="${launcher} -n ${npe_ocnanalecen} --cpus-per-task=${NTHREADS_OCNANALECEN}"

elif [[ "${step}" = "ocnanalletkf" ]]; then
elif [[ "${step}" = "marineanalletkf" ]]; then

nth_max=$((npe_node_max / npe_node_ocnanalletkf))
nth_max=$((npe_node_max / npe_node_marineanalletkf))

export NTHREADS_OCNANALLETKF=${nth_ocnanalletkf:-${nth_max}}
[[ ${NTHREADS_OCNANALLETKF} -gt ${nth_max} ]] && export NTHREADS_OCNANALLETKF=${nth_max}
export APRUN_OCNANALLETKF="${launcher} -n ${npe_ocnanalletkf} --cpus-per-task=${NTHREADS_OCNANALLETKF}"
export NTHREADS_MARINEANALLETKF=${nth_marineanalletkf:-${nth_max}}
[[ ${NTHREADS_MARINEANALLETKF} -gt ${nth_max} ]] && export NTHREADS_MARINEANALLETKF=${nth_max}
export APRUN_MARINEANALLETKF="${launcher} -n ${npe_marineanalletkf} --cpus-per-task=${NTHREADS_MARINEANALLETKF}"

elif [[ "${step}" = "anal" ]] || [[ "${step}" = "analcalc" ]]; then

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" -e "ocnanalletkf" -c "base ocnanal ocnanalletkf"
source "${HOMEgfs}/ush/jjob_header.sh" -e "marineanalletkf" -c "base ocnanal marineanalletkf"

##############################################
# Set variables used in the script
Expand All @@ -13,8 +13,10 @@ gPDY=${GDATE:0:8}
gcyc=${GDATE:8:2}

YMD=${gPDY} HH=${gcyc} declare_from_tmpl -rx \
COM_OCEAN_HISTORY_PREV:COM_OCEAN_HISTORY_TMPL \
COM_ICE_HISTORY_PREV:COM_ICE_HISTORY_TMPL
COMIN_OCEAN_HISTORY_PREV:COM_OCEAN_HISTORY_TMPL \
COMIN_ICE_HISTORY_PREV:COM_ICE_HISTORY_TMPL

YMD=${PDY} HH=${cyc} declare_from_tmpl -rx COMIN_OBS:COM_OBS_TMPL

##############################################
# Begin JOB SPECIFIC work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source "${HOMEgfs}/ush/preamble.sh"
status=$?
[[ ${status} -ne 0 ]] && exit "${status}"

export job="ocnanalletkf"
export job="marineanalletkf"
export jobid="${job}.$$"

###############################################################
Expand All @@ -18,6 +18,6 @@ export PYTHONPATH

###############################################################
# Execute the JJOB
"${HOMEgfs}/jobs/JGDAS_GLOBAL_OCEAN_ANALYSIS_LETKF"
"${HOMEgfs}/jobs/JGLOBAL_MARINE_ANALYSIS_LETKF"
status=$?
exit "${status}"
171 changes: 87 additions & 84 deletions parm/archive/master_enkf.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,108 +6,111 @@

# Split IAUFHRS into a list; typically either "3,6,9" or 6 (integer)
{% if IAUFHRS is string %}
# "3,6,9"
{% set iaufhrs = [] %}
{% for iaufhr in IAUFHRS.split(",") %}
{% do iaufhrs.append(iaufhr | int) %}
{% endfor %}
# "3,6,9"
{% set iaufhrs = [] %}
{% for iaufhr in IAUFHRS.split(",") %}
{% do iaufhrs.append(iaufhr | int) %}
{% endfor %}
{% else %}
# 6 (integer)
{% set iaufhrs = [IAUFHRS] %}
# 6 (integer)
{% set iaufhrs = [IAUFHRS] %}
{% endif %}

# Repeat for IAUFHRS_ENKF
{% if IAUFHRS_ENKF is string %}
{% set iaufhrs_enkf = [] %}
{% for iaufhr in IAUFHRS_ENKF.split(",") %}
{% do iaufhrs_enkf.append(iaufhr | int) %}
{% endfor %}
{% set iaufhrs_enkf = [] %}
{% for iaufhr in IAUFHRS_ENKF.split(",") %}
{% do iaufhrs_enkf.append(iaufhr | int) %}
{% endfor %}
{% else %}
{% set iaufhrs_enkf = [IAUFHRS_ENKF] %}
{% set iaufhrs_enkf = [IAUFHRS_ENKF] %}
{% endif %}

# Determine which data to archive
datasets:
{% if ENSGRP == 0 %}
{% filter indent(width=4) %}
# Archive the ensemble means and spreads
{% filter indent(width=4) %}
# Archive the ensemble means and spreads
{% include "enkf.yaml.j2" %}
{% endfilter %}
{% endfilter %}
{% else %}

# Archive individual member data
# First, construct individual member directories from templates
# COMIN_ATMOS_ANALYSIS_MEM, COMIN_ATMOS_HISTORY_MEM, and COMIN_ATMOS_RESTART_MEM

# Declare to-be-filled lists of member COM directories
{% set COMIN_ATMOS_ANALYSIS_MEM_list = [] %}
{% set COMIN_ATMOS_RESTART_MEM_list = [] %}
{% set COMIN_ATMOS_HISTORY_MEM_list = [] %}

# Determine which ensemble members belong to this group
{% set first_group_mem = (ENSGRP - 1) * NMEM_EARCGRP + 1 %}
{% set last_group_mem = [ ENSGRP * NMEM_EARCGRP, nmem_ens ] | min %}

# Construct member COM directories for the group
{% for mem in range(first_group_mem, last_group_mem + 1) %}

# Declare a dict of search and replace terms to run on each template
{% set tmpl_dict = {'ROTDIR':ROTDIR,
'RUN':RUN,
'YMD':cycle_YMD,
'HH':cycle_HH,
'MEMDIR':"mem" + '%03d' % mem} %}

# Replace template variables with tmpl_dict, one key at a time
# This must be done in a namespace to overcome jinja scoping
# Variables set inside of a for loop are lost at the end of the loop
# unless they are part of a namespace
{% set com_ns = namespace(COMIN_ATMOS_ANALYSIS_MEM = COM_ATMOS_ANALYSIS_TMPL,
COMIN_ATMOS_HISTORY_MEM = COM_ATMOS_HISTORY_TMPL,
COMIN_ATMOS_RESTART_MEM = COM_ATMOS_RESTART_TMPL) %}

{% for key in tmpl_dict.keys() %}
{% set search_term = '${' + key + '}' %}
{% set replace_term = tmpl_dict[key] %}
{% set com_ns.COMIN_ATMOS_ANALYSIS_MEM = com_ns.COMIN_ATMOS_ANALYSIS_MEM.replace(search_term, replace_term) %}
{% set com_ns.COMIN_ATMOS_HISTORY_MEM = com_ns.COMIN_ATMOS_HISTORY_MEM.replace(search_term, replace_term) %}
{% set com_ns.COMIN_ATMOS_RESTART_MEM = com_ns.COMIN_ATMOS_RESTART_MEM.replace(search_term, replace_term) %}
{% endfor %}

# Append the member COM directories
{% do COMIN_ATMOS_ANALYSIS_MEM_list.append(com_ns.COMIN_ATMOS_ANALYSIS_MEM)%}
{% do COMIN_ATMOS_HISTORY_MEM_list.append(com_ns.COMIN_ATMOS_HISTORY_MEM)%}
{% do COMIN_ATMOS_RESTART_MEM_list.append(com_ns.COMIN_ATMOS_RESTART_MEM)%}

{% endfor %}

# Archive member data
{% filter indent(width=4) %}
# Archive individual member data
# First, construct individual member directories from templates
# COMIN_ATMOS_ANALYSIS_MEM, COMIN_ATMOS_HISTORY_MEM, and COMIN_ATMOS_RESTART_MEM

# Declare to-be-filled lists of member COM directories
{% set COMIN_ATMOS_ANALYSIS_MEM_list = [] %}
{% set COMIN_ATMOS_RESTART_MEM_list = [] %}
{% set COMIN_ATMOS_HISTORY_MEM_list = [] %}

# Determine which ensemble members belong to this group
{% set first_group_mem = (ENSGRP - 1) * NMEM_EARCGRP + 1 %}
{% set last_group_mem = [ ENSGRP * NMEM_EARCGRP, nmem_ens ] | min %}

# Construct member COM directories for the group
{% for mem in range(first_group_mem, last_group_mem + 1) %}

# Declare a dict of search and replace terms to run on each template
{% set tmpl_dict = {'ROTDIR':ROTDIR,
'RUN':RUN,
'YMD':cycle_YMD,
'HH':cycle_HH,
'MEMDIR':"mem" + '%03d' % mem} %}

# Replace template variables with tmpl_dict, one key at a time
# This must be done in a namespace to overcome jinja scoping
# Variables set inside of a for loop are lost at the end of the loop
# unless they are part of a namespace
{% set com_ns = namespace(COMIN_ATMOS_ANALYSIS_MEM = COM_ATMOS_ANALYSIS_TMPL,
COMIN_ATMOS_HISTORY_MEM = COM_ATMOS_HISTORY_TMPL,
COMIN_ATMOS_RESTART_MEM = COM_ATMOS_RESTART_TMPL) %}

{% for key in tmpl_dict.keys() %}
{% set search_term = '${' + key + '}' %}
{% set replace_term = tmpl_dict[key] %}
{% set com_ns.COMIN_ATMOS_ANALYSIS_MEM =
com_ns.COMIN_ATMOS_ANALYSIS_MEM.replace(search_term, replace_term) %}
{% set com_ns.COMIN_ATMOS_HISTORY_MEM =
com_ns.COMIN_ATMOS_HISTORY_MEM.replace(search_term, replace_term) %}
{% set com_ns.COMIN_ATMOS_RESTART_MEM =
com_ns.COMIN_ATMOS_RESTART_MEM.replace(search_term, replace_term) %}
{% endfor %}

# Append the member COM directories
{% do COMIN_ATMOS_ANALYSIS_MEM_list.append(com_ns.COMIN_ATMOS_ANALYSIS_MEM)%}
{% do COMIN_ATMOS_HISTORY_MEM_list.append(com_ns.COMIN_ATMOS_HISTORY_MEM)%}
{% do COMIN_ATMOS_RESTART_MEM_list.append(com_ns.COMIN_ATMOS_RESTART_MEM)%}

{% endfor %}

# Archive member data
{% filter indent(width=4) %}
{% include "enkf_grp.yaml.j2" %}
{% endfilter %}
{% endfilter %}

# Determine if restarts should be saved
{% set save_warm_start_forecast, save_warm_start_cycled = ( False, False ) %}
# Determine if restarts should be saved
{% set save_warm_start_forecast, save_warm_start_cycled = ( False, False ) %}

# Save the increments and restarts every ARCH_WARMICFREQ days
# The ensemble increments (group a) should be saved on the ARCH_CYC
{% if (current_cycle - SDATE).days % ARCH_WARMICFREQ == 0 %}
{% if ARCH_CYC == cycle_HH | int %}
{% filter indent(width=4) %}
# Save the increments and restarts every ARCH_WARMICFREQ days
# The ensemble increments (group a) should be saved on the ARCH_CYC
{% if (current_cycle - SDATE).days % ARCH_WARMICFREQ == 0 %}
{% if ARCH_CYC == cycle_HH | int %}
{% filter indent(width=4) %}
{% include "enkf_restarta_grp.yaml.j2" %}
{% endfilter %}
{% endif %}
{% endif %}

# The ensemble ICs (group b) are restarts and always lag increments by assim_freq
{% set ics_offset = (assim_freq | string + "H") | to_timedelta %}
{% if (current_cycle | add_to_datetime(ics_offset) - SDATE).days % ARCH_WARMICFREQ == 0 %}
{% if (ARCH_CYC - assim_freq) % 24 == cycle_HH | int %}
{% filter indent(width=4) %}
{% endfilter %}
{% endif %}
{% endif %}

# The ensemble ICs (group b) are restarts and always lag increments by assim_freq
{% set ics_offset = (assim_freq | string + "H") | to_timedelta %}
{% if (current_cycle | add_to_datetime(ics_offset) - SDATE).days % ARCH_WARMICFREQ == 0 %}
{% if (ARCH_CYC - assim_freq) % 24 == cycle_HH | int %}
{% filter indent(width=4) %}
{% include "enkf_restartb_grp.yaml.j2" %}
{% endfilter %}
{% endif %}
{% endif %}
{% endfilter %}
{% endif %}
{% endif %}

# End of individual member archiving
# End of individual member archiving
{% endif %}
Loading

0 comments on commit 4293469

Please sign in to comment.