Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat snowDA templates to jinja2 #2371

Merged
merged 9 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ fix/wave

# Ignore parm file symlinks
#--------------------------
parm/config/config.base
parm/gldas
parm/gdas/aero
parm/gdas/atm
parm/gdas/io
parm/gdas/ioda
parm/gdas/snow
parm/gdas/soca
parm/monitor
parm/post/AEROSOL_LUTS.dat
parm/post/nam_micro_lookup.dat
Expand Down
38 changes: 19 additions & 19 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[submodule "sorc/ufs_model.fd"]
path = sorc/ufs_model.fd
url = https://github.com/ufs-community/ufs-weather-model
ignore = dirty
path = sorc/ufs_model.fd
url = https://github.com/ufs-community/ufs-weather-model
ignore = dirty
[submodule "sorc/wxflow"]
path = sorc/wxflow
url = https://github.com/NOAA-EMC/wxflow
path = sorc/wxflow
url = https://github.com/NOAA-EMC/wxflow
[submodule "sorc/gfs_utils.fd"]
path = sorc/gfs_utils.fd
url = https://github.com/NOAA-EMC/gfs-utils
path = sorc/gfs_utils.fd
url = https://github.com/NOAA-EMC/gfs-utils
[submodule "sorc/ufs_utils.fd"]
path = sorc/ufs_utils.fd
url = https://github.com/ufs-community/UFS_UTILS.git
path = sorc/ufs_utils.fd
url = https://github.com/ufs-community/UFS_UTILS.git
[submodule "sorc/verif-global.fd"]
path = sorc/verif-global.fd
url = https://github.com/NOAA-EMC/EMC_verif-global.git
path = sorc/verif-global.fd
url = https://github.com/NOAA-EMC/EMC_verif-global.git
[submodule "sorc/gsi_enkf.fd"]
path = sorc/gsi_enkf.fd
url = https://github.com/NOAA-EMC/GSI.git
path = sorc/gsi_enkf.fd
url = https://github.com/NOAA-EMC/GSI.git
[submodule "sorc/gdas.cd"]
path = sorc/gdas.cd
url = https://github.com/NOAA-EMC/GDASApp.git
path = sorc/gdas.cd
url = https://github.com/NOAA-EMC/GDASApp.git
[submodule "sorc/gsi_utils.fd"]
path = sorc/gsi_utils.fd
url = https://github.com/NOAA-EMC/GSI-Utils.git
path = sorc/gsi_utils.fd
url = https://github.com/NOAA-EMC/GSI-Utils.git
[submodule "sorc/gsi_monitor.fd"]
path = sorc/gsi_monitor.fd
url = https://github.com/NOAA-EMC/GSI-Monitor.git
path = sorc/gsi_monitor.fd
url = https://github.com/NOAA-EMC/GSI-Monitor.git
1 change: 1 addition & 0 deletions ci/cases/pr/C48mx500_3DVarAOWCDA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ arguments:

skip_ci_on_hosts:
- orion
- hera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember what the issue was @aerorahul ?

- hercules
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export RUN="gefs" # RUN is defined in the job-card (ecf); CDUMP is used at EMC
# Get all the COM path templates
source "${EXPDIR}/config.com"

# shellcheck disable=SC2016
export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'}
export LOGSCRIPT=${LOGSCRIPT:-""}
#export ERRSCRIPT=${ERRSCRIPT:-"err_chk"}
Expand Down Expand Up @@ -210,7 +211,7 @@ export gfs_cyc=@gfs_cyc@ # 0: no GFS cycle, 1: 00Z only, 2: 00Z and 12Z only, 4:
export FHMIN_GFS=0
export FHMIN=${FHMIN_GFS}
export FHMAX_GFS=@FHMAX_GFS@
export FHOUT_GFS=6
export FHOUT_GFS=6
export FHMAX_HF_GFS=0
export FHOUT_HF_GFS=1
export FHOUT_OCNICE_GFS=6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export RUN=${RUN:-${CDUMP:-"gfs"}} # RUN is defined in the job-card (ecf); CDUM
# Get all the COM path templates
source "${EXPDIR}/config.com"

# shellcheck disable=SC2016
export ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'}
export LOGSCRIPT=${LOGSCRIPT:-""}
#export ERRSCRIPT=${ERRSCRIPT:-"err_chk"}
Expand Down Expand Up @@ -247,7 +248,7 @@ export gfs_cyc=@gfs_cyc@ # 0: no GFS cycle, 1: 00Z only, 2: 00Z and 12Z only, 4:
# GFS output and frequency
export FHMIN_GFS=0
export FHMAX_GFS=@FHMAX_GFS@
export FHOUT_GFS=3
export FHOUT_GFS=3
export FHMAX_HF_GFS=0
export FHOUT_HF_GFS=1
export FHOUT_OCNICE_GFS=6
Expand Down
9 changes: 6 additions & 3 deletions parm/config/gfs/config.prepsnowobs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ echo "BEGIN: config.prepsnowobs"
# Get task specific resources
. "${EXPDIR}/config.resources" prepsnowobs

