From 0b7692a07f88c194b602fc12feb7bef6b80186db Mon Sep 17 00:00:00 2001 From: Ryan Forsyth Date: Thu, 22 Feb 2024 17:40:12 -0600 Subject: [PATCH] Add e3sm_to_cmip_environment_commands parameter --- tests/integration/generated/test_bundles_chrysalis.cfg | 1 + .../integration/generated/test_complete_run_chrysalis.cfg | 1 + tests/integration/generated/test_debug_chrysalis.cfg | 5 +++-- tests/integration/template_bundles.cfg | 1 + tests/integration/template_complete_run.cfg | 1 + tests/integration/template_debug.cfg | 5 +++-- tests/integration/utils.py | 3 +++ tests/test_sections.py | 8 ++++++++ zppy/templates/default.ini | 5 +++++ zppy/templates/ts.bash | 2 ++ 10 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/integration/generated/test_bundles_chrysalis.cfg b/tests/integration/generated/test_bundles_chrysalis.cfg index 95068a36..7e999859 100644 --- a/tests/integration/generated/test_bundles_chrysalis.cfg +++ b/tests/integration/generated/test_bundles_chrysalis.cfg @@ -36,6 +36,7 @@ years = "1850:1854:2", "1850:1854:4", [ts] active = True bundle = "bundle1" +e3sm_to_cmip_environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_to_cmip_20240223" years = "1850:1854:2", [[ atm_monthly_180x360_aave ]] diff --git a/tests/integration/generated/test_complete_run_chrysalis.cfg b/tests/integration/generated/test_complete_run_chrysalis.cfg index bb222b8d..a420e8b9 100644 --- a/tests/integration/generated/test_complete_run_chrysalis.cfg +++ b/tests/integration/generated/test_complete_run_chrysalis.cfg @@ -28,6 +28,7 @@ years = "1850:1854:2", "1850:1854:4", [ts] active = True +e3sm_to_cmip_environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_to_cmip_20240223" walltime = "00:30:00" years = "1850:1854:2", diff --git a/tests/integration/generated/test_debug_chrysalis.cfg b/tests/integration/generated/test_debug_chrysalis.cfg index ae2777fe..22158126 100644 --- a/tests/integration/generated/test_debug_chrysalis.cfg +++ b/tests/integration/generated/test_debug_chrysalis.cfg @@ -36,12 +36,13 @@ years = "1850:1854:2", vars = "PRECT" [[ land_monthly ]] + e3sm_to_cmip_environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_to_cmip_20240223" extra_vars = "landfrac" frequency = "monthly" input_files = "elm.h0" input_subdir = "archive/lnd/hist" - #vars = "LAISHA,LAISUN" - vars = "FSH,RH2M" + vars = "LAISHA,LAISUN" + #vars = "FSH,RH2M" ts_fmt = "cmip" [ilamb] diff --git a/tests/integration/template_bundles.cfg b/tests/integration/template_bundles.cfg index d6516597..b61a1323 100644 --- a/tests/integration/template_bundles.cfg +++ b/tests/integration/template_bundles.cfg @@ -36,6 +36,7 @@ years = "1850:1854:2", "1850:1854:4", [ts] active = True bundle = "bundle1" +e3sm_to_cmip_environment_commands = "#expand e3sm_to_cmip_environment_commands#" years = "1850:1854:2", [[ atm_monthly_180x360_aave ]] diff --git a/tests/integration/template_complete_run.cfg b/tests/integration/template_complete_run.cfg index 427f8655..0eb5c140 100644 --- a/tests/integration/template_complete_run.cfg +++ b/tests/integration/template_complete_run.cfg @@ -28,6 +28,7 @@ years = "1850:1854:2", "1850:1854:4", [ts] active = True +e3sm_to_cmip_environment_commands = "#expand e3sm_to_cmip_environment_commands#" walltime = "00:30:00" years = "1850:1854:2", diff --git a/tests/integration/template_debug.cfg b/tests/integration/template_debug.cfg index 11fce44d..37b96e47 100644 --- a/tests/integration/template_debug.cfg +++ b/tests/integration/template_debug.cfg @@ -36,12 +36,13 @@ years = "1850:1854:2", vars = "PRECT" [[ land_monthly ]] + e3sm_to_cmip_environment_commands = "#expand e3sm_to_cmip_environment_commands#" extra_vars = "landfrac" frequency = "monthly" input_files = "elm.h0" input_subdir = "archive/lnd/hist" - #vars = "LAISHA,LAISUN" - vars = "FSH,RH2M" + vars = "LAISHA,LAISUN" + #vars = "FSH,RH2M" ts_fmt = "cmip" [ilamb] diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 3cbad951..75f5b37a 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -138,6 +138,7 @@ def get_chyrsalis_expansions(config): # To run this test, replace conda environment with your e3sm_diags dev environment "diags_environment_commands": "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_diags_20240214", "diags_walltime": "5:00:00", + "e3sm_to_cmip_environment_commands": "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_to_cmip_20240223", "environment_commands_test": "source /lcrc/soft/climate/e3sm-unified/test_e3sm_unified_1.9.0rc16_chrysalis.sh", "expected_dir": "/lcrc/group/e3sm/public_html/zppy_test_resources/", "mpas_analysis_walltime": "00:30:00", @@ -163,6 +164,7 @@ def get_compy_expansions(config): # To run this test, replace conda environment with your e3sm_diags dev environment "diags_environment_commands": "source /qfs/people/fors729/mambaforge/etc/profile.d/conda.sh; conda activate e3sm_diags_20230914", "diags_walltime": "03:00:00", + "e3sm_to_cmip_environment_commands": "", "environment_commands_test": "source /share/apps/E3SM/conda_envs/test_e3sm_unified_1.9.0rc16_compy.sh", "expected_dir": "/compyfs/www/zppy_test_resources/", "mpas_analysis_walltime": "00:30:00", @@ -188,6 +190,7 @@ def get_perlmutter_expansions(config): # To run this test, replace conda environment with your e3sm_diags dev environment "diags_environment_commands": "source /global/homes/f/forsyth/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_diags_20230914", "diags_walltime": "6:00:00", + "e3sm_to_cmip_environment_commands": "", "environment_commands_test": "source /global/common/software/e3sm/anaconda_envs/test_e3sm_unified_1.9.0rc16_pm-cpu.sh", "expected_dir": "/global/cfs/cdirs/e3sm/www/zppy_test_resources/", "mpas_analysis_walltime": "01:00:00", diff --git a/tests/test_sections.py b/tests/test_sections.py index 9b6d3851..4bbe8180 100644 --- a/tests/test_sections.py +++ b/tests/test_sections.py @@ -71,6 +71,7 @@ def test_sections(self): "constraint": "", "debug": False, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "frequency": "monthly", "grid": "", @@ -124,6 +125,7 @@ def test_sections(self): "debug": False, "dpf": 30, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "extra_vars": "", "frequency": "monthly", @@ -176,6 +178,7 @@ def test_sections(self): "constraint": "", "debug": False, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "exclude": False, "frequency": "monthly", @@ -228,6 +231,7 @@ def test_subsections(self): "constraint": "", "debug": False, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "frequency": "monthly", "grid": "", @@ -301,6 +305,7 @@ def test_subsections(self): "debug": False, "dpf": 30, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "extra_vars": "", "frequency": "monthly", @@ -339,6 +344,7 @@ def test_subsections(self): "debug": False, "dpf": 30, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "extra_vars": "", "frequency": "monthly", @@ -407,6 +413,7 @@ def test_subsections(self): "constraint": "", "debug": False, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "exclude": False, "frequency": "monthly", @@ -440,6 +447,7 @@ def test_subsections(self): "constraint": "", "debug": False, "dry_run": False, + "e3sm_to_cmip_environment_commands": "", "environment_commands": "", "exclude": False, "frequency": "monthly", diff --git a/zppy/templates/default.ini b/zppy/templates/default.ini index 28bd4d11..1cbf8b2a 100644 --- a/zppy/templates/default.ini +++ b/zppy/templates/default.ini @@ -17,6 +17,11 @@ debug = boolean(default=False) # diagnostics_base_path -- NOTE: this parameter is created internally # This should be set to True if you don't want the batch jobs to be submitted dry_run = boolean(default=False) +# Set up the environment for e3sm_to_cmip. +# Because e3sm_to_cmip is used internally in the `ts` task, +# the `environment_commands` parameter below is insufficient +# and this parameter must be used instead. +e3sm_to_cmip_environment_commands = string(default="") # Set up the environment -- this is where you can tell zppy to use a custom conda environment. # To use a custom conda environment, you can set `environment_commands="source ; conda activate "`. environment_commands = string(default="") diff --git a/zppy/templates/ts.bash b/zppy/templates/ts.bash index 996dcd3b..6c555801 100644 --- a/zppy/templates/ts.bash +++ b/zppy/templates/ts.bash @@ -144,6 +144,7 @@ EOF input_dir={{ output }}/post/{{ component }}/{{ grid }}/ts/{{ frequency }}/{{ '%dyr' % (ypf) }} dest_cmip={{ output }}/post/{{ component }}/{{ grid }}/cmip_ts/{{ frequency }} mkdir -p ${dest_cmip} + {{ e3sm_to_cmip_environment_commands }} srun -N 1 e3sm_to_cmip \ --output-path \ ${dest_cmip}/${tmp_dir} \ @@ -173,6 +174,7 @@ EOF echo 'ERROR (4)' > {{ prefix }}.status exit 4 fi + {{ environment_commands }} # Move output ts files to final destination mv ${dest_cmip}/${tmp_dir}/CMIP6/CMIP/*/*/*/*/*/*/*/*/*.nc ${dest_cmip}