From 3e78e586da58b9be7fc0caa2cb4437bffa337522 Mon Sep 17 00:00:00 2001 From: David Huber <69919478+DavidHuber-NOAA@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:46:02 -0500 Subject: [PATCH] Move machine-based options from config.base to host files (#3053) This moves all machine-specific options to the workflow/hosts files from the config.* files. This also turns HPSS archiving on for WCOSS2 by default. This turns OFF UFS DA tests on WCOSS2. Resolves #2942 Resolves #3087 --------- Co-authored-by: Walter Kolczynski - NOAA Co-authored-by: Rahul Mahajan --- ci/cases/pr/C96C48_ufs_hybatmDA.yaml | 2 +- ci/cases/yamls/ufs_hybatmDA_defaults.ci.yaml | 1 - modulefiles/module_gwsetup.wcoss2.lua | 3 + parm/archive/gfs_downstream.yaml.j2 | 4 +- parm/config/gefs/config.base | 13 +-- parm/config/gfs/config.aero | 30 +------ parm/config/gfs/config.base | 20 +---- parm/config/gfs/config.prepoceanobs | 7 +- parm/config/gfs/yaml/defaults.yaml | 7 +- workflow/generate_workflows.sh | 2 + workflow/hosts/awspw.yaml | 4 + workflow/hosts/azurepw.yaml | 1 + workflow/hosts/gaea.yaml | 1 + workflow/hosts/googlepw.yaml | 1 + workflow/hosts/hera.yaml | 1 + workflow/hosts/hercules.yaml | 3 + workflow/hosts/jet.yaml | 1 + workflow/hosts/orion.yaml | 3 + workflow/hosts/s4.yaml | 1 + workflow/hosts/wcoss2.yaml | 1 + workflow/setup_expt.py | 89 +++++++++++++------- 21 files changed, 100 insertions(+), 95 deletions(-) diff --git a/ci/cases/pr/C96C48_ufs_hybatmDA.yaml b/ci/cases/pr/C96C48_ufs_hybatmDA.yaml index 41a8baa725..031054079a 100644 --- a/ci/cases/pr/C96C48_ufs_hybatmDA.yaml +++ b/ci/cases/pr/C96C48_ufs_hybatmDA.yaml @@ -21,4 +21,4 @@ skip_ci_on_hosts: - gaea - orion - hercules - + - wcoss2 diff --git a/ci/cases/yamls/ufs_hybatmDA_defaults.ci.yaml b/ci/cases/yamls/ufs_hybatmDA_defaults.ci.yaml index c4fa54dcc8..b956066f6b 100644 --- a/ci/cases/yamls/ufs_hybatmDA_defaults.ci.yaml +++ b/ci/cases/yamls/ufs_hybatmDA_defaults.ci.yaml @@ -17,4 +17,3 @@ nsst: NST_MODEL: "1" sfcanl: DONST: "NO" - diff --git a/modulefiles/module_gwsetup.wcoss2.lua b/modulefiles/module_gwsetup.wcoss2.lua index a2440569db..86bdad3c56 100644 --- a/modulefiles/module_gwsetup.wcoss2.lua +++ b/modulefiles/module_gwsetup.wcoss2.lua @@ -4,5 +4,8 @@ Load environment to run GFS workflow ci scripts on WCOSS2 prepend_path("MODULEPATH", "/apps/ops/test/nco/modulefiles/core") load(pathJoin("rocoto","1.3.5")) +load(pathJoin("PrgEnv-intel")) +load(pathJoin("intel","19.1.3.304")) +load(pathJoin("python", "3.8.6")) whatis("Description: GFS run setup environment") diff --git a/parm/archive/gfs_downstream.yaml.j2 b/parm/archive/gfs_downstream.yaml.j2 index ed5317b42c..94bdd1df56 100644 --- a/parm/archive/gfs_downstream.yaml.j2 +++ b/parm/archive/gfs_downstream.yaml.j2 @@ -6,7 +6,7 @@ gfs_downstream: - "{{ COMIN_ATMOS_GEMPAK | relpath(ROTDIR) }}/gfs_{{ cycle_YMDH }}.sfc" - "{{ COMIN_ATMOS_GEMPAK | relpath(ROTDIR) }}/gfs_{{ cycle_YMDH }}.snd" {% for i in range(1, NUM_SND_COLLECTIVES) %} - - "{{ COMIN_ATMOS_WMO | relpath(ROTDIR) }}/gfs_collective{{ i }}.postsnd_{{ cycle_HH }}" + - "{{ COMIN_ATMOS_BUFR | relpath(ROTDIR) }}/gfs_collective{{ i }}.fil" {% endfor %} - - "{{ COMIN_ATMOS_BUFR | relpath(ROTDIR) }}/bufr.t{{ cycle_HH }}z" + - "{{ COMIN_ATMOS_BUFR | relpath(ROTDIR) }}/bufr.??????.{{ cycle_YMDH }}" - "{{ COMIN_ATMOS_BUFR | relpath(ROTDIR) }}/gfs.t{{ cycle_HH }}z.bufrsnd.tar.gz" diff --git a/parm/config/gefs/config.base b/parm/config/gefs/config.base index 05aabaa323..e769015937 100644 --- a/parm/config/gefs/config.base +++ b/parm/config/gefs/config.base @@ -210,12 +210,11 @@ case "${APP}" in if [[ "${APP}" =~ ^S2SW ]]; then export DO_WAVE="YES" export WAVE_RUN="both" - export cplwav2atm=".true." fi ;; *) - echo "Unrecognized APP: ${1}" - exit 1 + echo "FATAL ERROR: Unrecognized APP: '${APP}'" + exit 2 ;; esac @@ -327,7 +326,7 @@ export HPSSARCH="@HPSSARCH@" # save data to HPSS archive export LOCALARCH="@LOCALARCH@" # save data to local archive if [[ ${HPSSARCH} = "YES" ]] && [[ ${LOCALARCH} = "YES" ]]; then echo "Both HPSS and local archiving selected. Please choose one or the other." - exit 2 + exit 3 fi export ARCH_CYC=00 # Archive data at this cycle for warm_start capability export ARCH_WARMICFREQ=4 # Archive frequency in days for warm_start capability @@ -338,10 +337,4 @@ export DELETE_COM_IN_ARCHIVE_JOB="YES" # NO=retain ROTDIR. YES default in arc # Number of regional collectives to create soundings for export NUM_SND_COLLECTIVES=${NUM_SND_COLLECTIVES:-9} -# The tracker, genesis, and METplus jobs are not supported on CSPs yet -# TODO: we should place these in workflow/hosts/[aws|azure|google]pw.yaml as part of CSP's setup, not for general. -if [[ "${machine}" =~ "PW" ]]; then - export DO_WAVE="NO" -fi - echo "END: config.base" diff --git a/parm/config/gfs/config.aero b/parm/config/gfs/config.aero index f49593a439..bbfb782636 100644 --- a/parm/config/gfs/config.aero +++ b/parm/config/gfs/config.aero @@ -2,36 +2,8 @@ # UFS-Aerosols settings -# Turn off warnings about unused variables -# shellcheck disable=SC2034 - - # Path to the input data tree -case ${machine} in - "HERA") - AERO_INPUTS_DIR="/scratch1/NCEPDEV/global/glopara/data/gocart_emissions" - ;; - "ORION" | "HERCULES") - AERO_INPUTS_DIR="/work2/noaa/global/wkolczyn/noscrub/global-workflow/gocart_emissions" - ;; - "S4") - AERO_INPUTS_DIR="/data/prod/glopara/gocart_emissions" - ;; - "WCOSS2") - AERO_INPUTS_DIR="/lfs/h2/emc/global/noscrub/emc.global/data/gocart_emissions" - ;; - "GAEA") - AERO_INPUTS_DIR="/gpfs/f5/epic/proj-shared/global/glopara/data/gocart_emissions" - ;; - "JET") - AERO_INPUTS_DIR="/lfs5/HFIP/hfv3gfs/glopara/data/gocart_emissions" - ;; - *) - echo "FATAL ERROR: Machine ${machine} unsupported for aerosols" - exit 2 - ;; -esac -export AERO_INPUTS_DIR +export AERO_INPUTS_DIR=@AERO_INPUTS_DIR@ export AERO_DIAG_TABLE="${PARMgfs}/ufs/fv3/diag_table.aero" export AERO_FIELD_TABLE="${PARMgfs}/ufs/fv3/field_table.aero" diff --git a/parm/config/gfs/config.base b/parm/config/gfs/config.base index ccb05abe88..4f702f9668 100644 --- a/parm/config/gfs/config.base +++ b/parm/config/gfs/config.base @@ -260,7 +260,7 @@ case "${APP}" in ;; *) echo "Unrecognized APP: '${APP}'" - exit 1 + exit 2 ;; esac @@ -462,7 +462,7 @@ export HPSSARCH="@HPSSARCH@" # save data to HPSS archive export LOCALARCH="@LOCALARCH@" # save data to local archive if [[ ${HPSSARCH} = "YES" ]] && [[ ${LOCALARCH} = "YES" ]]; then echo "Both HPSS and local archiving selected. Please choose one or the other." - exit 2 + exit 3 fi export ARCH_CYC=00 # Archive data at this cycle for warm_start capability export ARCH_WARMICFREQ=4 # Archive frequency in days for warm_start capability @@ -483,20 +483,4 @@ export OFFSET_START_HOUR=0 # Number of regional collectives to create soundings for export NUM_SND_COLLECTIVES=${NUM_SND_COLLECTIVES:-9} -# The tracker, genesis, and METplus jobs are not supported on CSPs yet -# TODO: we should place these in workflow/hosts/awspw.yaml as part of AWS/AZURE setup, not for general. -if [[ "${machine}" =~ "PW" ]]; then - export DO_TRACKER="NO" - export DO_GENESIS="NO" - export DO_METP="NO" - export DO_WAVE="NO" -fi - -# The tracker and genesis are not installed on Orion/Hercules yet; this requires spack-stack builds of the package. -# TODO: we should place these in workflow/hosts/[orion|hercules].yaml. -if [[ "${machine}" == "ORION" || "${machine}" == "HERCULES" ]]; then - export DO_TRACKER="NO" - export DO_GENESIS="NO" -fi - echo "END: config.base" diff --git a/parm/config/gfs/config.prepoceanobs b/parm/config/gfs/config.prepoceanobs index 0963a5c42d..3aeff8a3de 100644 --- a/parm/config/gfs/config.prepoceanobs +++ b/parm/config/gfs/config.prepoceanobs @@ -14,7 +14,12 @@ export OBS_LIST=@SOCA_OBS_LIST@ export OBS_YAML=${OBS_LIST} # ocean analysis needs own dmpdir until standard dmpdir has full ocean obs -export DMPDIR=@DMPDIR@ +use_exp_obs="@use_exp_obs@" +if [[ "${use_exp_obs}" == "YES" ]]; then + dmpdir_exp="@dmpdir_exp@" +fi + +export DMPDIR="${dmpdir_exp:-${DMPDIR}}" # For BUFR2IODA json and python scripts export JSON_TMPL_DIR="${PARMgfs}/gdas/ioda/bufr2ioda" diff --git a/parm/config/gfs/yaml/defaults.yaml b/parm/config/gfs/yaml/defaults.yaml index dfc67d1237..78caf46f5d 100644 --- a/parm/config/gfs/yaml/defaults.yaml +++ b/parm/config/gfs/yaml/defaults.yaml @@ -61,4 +61,9 @@ prepoceanobs: SOCA_INPUT_FIX_DIR: "${FIXgfs}/gdas/soca/72x35x25/soca" SOCA_OBS_LIST: "${PARMgfs}/gdas/soca/obs/obs_list.yaml" # TODO: This is also repeated in ocnanal OBSPREP_YAML: "${PARMgfs}/gdas/soca/obsprep/obsprep_config.yaml" - DMPDIR: "${BASE_DATA}/experimental_obs" + use_exp_obs: "YES" + dmpdir_exp: "${BASE_DATA}/experimental_obs" + +# config.aero has just a system-specific path to add. +# This is handled by the setup_expt.py, but it has to be told to write to it. +aero: {} diff --git a/workflow/generate_workflows.sh b/workflow/generate_workflows.sh index c2565140d3..6a4cb9910a 100755 --- a/workflow/generate_workflows.sh +++ b/workflow/generate_workflows.sh @@ -150,10 +150,12 @@ while [[ $# -gt 0 && "$1" != "--" ]]; do :) echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" _usage + exit 1 ;; *) echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" _usage + exit 1 ;; esac done diff --git a/workflow/hosts/awspw.yaml b/workflow/hosts/awspw.yaml index ef17d8f2f4..b98c838faa 100644 --- a/workflow/hosts/awspw.yaml +++ b/workflow/hosts/awspw.yaml @@ -24,4 +24,8 @@ LOCALARCH: 'NO' ATARDIR: '' # TODO: This will not yet work from AWS. MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' +DO_TRACKER: 'NO' +DO_GENESIS: 'NO' +DO_METP: 'NO' +SUPPORT_WAVES: 'NO' SUPPORTED_RESOLUTIONS: ['C48', 'C96'] # TODO: Test and support all cubed-sphere resolutions. diff --git a/workflow/hosts/azurepw.yaml b/workflow/hosts/azurepw.yaml index 1769f9ee19..4725e28962 100644 --- a/workflow/hosts/azurepw.yaml +++ b/workflow/hosts/azurepw.yaml @@ -24,4 +24,5 @@ LOCALARCH: 'NO' ATARDIR: '' # TODO: This will not yet work from AZURE. MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' +SUPPORT_WAVES: 'NO' SUPPORTED_RESOLUTIONS: ['C48', 'C96'] # TODO: Test and support all cubed-sphere resolutions. diff --git a/workflow/hosts/gaea.yaml b/workflow/hosts/gaea.yaml index 5a37b5dabf..23ac75ca03 100644 --- a/workflow/hosts/gaea.yaml +++ b/workflow/hosts/gaea.yaml @@ -26,3 +26,4 @@ ATARDIR: '${NOSCRUB}/archive_rotdir/${PSLOT}' MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' SUPPORTED_RESOLUTIONS: ['C1152', 'C768', 'C384', 'C192', 'C96', 'C48'] +AERO_INPUTS_DIR: /gpfs/f5/epic/proj-shared/global/glopara/data/gocart_emissions diff --git a/workflow/hosts/googlepw.yaml b/workflow/hosts/googlepw.yaml index daf6cd1eb2..1b979b6bc9 100644 --- a/workflow/hosts/googlepw.yaml +++ b/workflow/hosts/googlepw.yaml @@ -24,4 +24,5 @@ LOCALARCH: 'NO' ATARDIR: '' # TODO: This will not yet work from GOOGLE. MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' +SUPPORT_WAVES: 'NO' SUPPORTED_RESOLUTIONS: ['C48', 'C96'] # TODO: Test and support all cubed-sphere resolutions. diff --git a/workflow/hosts/hera.yaml b/workflow/hosts/hera.yaml index fa2c351aa1..e9e749ad3c 100644 --- a/workflow/hosts/hera.yaml +++ b/workflow/hosts/hera.yaml @@ -28,3 +28,4 @@ SUPPORTED_RESOLUTIONS: ['C1152', 'C768', 'C384', 'C192', 'C96', 'C48'] COMINecmwf: /scratch1/NCEPDEV/global/glopara/data/external_gempak/ecmwf COMINnam: /scratch1/NCEPDEV/global/glopara/data/external_gempak/nam COMINukmet: /scratch1/NCEPDEV/global/glopara/data/external_gempak/ukmet +AERO_INPUTS_DIR: /scratch1/NCEPDEV/global/glopara/data/gocart_emissions diff --git a/workflow/hosts/hercules.yaml b/workflow/hosts/hercules.yaml index 73fde6cde6..f528761cf1 100644 --- a/workflow/hosts/hercules.yaml +++ b/workflow/hosts/hercules.yaml @@ -24,7 +24,10 @@ LOCALARCH: 'NO' ATARDIR: '${NOSCRUB}/archive_rotdir/${PSLOT}' MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' +DO_TRACKER: 'NO' +DO_GENESIS: 'NO' SUPPORTED_RESOLUTIONS: ['C1152', 'C768', 'C384', 'C192', 'C96', 'C48'] COMINecmwf: /work/noaa/global/glopara/data/external_gempak/ecmwf COMINnam: /work/noaa/global/glopara/data/external_gempak/nam COMINukmet: /work/noaa/global/glopara/data/external_gempak/ukmet +AERO_INPUTS_DIR: /work2/noaa/global/wkolczyn/noscrub/global-workflow/gocart_emissions diff --git a/workflow/hosts/jet.yaml b/workflow/hosts/jet.yaml index a53224fe52..737e2e7f94 100644 --- a/workflow/hosts/jet.yaml +++ b/workflow/hosts/jet.yaml @@ -28,3 +28,4 @@ SUPPORTED_RESOLUTIONS: ['C384', 'C192', 'C96', 'C48'] COMINecmwf: /mnt/lfs5/HFIP/hfv3gfs/glopara/data/external_gempak/ecmwf COMINnam: /mnt/lfs5/HFIP/hfv3gfs/glopara/data/external_gempak/nam COMINukmet: /mnt/lfs5/HFIP/hfv3gfs/glopara/data/external_gempak/ukmet +AERO_INPUTS_DIR: /lfs5/HFIP/hfv3gfs/glopara/data/gocart_emissions diff --git a/workflow/hosts/orion.yaml b/workflow/hosts/orion.yaml index d47b2b2bab..985c24c6fb 100644 --- a/workflow/hosts/orion.yaml +++ b/workflow/hosts/orion.yaml @@ -24,7 +24,10 @@ LOCALARCH: 'NO' ATARDIR: '${NOSCRUB}/archive_rotdir/${PSLOT}' MAKE_NSSTBUFR: 'NO' MAKE_ACFTBUFR: 'NO' +DO_TRACKER: 'NO' +DO_GENESIS: 'NO' SUPPORTED_RESOLUTIONS: ['C1152', 'C768', 'C384', 'C192', 'C96', 'C48'] COMINecmwf: /work/noaa/global/glopara/data/external_gempak/ecmwf COMINnam: /work/noaa/global/glopara/data/external_gempak/nam COMINukmet: /work/noaa/global/glopara/data/external_gempak/ukmet +AERO_INPUTS_DIR: /work2/noaa/global/wkolczyn/noscrub/global-workflow/gocart_emissions diff --git a/workflow/hosts/s4.yaml b/workflow/hosts/s4.yaml index b93fefec39..2e77c112b1 100644 --- a/workflow/hosts/s4.yaml +++ b/workflow/hosts/s4.yaml @@ -25,3 +25,4 @@ ATARDIR: '${NOSCRUB}/archive_rotdir/${PSLOT}' MAKE_NSSTBUFR: 'YES' MAKE_ACFTBUFR: 'YES' SUPPORTED_RESOLUTIONS: ['C384', 'C192', 'C96', 'C48'] +AERO_INPUTS_DIR: /data/prod/glopara/gocart_emissions diff --git a/workflow/hosts/wcoss2.yaml b/workflow/hosts/wcoss2.yaml index 15f0705f91..4fb4b1d64a 100644 --- a/workflow/hosts/wcoss2.yaml +++ b/workflow/hosts/wcoss2.yaml @@ -28,3 +28,4 @@ SUPPORTED_RESOLUTIONS: ['C1152', 'C768', 'C384', 'C192', 'C96', 'C48'] COMINecmwf: /lfs/h2/emc/global/noscrub/emc.global/data/external_gempak/ecmwf COMINnam: /lfs/h2/emc/global/noscrub/emc.global/data/external_gempak/nam COMINukmet: /lfs/h2/emc/global/noscrub/emc.global/data/external_gempak/ukmet +AERO_INPUTS_DIR: /lfs/h2/emc/global/noscrub/emc.global/data/gocart_emissions diff --git a/workflow/setup_expt.py b/workflow/setup_expt.py index f32203e600..27da4943d3 100755 --- a/workflow/setup_expt.py +++ b/workflow/setup_expt.py @@ -7,7 +7,6 @@ import os import glob import shutil -import warnings from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, SUPPRESS, ArgumentTypeError from hosts import Host @@ -29,7 +28,7 @@ def makedirs_if_missing(dirname): os.makedirs(dirname) -def fill_EXPDIR(inputs): +def fill_expdir(inputs): """ Method to copy config files from workflow to experiment directory INPUTS: @@ -50,18 +49,31 @@ def fill_EXPDIR(inputs): def update_configs(host, inputs): def _update_defaults(dict_in: dict) -> dict: + # Given an input dict_in of the form + # {defaults: {config_name: {var1: value1, ...}, }, config_name: {var1: value1, ...}} + # Replace values in ['defaults']['config_name']['var1'] with ['config_name']['var1'] + # and return the ['defaults'] subdictionary as its own new dictionary. defaults = dict_in.pop('defaults', AttrDict()) + if 'defaults' in defaults: + _update_defaults(defaults) defaults.update(dict_in) return defaults - # Read in the YAML file to fill out templates and override host defaults + # Convert the inputs to an AttrDict data = AttrDict(host.info, **inputs.__dict__) + + # Read in the YAML file to fill out templates data.HOMEgfs = _top yaml_path = inputs.yaml if not os.path.exists(yaml_path): - raise IOError(f'YAML file does not exist, check path:' + yaml_path) - yaml_dict = _update_defaults(AttrDict(parse_j2yaml(yaml_path, data))) + raise FileNotFoundError(f'YAML file does not exist, check path: {yaml_path}') + yaml_dict = parse_j2yaml(yaml_path, data) + + # yaml_dict is in the form {defaults: {key1: val1, ...}, base: {key1: val1, ...}, ...} + # _update_defaults replaces any keys/values in defaults with matching keys in base + yaml_dict = _update_defaults(yaml_dict) + # Override the YAML defaults with the host-specific capabilities # First update config.base edit_baseconfig(host, inputs, yaml_dict) @@ -73,7 +85,7 @@ def _update_defaults(dict_in: dict) -> dict: stage_dict = dict(stage_dict, **host_dict) stage_input = f'{inputs.configdir}/config.stage_ic' stage_output = f'{inputs.expdir}/{inputs.pslot}/config.stage_ic' - edit_config(stage_input, stage_output, stage_dict) + edit_config(stage_input, stage_output, host_dict, stage_dict) # Loop over other configs and update them with defaults for cfg in yaml_dict.keys(): @@ -81,7 +93,7 @@ def _update_defaults(dict_in: dict) -> dict: continue cfg_file = f'{inputs.expdir}/{inputs.pslot}/config.{cfg}' cfg_dict = get_template_dict(yaml_dict[cfg]) - edit_config(cfg_file, cfg_file, cfg_dict) + edit_config(cfg_file, cfg_file, host_dict, cfg_dict) return @@ -92,20 +104,19 @@ def edit_baseconfig(host, inputs, yaml_dict): to `EXPDIR/pslot/config.base` """ - tmpl_dict = { + # Create base_dict which holds templated variables to be written to config.base + base_dict = { "@HOMEgfs@": _top, "@MACHINE@": host.machine.upper()} - # Replace host related items - extend_dict = get_template_dict(host.info) - tmpl_dict = dict(tmpl_dict, **extend_dict) - if inputs.start in ["warm"]: is_warm_start = ".true." elif inputs.start in ["cold"]: is_warm_start = ".false." + else: + raise ValueError(f"Invalid start type: {inputs.start}") - extend_dict = dict() + # Construct a dictionary from user inputs extend_dict = { "@PSLOT@": inputs.pslot, "@SDATE@": datetime_to_YMDH(inputs.idate), @@ -121,35 +132,37 @@ def edit_baseconfig(host, inputs, yaml_dict): "@APP@": inputs.app, "@NMEM_ENS@": getattr(inputs, 'nens', 0) } - tmpl_dict = dict(tmpl_dict, **extend_dict) - extend_dict = dict() if getattr(inputs, 'nens', 0) > 0: - extend_dict = { - "@CASEENS@": f'C{inputs.resensatmos}', - } - tmpl_dict = dict(tmpl_dict, **extend_dict) + extend_dict['@CASEENS@'] = f'C{inputs.resensatmos}' - extend_dict = dict() if inputs.mode in ['cycled']: - extend_dict = { - "@DOHYBVAR@": "YES" if inputs.nens > 0 else "NO", - } - tmpl_dict = dict(tmpl_dict, **extend_dict) + extend_dict["@DOHYBVAR@"] = "YES" if inputs.nens > 0 else "NO" - try: - tmpl_dict = dict(tmpl_dict, **get_template_dict(yaml_dict['base'])) - except KeyError: - pass + # Further extend/redefine base_dict with extend_dict + base_dict = dict(base_dict, **extend_dict) + + # Add/override 'base'-specific declarations in base_dict + if 'base' in yaml_dict: + base_dict = dict(base_dict, **get_template_dict(yaml_dict['base'])) base_input = f'{inputs.configdir}/config.base' base_output = f'{inputs.expdir}/{inputs.pslot}/config.base' - edit_config(base_input, base_output, tmpl_dict) + edit_config(base_input, base_output, host.info, base_dict) return -def edit_config(input_config, output_config, config_dict): +def edit_config(input_config, output_config, host_info, config_dict): + """ + Given a templated input_config filename, parse it based on config_dict and + host_info and write it out to the output_config filename. + """ + + # Override defaults with machine-specific capabilties + # e.g. some machines are not able to run metp jobs + host_dict = get_template_dict(host_info) + config_dict = dict(config_dict, **host_dict) # Read input config with open(input_config, 'rt') as fi: @@ -173,9 +186,17 @@ def edit_config(input_config, output_config, config_dict): def get_template_dict(input_dict): + # Reads a templated input dictionary and updates the output + output_dict = dict() + for key, value in input_dict.items(): - output_dict[f'@{key}@'] = value + # In some cases, the same config may be templated twice + # Prevent adding additional "@"s + if "@" in key: + output_dict[f'{key}'] = value + else: + output_dict[f'@{key}@'] = value return output_dict @@ -350,6 +371,7 @@ def query_and_clean(dirname, force_clean=False): def validate_user_request(host, inputs): supp_res = host.info['SUPPORTED_RESOLUTIONS'] + supp_waves = host.info.get('SUPPORT_WAVES', 'YES') machine = host.machine for attr in ['resdetatmos', 'resensatmos']: try: @@ -359,6 +381,9 @@ def validate_user_request(host, inputs): if expt_res not in supp_res: raise NotImplementedError(f"Supported resolutions on {machine} are:\n{', '.join(supp_res)}") + if "W" in inputs.app and supp_waves == "NO": + raise NotImplementedError(f"Waves are not supported on {machine}") + def get_ocean_resolution(resdetatmos): """ @@ -397,7 +422,7 @@ def main(*argv): if create_expdir: makedirs_if_missing(expdir) - fill_EXPDIR(user_inputs) + fill_expdir(user_inputs) update_configs(host, user_inputs) print(f"*" * 100)