export GTS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/prep_gts.yaml"
export GTS_OBS_LIST="${HOMEgfs}/parm/gdas/snow/prep/prep_gts.yaml.j2"
export IMS_OBS_LIST="${HOMEgfs}/parm/gdas/snow/prep/prep_ims.yaml.j2"

export BUFR2IODAX="${HOMEgfs}/exec/bufr2ioda.x"
export FIMS_NML_TMPL="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/fims.nml.j2"
export IMS_OBS_LIST="${HOMEgfs}/sorc/gdas.cd/parm/snow/prep/prep_ims.yaml"

export CALCFIMSEXE="${HOMEgfs}/exec/calcfIMS.exe"
export FIMS_NML_TMPL="${HOMEgfs}/parm/gdas/snow/prep/fims.nml.j2"

export IMS2IODACONV="${HOMEgfs}/ush/imsfv3_scf2ioda.py"

echo "END: config.prepsnowobs"
14 changes: 4 additions & 10 deletions parm/config/gfs/config.snowanl
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@
echo "BEGIN: config.snowanl"

# Get task specific resources
. "${EXPDIR}/config.resources" snowanl
source "${EXPDIR}/config.resources" snowanl

obs_list_name=gdas_snow_gts_only.yaml
if [[ "${cyc}" = "18" ]]; then
obs_list_name=gdas_snow_prototype.yaml
fi

export OBS_YAML_DIR=${HOMEgfs}/sorc/gdas.cd/parm/snow/obs/config/
export OBS_LIST=${HOMEgfs}/sorc/gdas.cd/parm/snow/obs/lists/${obs_list_name}
export OBS_LIST="${HOMEgfs}/parm/gdas/snow/obs/lists/gdas_snow.yaml.j2"

# Name of the JEDI executable and its yaml template
export JEDIEXE="${HOMEgfs}/exec/fv3jedi_letkf.x"
export JEDIYAML="${HOMEgfs}/sorc/gdas.cd/parm/snow/letkfoi/letkfoi.yaml"
export JEDIYAML="${HOMEgfs}/parm/gdas/snow/letkfoi/letkfoi.yaml.j2"

# Ensemble member properties
export SNOWDEPTHVAR="snodl"
export BESTDDEV="30." # Background Error Std. Dev. for LETKFOI

# Name of the executable that applies increment to bkg and its namelist template
export APPLY_INCR_EXE="${HOMEgfs}/exec/apply_incr.exe"
export APPLY_INCR_NML_TMPL="${HOMEgfs}/sorc/gdas.cd/parm/snow/letkfoi/apply_incr_nml.j2"
export APPLY_INCR_NML_TMPL="${HOMEgfs}/parm/gdas/snow/letkfoi/apply_incr_nml.j2"

export io_layout_x=@IO_LAYOUT_X@
export io_layout_y=@IO_LAYOUT_Y@
Expand Down
7 changes: 0 additions & 7 deletions parm/gdas/snow_jedi_fix.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions parm/gdas/snow_jedi_fix.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir:
- '{{ DATA }}/fv3jedi'
copy:
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/akbk{{ npz }}.nc4', '{{ DATA }}/fv3jedi/akbk.nc4']
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/fmsmpp.nml', '{{ DATA }}/fv3jedi/fmsmpp.nml']
- ['{{ HOMEgfs }}/fix/gdas/fv3jedi/fv3files/field_table_gfdl', '{{ DATA }}/fv3jedi/field_table']
- ['{{ HOMEgfs }}/sorc/gdas.cd/parm/io/fv3jedi_fieldmetadata_restart.yaml', '{{ DATA }}/fv3jedi/fv3jedi_fieldmetadata_restart.yaml']
12 changes: 12 additions & 0 deletions sorc/link_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ if [[ -d "${HOMEgfs}/sorc/gdas.cd" ]]; then
done
fi

#------------------------------
#--add GDASApp parm directory
#------------------------------
if [[ -d "${HOMEgfs}/sorc/gdas.cd" ]]; then
cd "${HOMEgfs}/parm/gdas" || exit 1
declare -a gdasapp_comps=("aero" "atm" "io" "ioda" "snow" "soca")
for comp in "${gdasapp_comps[@]}"; do
[[ -d "${comp}" ]] && rm -rf "${comp}"
${LINK_OR_COPY} "${HOMEgfs}/sorc/gdas.cd/parm/${comp}" .
done
fi

#------------------------------
#--add GDASApp files
#------------------------------
Expand Down
6 changes: 4 additions & 2 deletions ush/python/pygfs/task/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Analysis(Task):
def __init__(self, config: Dict[str, Any]) -> None:
super().__init__(config)
self.config.ntiles = 6
# Store location of GDASApp jinja2 templates
self.gdasapp_j2tmpl_dir = os.path.join(self.config.HOMEgfs, 'parm/gdas')

def initialize(self) -> None:
super().initialize()
Expand Down Expand Up @@ -56,7 +58,7 @@ def get_obs_dict(self) -> Dict[str, Any]:
a dictionary containing the list of observation files to copy for FileHandler
"""
logger.debug(f"OBS_LIST: {self.task_config['OBS_LIST']}")
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config)
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"obs_list_config: {obs_list_config}")
# get observers from master dictionary
observers = obs_list_config['observers']
Expand Down Expand Up @@ -88,7 +90,7 @@ def get_bias_dict(self) -> Dict[str, Any]:
a dictionary containing the list of observation bias files to copy for FileHandler
"""
logger.debug(f"OBS_LIST: {self.task_config['OBS_LIST']}")
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config)
obs_list_config = parse_j2yaml(self.task_config["OBS_LIST"], self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"obs_list_config: {obs_list_config}")
# get observers from master dictionary
observers = obs_list_config['observers']
Expand Down
11 changes: 5 additions & 6 deletions ush/python/pygfs/task/snow_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
FileHandler,
to_fv3time, to_YMD, to_YMDH, to_timedelta, add_to_datetime,
rm_p,
parse_j2yaml, parse_yamltmpl, save_as_yaml,
parse_j2yaml, save_as_yaml,
Jinja,
logit,
Executable,
Expand Down Expand Up @@ -99,7 +99,7 @@ def prepare_GTS(self) -> None:

def _gtsbufr2iodax(exe, yaml_file):
if not os.path.isfile(yaml_file):
logger.exception(f"{yaml_file} not found")
logger.exception(f"FATAL ERROR: {yaml_file} not found")
raise FileNotFoundError(yaml_file)

logger.info(f"Executing {exe}")
Expand Down Expand Up @@ -260,9 +260,9 @@ def initialize(self) -> None:
FileHandler({'mkdir': dirlist}).sync()

# stage fix files
jedi_fix_list_path = os.path.join(self.task_config.HOMEgfs, 'parm', 'gdas', 'snow_jedi_fix.yaml')
jedi_fix_list_path = os.path.join(self.task_config.HOMEgfs, 'parm', 'gdas', 'snow_jedi_fix.yaml.j2')
logger.info(f"Staging JEDI fix files from {jedi_fix_list_path}")
jedi_fix_list = parse_yamltmpl(jedi_fix_list_path, self.task_config)
jedi_fix_list = parse_j2yaml(jedi_fix_list_path, self.task_config)
FileHandler(jedi_fix_list).sync()

# stage backgrounds
Expand All @@ -271,10 +271,9 @@ def initialize(self) -> None:

# generate letkfoi YAML file
logger.info(f"Generate JEDI LETKF YAML file: {self.task_config.jedi_yaml}")
letkfoi_yaml = parse_j2yaml(self.task_config.JEDIYAML, self.task_config)
letkfoi_yaml = parse_j2yaml(self.task_config.JEDIYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
save_as_yaml(letkfoi_yaml, self.task_config.jedi_yaml)
logger.info(f"Wrote letkfoi YAML to: {self.task_config.jedi_yaml}")

# need output dir for diags and anl
logger.info("Create empty output [anl, diags] directories to receive output from executable")
newdirs = [
Expand Down
11 changes: 3 additions & 8 deletions workflow/setup_expt.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ def fill_EXPDIR(inputs):
expdir = os.path.join(inputs.expdir, inputs.pslot)

configs = glob.glob(f'{configdir}/config.*')
exclude_configs = ['base', 'base.emc.dyn', 'base.nco.static', 'fv3.nco.static']
for exclude in exclude_configs:
try:
configs.remove(f'{configdir}/config.{exclude}')
except ValueError:
pass
if len(configs) == 0:
raise IOError(f'no config files found in {configdir}')
for config in configs:
Expand Down Expand Up @@ -295,7 +289,8 @@ def _update_defaults(dict_in: dict) -> dict:

def edit_baseconfig(host, inputs, yaml_dict):
"""
Parses and populates the templated `config.base.emc.dyn` to `config.base`
Parses and populates the templated `HOMEgfs/parm/config/<gfs|gefs>/config.base`
to `EXPDIR/pslot/config.base`
"""

tmpl_dict = {
Expand Down Expand Up @@ -347,7 +342,7 @@ def edit_baseconfig(host, inputs, yaml_dict):
except KeyError:
pass

base_input = f'{inputs.configdir}/config.base.emc.dyn'
base_input = f'{inputs.configdir}/config.base'
base_output = f'{inputs.expdir}/{inputs.pslot}/config.base'
edit_config(base_input, base_output, tmpl_dict)

Expand Down
Loading