From 122b823e80c7c189db94b9ffcbdd79d55ca870aa Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Thu, 5 Mar 2026 19:05:01 +0000 Subject: [PATCH 01/20] Created adjoint namelist proxy variable, equivalent to COMPUTE_ANNEXED_DOFS in PSyclone config but only applying to PSyKAl lite adjoints that need it --- .../adjoint_tests/example/configuration.nml | 4 ++ .../rose-meta/lfric-adjoint_tests/versions.py | 18 ++++++-- .../example/configuration.nml | 3 ++ .../example_forecast/configuration.nml | 3 ++ .../example_forecast_pseudo/configuration.nml | 3 ++ .../configuration_op.nml | 3 ++ .../example_id_tlm_tests/configuration.nml | 4 ++ .../example_tlm_forecast_tl/configuration.nml | 3 ++ .../configuration_op.nml | 3 ++ .../example_tlm_tests/configuration.nml | 3 ++ .../rose-meta/jedi_common/versions.py | 19 ++++++-- .../rose-meta/jedi_forecast/versions.py | 19 ++++++-- .../jedi_forecast_pseudo/versions.py | 19 ++++++-- .../rose-meta/jedi_id_tlm_tests/versions.py | 19 ++++++-- .../rose-meta/jedi_lfric_tests/versions.py | 19 ++++++-- .../jedi_tlm_forecast_tl/versions.py | 19 ++++++-- .../rose-meta/jedi_tlm_tests/versions.py | 19 ++++++-- .../jedi_lfric_interface/versions.py | 14 ++++++ rose-stem/app/adjoint_tests/rose-app.conf | 6 ++- rose-stem/app/jedi_forecast/rose-app.conf | 4 ++ .../app/jedi_forecast_pseudo/rose-app.conf | 4 ++ rose-stem/app/jedi_id_tlm_tests/rose-app.conf | 4 ++ rose-stem/app/jedi_lfric_tests/rose-app.conf | 4 ++ .../app/jedi_tlm_forecast_tl/rose-app.conf | 4 ++ rose-stem/app/jedi_tlm_tests/rose-app.conf | 4 ++ .../lfric-adjoint/HEAD/rose-meta.conf | 16 +++++++ .../rose-meta/lfric-adjoint/versions.py | 18 ++++++-- .../psy/adj_sci_psykal_builtin_light_mod.f90 | 46 +++++++++++++------ 28 files changed, 261 insertions(+), 43 deletions(-) diff --git a/applications/adjoint_tests/example/configuration.nml b/applications/adjoint_tests/example/configuration.nml index 6061f8833..208ed3747 100644 --- a/applications/adjoint_tests/example/configuration.nml +++ b/applications/adjoint_tests/example/configuration.nml @@ -1,3 +1,7 @@ +&adjoint +l_compute_annexed_dofs=.false., +/ + &base_mesh file_prefix='mesh_C12_MG', geometry='spherical', diff --git a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py index 01798ad2b..dd01b1fd8 100644 --- a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py +++ b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py @@ -20,14 +20,26 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Set computation of annexed dofs to false for adjoint_tests + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/example/configuration.nml b/applications/jedi_lfric_tests/example/configuration.nml index ab6828519..b101185dc 100644 --- a/applications/jedi_lfric_tests/example/configuration.nml +++ b/applications/jedi_lfric_tests/example/configuration.nml @@ -1,3 +1,6 @@ +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12_MG', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_forecast/configuration.nml b/applications/jedi_lfric_tests/example_forecast/configuration.nml index 220c17be0..889880ee9 100644 --- a/applications/jedi_lfric_tests/example_forecast/configuration.nml +++ b/applications/jedi_lfric_tests/example_forecast/configuration.nml @@ -26,6 +26,9 @@ forecast_length='P0DT6H0M0S', #### Configure LFRic +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_forecast_pseudo/configuration.nml b/applications/jedi_lfric_tests/example_forecast_pseudo/configuration.nml index f3a627297..099868b55 100644 --- a/applications/jedi_lfric_tests/example_forecast_pseudo/configuration.nml +++ b/applications/jedi_lfric_tests/example_forecast_pseudo/configuration.nml @@ -29,6 +29,9 @@ time_step='P0DT1H0M0S', #### Configure LFRic +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_forecast_pseudo/configuration_op.nml b/applications/jedi_lfric_tests/example_forecast_pseudo/configuration_op.nml index e392cbdd7..8432141ea 100644 --- a/applications/jedi_lfric_tests/example_forecast_pseudo/configuration_op.nml +++ b/applications/jedi_lfric_tests/example_forecast_pseudo/configuration_op.nml @@ -29,6 +29,9 @@ time_step='P0DT1H0M0S', #### Configure LFRic +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_id_tlm_tests/configuration.nml b/applications/jedi_lfric_tests/example_id_tlm_tests/configuration.nml index e1a1eca60..a006a3d58 100644 --- a/applications/jedi_lfric_tests/example_id_tlm_tests/configuration.nml +++ b/applications/jedi_lfric_tests/example_id_tlm_tests/configuration.nml @@ -34,6 +34,10 @@ time_step='P0DT1H0M0S', adjoint_test_tolerance=1.0e-4, forecast_length='P0DT6H0M0S', / + +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12_MG', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration.nml b/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration.nml index 3ea39dd10..219a22368 100644 --- a/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration.nml +++ b/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration.nml @@ -34,6 +34,9 @@ time_step='P0DT1H0M0S', adjoint_test_tolerance=1.0e-3, forecast_length='P0DT6H0M0S', / +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12_MG', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration_op.nml b/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration_op.nml index f472b5066..bd2fc330e 100644 --- a/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration_op.nml +++ b/applications/jedi_lfric_tests/example_tlm_forecast_tl/configuration_op.nml @@ -38,6 +38,9 @@ forecast_length='P0DT6H0M0S', #### Configure LFRic +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12', geometry='spherical', diff --git a/applications/jedi_lfric_tests/example_tlm_tests/configuration.nml b/applications/jedi_lfric_tests/example_tlm_tests/configuration.nml index da9b864b8..c96b233e8 100644 --- a/applications/jedi_lfric_tests/example_tlm_tests/configuration.nml +++ b/applications/jedi_lfric_tests/example_tlm_tests/configuration.nml @@ -34,6 +34,9 @@ time_step='P0DT1H0M0S', adjoint_test_tolerance=1.0e-2, forecast_length='P0DT6H0M0S', / +&adjoint +l_compute_annexed_dofs=.true., +/ &base_mesh file_prefix='mesh_C12_MG', geometry='spherical', diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py index 01798ad2b..0fea7b276 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py @@ -20,14 +20,27 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py index 01798ad2b..e5ba16bb4 100644 --- a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py +++ b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py @@ -31,3 +31,17 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.2" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/rose-stem/app/adjoint_tests/rose-app.conf b/rose-stem/app/adjoint_tests/rose-app.conf index 4dafac183..9d6383b90 100644 --- a/rose-stem/app/adjoint_tests/rose-app.conf +++ b/rose-stem/app/adjoint_tests/rose-app.conf @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=(namelist:aerosol) +source=namelist:adjoint + = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) = namelist:boundaries @@ -99,6 +100,9 @@ source=(namelist:aerosol) = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.false. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_forecast/rose-app.conf b/rose-stem/app/jedi_forecast/rose-app.conf index 42c17cee6..3f09443b1 100644 --- a/rose-stem/app/jedi_forecast/rose-app.conf +++ b/rose-stem/app/jedi_forecast/rose-app.conf @@ -23,6 +23,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings + = namelist:adjoint = namelist:base_mesh = namelist:boundaries = namelist:checks @@ -94,6 +95,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf index 5734e167c..0d3795ac3 100644 --- a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf +++ b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf @@ -21,6 +21,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_pseudo_model + = namelist:adjoint = namelist:base_mesh = namelist:boundaries = namelist:checks @@ -92,6 +93,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf index dc2a904a2..7716e7c83 100644 --- a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf @@ -23,6 +23,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings + = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_lfric_tests/rose-app.conf b/rose-stem/app/jedi_lfric_tests/rose-app.conf index 07157baf5..ce6ebc62f 100644 --- a/rose-stem/app/jedi_lfric_tests/rose-app.conf +++ b/rose-stem/app/jedi_lfric_tests/rose-app.conf @@ -23,6 +23,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings + = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf index b446f4c69..950156da4 100644 --- a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf +++ b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf @@ -23,6 +23,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings + = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_tests/rose-app.conf b/rose-stem/app/jedi_tlm_tests/rose-app.conf index 6e8c2a776..56890d29e 100644 --- a/rose-stem/app/jedi_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_tlm_tests/rose-app.conf @@ -23,6 +23,7 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings + = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/science/adjoint/rose-meta/lfric-adjoint/HEAD/rose-meta.conf b/science/adjoint/rose-meta/lfric-adjoint/HEAD/rose-meta.conf index 4530c7b1e..455ec1ee4 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/HEAD/rose-meta.conf +++ b/science/adjoint/rose-meta/lfric-adjoint/HEAD/rose-meta.conf @@ -1 +1,17 @@ import=lfric-linear/HEAD + +[namelist:adjoint] +compulsory=true +description=Provides extra information for the adjoint model. +help= +ns=namelist/Adjoint +sort-key=Section-A07 +title=Adjoint + +[namelist:adjoint=l_compute_annexed_dofs] +compulsory=true +description=Boolean to control whether to loop into annexed dofs or not. MUST be false in the adjoint_tests app, otherwise true. +help=If true then loop into annexed dofs in PSyKAl lite code, else only loop into owned dofs and set halo dirty +!kind=default +ns=namelist/Adjoint/Testing +type=logical diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 01798ad2b..ae3eb5494 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -20,14 +20,26 @@ def __repr__(self): """ Copy this template and complete to add your macro - class vnXX_txxx(MacroUpgrade): # Upgrade macro for by - BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" - def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn32_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.2_t322" + + def upgrade(self, config, meta_config=None): + # Set computation of annexed dofs to true for adjoint + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 b/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 index e831bde6d..650fcfdb8 100644 --- a/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 +++ b/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 @@ -7,6 +7,7 @@ !> @brief Adjoint of the sci_psykal_builtin_light_mod routines module adj_sci_psykal_builtin_light_mod + use adjoint_config_mod, only: l_compute_annexed_dofs use, intrinsic :: iso_fortran_env, only : real32, real64 use constants_mod, only: r_def, i_def use field_mod, only: field_type, field_proxy_type @@ -65,12 +66,17 @@ subroutine invoke_adj_copy_field_32_64(fsrce_32, fdest_64) ! Set-up all of the loop bounds ! loop0_start = 1 - if (fsrce_32_proxy%is_dirty(depth=1)) then - ! only copy the owned dofs - loop0_stop = fdest_64_proxy%vspace%get_last_dof_annexed() + if (l_compute_annexed_dofs) then + if (fsrce_32_proxy%is_dirty(depth=1)) then + ! only copy the owned + annexed dofs + loop0_stop = fdest_64_proxy%vspace%get_last_dof_annexed() + else + ! copy the 1st halo row as well + loop0_stop = fdest_64_proxy%vspace%get_last_dof_halo(1) + end if else - ! copy the 1st halo row as well - loop0_stop = fdest_64_proxy%vspace%get_last_dof_halo(1) + ! only copy the owned dofs + loop0_stop = fdest_64_proxy%vspace%get_last_dof_owned() end if ! ! Call kernels and communication routines @@ -131,12 +137,17 @@ subroutine invoke_adj_copy_field_32_32(fsrce_32, fdest_32) ! Set-up all of the loop bounds ! loop0_start = 1 - if (fsrce_32_proxy%is_dirty(depth=1)) then - ! only copy the owned dofs - loop0_stop = fdest_32_proxy%vspace%get_last_dof_annexed() + if (l_compute_annexed_dofs) then + if (fsrce_32_proxy%is_dirty(depth=1)) then + ! only copy the owned + annexed dofs + loop0_stop = fdest_32_proxy%vspace%get_last_dof_annexed() + else + ! copy the 1st halo row as well + loop0_stop = fdest_32_proxy%vspace%get_last_dof_halo(1) + end if else - ! copy the 1st halo row as well - loop0_stop = fdest_32_proxy%vspace%get_last_dof_halo(1) + ! only copy the owned dofs + loop0_stop = fdest_32_proxy%vspace%get_last_dof_owned() end if ! ! Call kernels and communication routines @@ -197,12 +208,17 @@ subroutine invoke_adj_copy_field_64_64(fsrce_64, fdest_64) ! Set-up all of the loop bounds ! loop0_start = 1 - if (fsrce_64_proxy%is_dirty(depth=1)) then - ! only copy the owned dofs - loop0_stop = fdest_64_proxy%vspace%get_last_dof_annexed() + if (l_compute_annexed_dofs) then + if (fsrce_64_proxy%is_dirty(depth=1)) then + ! only copy the owned + annexed dofs + loop0_stop = fdest_64_proxy%vspace%get_last_dof_annexed() + else + ! copy the 1st halo row as well + loop0_stop = fdest_64_proxy%vspace%get_last_dof_halo(1) + end if else - ! copy the 1st halo row as well - loop0_stop = fdest_64_proxy%vspace%get_last_dof_halo(1) + ! only copy the owned dofs + loop0_stop = fdest_64_proxy%vspace%get_last_dof_owned() end if ! ! Call kernels and communication routines From 3d80d173a7eb27a7db0f84dd38b033eadf19dfdf Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Thu, 5 Mar 2026 19:15:23 +0000 Subject: [PATCH 02/20] Fixed upgrade macros --- .../adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py | 2 +- .../jedi_lfric_tests/rose-meta/jedi_common/versions.py | 4 ++-- .../jedi_lfric_tests/rose-meta/jedi_forecast/versions.py | 4 ++-- .../rose-meta/jedi_forecast_pseudo/versions.py | 4 ++-- .../jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py | 4 ++-- .../jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py | 4 ++-- .../rose-meta/jedi_tlm_forecast_tl/versions.py | 4 ++-- .../jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py | 4 ++-- .../rose-meta/jedi_lfric_interface/versions.py | 4 ++-- science/adjoint/rose-meta/lfric-adjoint/versions.py | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py index dd01b1fd8..2d32d2482 100644 --- a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py +++ b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py @@ -34,7 +34,7 @@ class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.2_t322" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Set computation of annexed dofs to false for adjoint_tests diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py index 0fea7b276..7aaad1e64 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py @@ -33,8 +33,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Commands From: rose-meta/lfric-adjoint diff --git a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py index e5ba16bb4..bb73e1d56 100644 --- a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py +++ b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py @@ -35,8 +35,8 @@ def upgrade(self, config, meta_config=None): class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" - BEFORE_TAG = "vn3.2" - AFTER_TAG = "vn3.2_t322" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Set computation of annexed dofs to true for adjoint diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index ae3eb5494..e79cbb31b 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -34,7 +34,7 @@ class vn32_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.2_t322" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): # Set computation of annexed dofs to true for adjoint From c976b7e4f4d7537e4c9ff33ed921b03b0264235d Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Thu, 5 Mar 2026 19:18:33 +0000 Subject: [PATCH 03/20] Added PSyclone issue to where namelist variable is used --- .../source/psy/adj_sci_psykal_builtin_light_mod.f90 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 b/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 index 650fcfdb8..852911338 100644 --- a/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 +++ b/science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90 @@ -66,6 +66,9 @@ subroutine invoke_adj_copy_field_32_64(fsrce_32, fdest_64) ! Set-up all of the loop bounds ! loop0_start = 1 + ! Need namelist variable to replicate COMPUTE_ANNEXED_DOFS + ! from PSyclone config. This is a workaround until + ! https://github.com/stfc/PSyclone/issues/2674 is fixed. if (l_compute_annexed_dofs) then if (fsrce_32_proxy%is_dirty(depth=1)) then ! only copy the owned + annexed dofs @@ -137,6 +140,9 @@ subroutine invoke_adj_copy_field_32_32(fsrce_32, fdest_32) ! Set-up all of the loop bounds ! loop0_start = 1 + ! Need namelist variable to replicate COMPUTE_ANNEXED_DOFS + ! from PSyclone config. This is a workaround until + ! https://github.com/stfc/PSyclone/issues/2674 is fixed. if (l_compute_annexed_dofs) then if (fsrce_32_proxy%is_dirty(depth=1)) then ! only copy the owned + annexed dofs @@ -208,6 +214,9 @@ subroutine invoke_adj_copy_field_64_64(fsrce_64, fdest_64) ! Set-up all of the loop bounds ! loop0_start = 1 + ! Need namelist variable to replicate COMPUTE_ANNEXED_DOFS + ! from PSyclone config. This is a workaround until + ! https://github.com/stfc/PSyclone/issues/2674 is fixed. if (l_compute_annexed_dofs) then if (fsrce_64_proxy%is_dirty(depth=1)) then ! only copy the owned + annexed dofs From 736692150bb48c60a04c9547d782fad3b25d1fd1 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Thu, 5 Mar 2026 19:28:54 +0000 Subject: [PATCH 04/20] Further fixes to upgrade macros --- .../adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py | 5 ++++- .../jedi_lfric_tests/rose-meta/jedi_common/versions.py | 5 ++++- .../jedi_lfric_tests/rose-meta/jedi_forecast/versions.py | 5 ++++- .../rose-meta/jedi_forecast_pseudo/versions.py | 5 ++++- .../jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py | 5 ++++- .../jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py | 5 ++++- .../rose-meta/jedi_tlm_forecast_tl/versions.py | 5 ++++- .../jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py | 5 ++++- .../rose-meta/jedi_lfric_interface/versions.py | 3 ++- science/adjoint/rose-meta/lfric-adjoint/versions.py | 5 ++++- 10 files changed, 38 insertions(+), 10 deletions(-) diff --git a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py index 2d32d2482..41443fb20 100644 --- a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py +++ b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py index 7aaad1e64..62d7e48de 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py index bb73e1d56..cc76f1a2c 100644 --- a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py +++ b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py @@ -32,7 +32,8 @@ def upgrade(self, config, meta_config=None): return config, self.reports """ -class vn32_t322(MacroUpgrade): + +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index e79cbb31b..cc76f1a2c 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -20,17 +20,20 @@ def __repr__(self): """ Copy this template and complete to add your macro + class vnXX_txxx(MacroUpgrade): # Upgrade macro for by + BEFORE_TAG = "vnX.X" AFTER_TAG = "vnX.X_txxx" + def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ -class vn32_t322(MacroUpgrade): +class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" BEFORE_TAG = "vn3.1" From b06a9eb0b665374e0c8570a75a4b3f1eab8e96c5 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:29:16 +0000 Subject: [PATCH 05/20] Reverted rose-app.conf and upgrade macros for non lfric-adjoint. Updated lfric-adjoint macro to add namelist and value to rose-apps conditionally. --- .../rose-meta/lfric-adjoint_tests/versions.py | 15 -------- .../rose-meta/jedi_common/versions.py | 16 -------- .../rose-meta/jedi_forecast/versions.py | 16 -------- .../jedi_forecast_pseudo/versions.py | 16 -------- .../rose-meta/jedi_id_tlm_tests/versions.py | 16 -------- .../rose-meta/jedi_lfric_tests/versions.py | 16 -------- .../jedi_tlm_forecast_tl/versions.py | 16 -------- .../rose-meta/jedi_tlm_tests/versions.py | 16 -------- .../jedi_lfric_interface/versions.py | 15 -------- rose-stem/app/adjoint_tests/rose-app.conf | 6 +-- rose-stem/app/jedi_forecast/rose-app.conf | 4 -- .../app/jedi_forecast_pseudo/rose-app.conf | 4 -- rose-stem/app/jedi_id_tlm_tests/rose-app.conf | 4 -- rose-stem/app/jedi_lfric_tests/rose-app.conf | 4 -- .../app/jedi_tlm_forecast_tl/rose-app.conf | 4 -- rose-stem/app/jedi_tlm_tests/rose-app.conf | 4 -- .../rose-meta/lfric-adjoint/versions.py | 37 +++++++++++++++++-- 17 files changed, 35 insertions(+), 174 deletions(-) diff --git a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py index 41443fb20..01798ad2b 100644 --- a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py +++ b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py @@ -31,18 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Set computation of annexed dofs to false for adjoint_tests - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py index 62d7e48de..01798ad2b 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py @@ -31,19 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Commands From: rose-meta/lfric-adjoint - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py index cc76f1a2c..01798ad2b 100644 --- a/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py +++ b/interfaces/jedi_lfric_interface/rose-meta/jedi_lfric_interface/versions.py @@ -31,18 +31,3 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ - - -class vn31_t322(MacroUpgrade): - """Upgrade macro for ticket #322 by Terence Vockerodt.""" - - BEFORE_TAG = "vn3.1" - AFTER_TAG = "vn3.1_t322" - - def upgrade(self, config, meta_config=None): - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) - - return config, self.reports diff --git a/rose-stem/app/adjoint_tests/rose-app.conf b/rose-stem/app/adjoint_tests/rose-app.conf index 9d6383b90..4dafac183 100644 --- a/rose-stem/app/adjoint_tests/rose-app.conf +++ b/rose-stem/app/adjoint_tests/rose-app.conf @@ -16,8 +16,7 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:adjoint - = (namelist:aerosol) +source=(namelist:aerosol) = namelist:base_mesh = (namelist:blayer) = namelist:boundaries @@ -100,9 +99,6 @@ source=namelist:adjoint = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.false. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_forecast/rose-app.conf b/rose-stem/app/jedi_forecast/rose-app.conf index 3f09443b1..42c17cee6 100644 --- a/rose-stem/app/jedi_forecast/rose-app.conf +++ b/rose-stem/app/jedi_forecast/rose-app.conf @@ -23,7 +23,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings - = namelist:adjoint = namelist:base_mesh = namelist:boundaries = namelist:checks @@ -95,9 +94,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf index 0d3795ac3..5734e167c 100644 --- a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf +++ b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf @@ -21,7 +21,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_pseudo_model - = namelist:adjoint = namelist:base_mesh = namelist:boundaries = namelist:checks @@ -93,9 +92,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf index 7716e7c83..dc2a904a2 100644 --- a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf @@ -23,7 +23,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings - = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -107,9 +106,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_lfric_tests/rose-app.conf b/rose-stem/app/jedi_lfric_tests/rose-app.conf index ce6ebc62f..07157baf5 100644 --- a/rose-stem/app/jedi_lfric_tests/rose-app.conf +++ b/rose-stem/app/jedi_lfric_tests/rose-app.conf @@ -23,7 +23,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings - = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -107,9 +106,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf index 950156da4..b446f4c69 100644 --- a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf +++ b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf @@ -23,7 +23,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings - = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -107,9 +106,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_tests/rose-app.conf b/rose-stem/app/jedi_tlm_tests/rose-app.conf index 56890d29e..6e8c2a776 100644 --- a/rose-stem/app/jedi_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_tlm_tests/rose-app.conf @@ -23,7 +23,6 @@ source=namelist:jedi_lfric_tests = namelist:jedi_linear_model = namelist:jedi_pseudo_model = namelist:jedi_lfric_settings - = namelist:adjoint = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) @@ -107,9 +106,6 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) -[namelist:adjoint] -l_compute_annexed_dofs=.true. - [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index cc76f1a2c..75dc5268c 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -40,9 +40,40 @@ class vn31_t322(MacroUpgrade): AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): - # Set computation of annexed dofs to true for adjoint - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] ) + # Insert adjoint above aerosol except for these exceptions + exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] + exec_name = self.get_setting_value( + config, ["env", "EXEC_NAME"] + ) + if exec_name in exception_exec_names : + source = re.sub( + r"namelist:base_mesh", + r"namelist:adjoint" + "\n" + " namelist:base_mesh", + source, + ) + else: + source = re.sub( + r"(namelist:aerosol)", + r"namelist:adjoint" + "\n" + " (namelist:aerosol)", + source, + ) + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + + # Set computation of annexed dofs to true for adjoint, false for adjoint_tests + if exec_name == "adjoint_tests": + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." + ) + else: + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + return config, self.reports From eb813dd19bca42563019a916a4d8fb4ae5daaf3b Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:46:22 +0000 Subject: [PATCH 06/20] Possible syntax fix --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 75dc5268c..623c03624 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -54,13 +54,13 @@ def upgrade(self, config, meta_config=None): source = re.sub( r"namelist:base_mesh", r"namelist:adjoint" + "\n" + " namelist:base_mesh", - source, + source ) else: source = re.sub( r"(namelist:aerosol)", r"namelist:adjoint" + "\n" + " (namelist:aerosol)", - source, + source ) self.change_setting_value( config, ["file:configuration.nml", "source"], source From 098f848d86e6d72d8faf812824a67b02f9270cca Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:56:05 +0000 Subject: [PATCH 07/20] Did not solve macro problem, reverted to original --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 623c03624..75dc5268c 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -54,13 +54,13 @@ def upgrade(self, config, meta_config=None): source = re.sub( r"namelist:base_mesh", r"namelist:adjoint" + "\n" + " namelist:base_mesh", - source + source, ) else: source = re.sub( r"(namelist:aerosol)", r"namelist:adjoint" + "\n" + " (namelist:aerosol)", - source + source, ) self.change_setting_value( config, ["file:configuration.nml", "source"], source From 3156c17b5aa749991c3a5b8cdb59f0cb6fec9c88 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:00:12 +0000 Subject: [PATCH 08/20] Added missing import --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 75dc5268c..fdb81c81d 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 From 97b6af0ee3285c28f084f9727cba87aad9d10003 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 14:18:34 +0000 Subject: [PATCH 09/20] Amended pattern matching to find the brackets instead of just ignoring them --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index fdb81c81d..b97ca1dec 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -59,7 +59,7 @@ def upgrade(self, config, meta_config=None): ) else: source = re.sub( - r"(namelist:aerosol)", + r".namelist:aerosol.", r"namelist:adjoint" + "\n" + " (namelist:aerosol)", source, ) From 5832908f1f89e983b7eee804ad242951dbaeda42 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Fri, 6 Mar 2026 14:43:59 +0000 Subject: [PATCH 10/20] Aligned source formatting properly in substitution --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index b97ca1dec..abbb46922 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -54,13 +54,13 @@ def upgrade(self, config, meta_config=None): if exec_name in exception_exec_names : source = re.sub( r"namelist:base_mesh", - r"namelist:adjoint" + "\n" + " namelist:base_mesh", + r"namelist:adjoint" + "\n" + " namelist:base_mesh", source, ) else: source = re.sub( r".namelist:aerosol.", - r"namelist:adjoint" + "\n" + " (namelist:aerosol)", + r" namelist:adjoint" + "\n" + " (namelist:aerosol)", source, ) self.change_setting_value( From 6e96a2f3c1c9c066af8ce08c5970bd4bc02d29ac Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 10:59:57 +0000 Subject: [PATCH 11/20] Attempted logic at preventing update to non-base configs --- .../rose-meta/lfric-adjoint/versions.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index abbb46922..35b56f9b5 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -67,14 +67,16 @@ def upgrade(self, config, meta_config=None): config, ["file:configuration.nml", "source"], source ) - # Set computation of annexed dofs to true for adjoint, false for adjoint_tests - if exec_name == "adjoint_tests": - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." - ) - else: - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) + # We don't want to modify optional configs + if exec_name != "${APP_NAME}": + # Set computation of annexed dofs to true for adjoint, false for adjoint_tests + if exec_name == "adjoint_tests": + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." + ) + else: + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) return config, self.reports From da5a34e7e00846534972764e286d27bd61dec080 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:07:50 +0000 Subject: [PATCH 12/20] Clarified comment --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 35b56f9b5..5d60b516a 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -67,7 +67,7 @@ def upgrade(self, config, meta_config=None): config, ["file:configuration.nml", "source"], source ) - # We don't want to modify optional configs + # We don't want to directly modify optional configs if exec_name != "${APP_NAME}": # Set computation of annexed dofs to true for adjoint, false for adjoint_tests if exec_name == "adjoint_tests": From 027dd1f5e96bf3d2669dfdbb180a2f1c1400bfaf Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:31:48 +0000 Subject: [PATCH 13/20] Fixed faulty macro by manually upgrading adjoint_tests config --- rose-stem/app/adjoint_tests/rose-app.conf | 6 ++- .../rose-meta/lfric-adjoint/versions.py | 41 ++++++++----------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/rose-stem/app/adjoint_tests/rose-app.conf b/rose-stem/app/adjoint_tests/rose-app.conf index 915553a27..19a68630e 100644 --- a/rose-stem/app/adjoint_tests/rose-app.conf +++ b/rose-stem/app/adjoint_tests/rose-app.conf @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=(namelist:aerosol) +source=namelist:adjoint + = (namelist:aerosol) = namelist:base_mesh = (namelist:blayer) = namelist:boundaries @@ -99,6 +100,9 @@ source=(namelist:aerosol) = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.false. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 5d60b516a..1b9e24ffb 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -51,32 +51,27 @@ def upgrade(self, config, meta_config=None): exec_name = self.get_setting_value( config, ["env", "EXEC_NAME"] ) - if exec_name in exception_exec_names : - source = re.sub( - r"namelist:base_mesh", - r"namelist:adjoint" + "\n" + " namelist:base_mesh", - source, - ) - else: - source = re.sub( - r".namelist:aerosol.", - r" namelist:adjoint" + "\n" + " (namelist:aerosol)", - source, - ) + # To prevent macro upgrade errors, we edit the adjoint_tests config manually + if exec_name != "adjoint_tests": + if exec_name in exception_exec_names : + source = re.sub( + r"namelist:base_mesh", + r"namelist:adjoint" + "\n" + " namelist:base_mesh", + source, + ) + else: + source = re.sub( + r".namelist:aerosol.", + r" namelist:adjoint" + "\n" + " (namelist:aerosol)", + source, + ) self.change_setting_value( config, ["file:configuration.nml", "source"], source ) - # We don't want to directly modify optional configs - if exec_name != "${APP_NAME}": - # Set computation of annexed dofs to true for adjoint, false for adjoint_tests - if exec_name == "adjoint_tests": - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".false." - ) - else: - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) return config, self.reports From b95331799087482718938a1b560090ae057da526 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:45:31 +0000 Subject: [PATCH 14/20] Further attempt at a fix... --- .../rose-meta/lfric-adjoint/versions.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 1b9e24ffb..242ffb135 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -41,18 +41,18 @@ class vn31_t322(MacroUpgrade): AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): - # Adds new namelist entry alphabetically - source = self.get_setting_value( - config, ["file:configuration.nml", "source"] - ) - - # Insert adjoint above aerosol except for these exceptions - exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] exec_name = self.get_setting_value( config, ["env", "EXEC_NAME"] ) # To prevent macro upgrade errors, we edit the adjoint_tests config manually - if exec_name != "adjoint_tests": + do_not_upgrade = ["adjoint_tests"] + if exec_name not in do_not_upgrade: + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + # Insert adjoint above aerosol except for these exceptions + exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] if exec_name in exception_exec_names : source = re.sub( r"namelist:base_mesh", @@ -65,13 +65,13 @@ def upgrade(self, config, meta_config=None): r" namelist:adjoint" + "\n" + " (namelist:aerosol)", source, ) - self.change_setting_value( - config, ["file:configuration.nml", "source"], source - ) - - # Default value - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) return config, self.reports From 0c41a0de9b8f2990db2c410d0643bfb28ca01ba6 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:48:21 +0000 Subject: [PATCH 15/20] ...and again... --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 242ffb135..822026929 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -45,7 +45,7 @@ def upgrade(self, config, meta_config=None): config, ["env", "EXEC_NAME"] ) # To prevent macro upgrade errors, we edit the adjoint_tests config manually - do_not_upgrade = ["adjoint_tests"] + do_not_upgrade = ["adjoint_tests", "${APP_NAME}"] if exec_name not in do_not_upgrade: # Adds new namelist entry alphabetically source = self.get_setting_value( From b3782bfefd8c291e9d30b0128d93fc8aa3516539 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:53:07 +0000 Subject: [PATCH 16/20] Another attempt, this time using different logic --- .../adjoint/rose-meta/lfric-adjoint/versions.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 822026929..2d762e054 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -41,18 +41,16 @@ class vn31_t322(MacroUpgrade): AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): - exec_name = self.get_setting_value( - config, ["env", "EXEC_NAME"] + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] ) - # To prevent macro upgrade errors, we edit the adjoint_tests config manually - do_not_upgrade = ["adjoint_tests", "${APP_NAME}"] - if exec_name not in do_not_upgrade: - # Adds new namelist entry alphabetically - source = self.get_setting_value( - config, ["file:configuration.nml", "source"] - ) + if ("namelist:adjoint" not in source) and (source != ""): # Insert adjoint above aerosol except for these exceptions exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] + exec_name = self.get_setting_value( + config, ["env", "EXEC_NAME"] + ) if exec_name in exception_exec_names : source = re.sub( r"namelist:base_mesh", From 906ebc0cd2c0dec26171fb4bc52fb3901fc09230 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:59:12 +0000 Subject: [PATCH 17/20] Temporary logging for debugging --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 2d762e054..042ed4af5 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -51,6 +51,7 @@ def upgrade(self, config, meta_config=None): exec_name = self.get_setting_value( config, ["env", "EXEC_NAME"] ) + print(f"exec_name = {exec_name}, source = {source}") if exec_name in exception_exec_names : source = re.sub( r"namelist:base_mesh", From 1a3bf65205819bc866eae9280277a35309c3e149 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:04:36 +0000 Subject: [PATCH 18/20] Further testing --- science/adjoint/rose-meta/lfric-adjoint/versions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 042ed4af5..2cb702983 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -45,12 +45,13 @@ def upgrade(self, config, meta_config=None): source = self.get_setting_value( config, ["file:configuration.nml", "source"] ) - if ("namelist:adjoint" not in source) and (source != ""): + exec_name = self.get_setting_value( + config, ["env", "EXEC_NAME"] + ) + if ("namelist:adjoint" not in source) or (exec_name != "${APP_NAME}"): # Insert adjoint above aerosol except for these exceptions exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] - exec_name = self.get_setting_value( - config, ["env", "EXEC_NAME"] - ) + print(f"exec_name = {exec_name}, source = {source}") if exec_name in exception_exec_names : source = re.sub( From db00ef92bb078f51555b6c317cef53c99850d988 Mon Sep 17 00:00:00 2001 From: DrTVockerodtMO <114994380+DrTVockerodtMO@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:03:24 +0000 Subject: [PATCH 19/20] Fixed the macro --- .../rose-meta/lfric-adjoint/versions.py | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index 2cb702983..d5d0f5f62 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -45,33 +45,24 @@ def upgrade(self, config, meta_config=None): source = self.get_setting_value( config, ["file:configuration.nml", "source"] ) - exec_name = self.get_setting_value( - config, ["env", "EXEC_NAME"] - ) - if ("namelist:adjoint" not in source) or (exec_name != "${APP_NAME}"): - # Insert adjoint above aerosol except for these exceptions - exception_exec_names = ["jedi_forecast", "jedi_forecast_pseudo"] - - print(f"exec_name = {exec_name}, source = {source}") - if exec_name in exception_exec_names : - source = re.sub( - r"namelist:base_mesh", - r"namelist:adjoint" + "\n" + " namelist:base_mesh", - source, - ) - else: - source = re.sub( - r".namelist:aerosol.", - r" namelist:adjoint" + "\n" + " (namelist:aerosol)", - source, + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source ) - self.change_setting_value( - config, ["file:configuration.nml", "source"], source - ) - - # Default value - self.add_setting( - config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." - ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) return config, self.reports From dbfa35c473fa9b6af6eb61c3c9cb5ab91a2aebe1 Mon Sep 17 00:00:00 2001 From: stevemullerworth <26165365+stevemullerworth@users.noreply.github.com> Date: Thu, 19 Mar 2026 17:00:15 +0000 Subject: [PATCH 20/20] Upgrade macro application --- .../rose-meta/lfric-adjoint_tests/versions.py | 36 +++++++++++++++++++ .../rose-meta/jedi_common/versions.py | 36 +++++++++++++++++++ .../rose-meta/jedi_forecast/versions.py | 36 +++++++++++++++++++ .../jedi_forecast_pseudo/versions.py | 36 +++++++++++++++++++ .../rose-meta/jedi_id_tlm_tests/versions.py | 36 +++++++++++++++++++ .../rose-meta/jedi_lfric_tests/versions.py | 36 +++++++++++++++++++ .../jedi_tlm_forecast_tl/versions.py | 36 +++++++++++++++++++ .../rose-meta/jedi_tlm_tests/versions.py | 36 +++++++++++++++++++ rose-stem/app/adjoint_tests/rose-app.conf | 2 +- rose-stem/app/jedi_forecast/rose-app.conf | 8 +++-- .../app/jedi_forecast_pseudo/rose-app.conf | 8 +++-- rose-stem/app/jedi_id_tlm_tests/rose-app.conf | 8 +++-- rose-stem/app/jedi_lfric_tests/rose-app.conf | 8 +++-- .../app/jedi_tlm_forecast_tl/rose-app.conf | 8 +++-- rose-stem/app/jedi_tlm_tests/rose-app.conf | 8 +++-- .../rose-meta/lfric-adjoint/versions.py | 16 +-------- 16 files changed, 326 insertions(+), 28 deletions(-) diff --git a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py +++ b/applications/adjoint_tests/rose-meta/lfric-adjoint_tests/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_common/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_forecast_pseudo/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_id_tlm_tests/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_lfric_tests/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_forecast_tl/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py index 01798ad2b..0609604ba 100644 --- a/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py +++ b/applications/jedi_lfric_tests/rose-meta/jedi_tlm_tests/versions.py @@ -1,3 +1,4 @@ +import re import sys from metomi.rose.upgrade import MacroUpgrade # noqa: F401 @@ -31,3 +32,38 @@ def upgrade(self, config, meta_config=None): # Add settings return config, self.reports """ + + +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" + + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" + + def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint + # Adds new namelist entry alphabetically + source = self.get_setting_value( + config, ["file:configuration.nml", "source"] + ) + if "namelist:adjoint" not in source: + # Insert adjoint to configuration + for line in source.split("\n"): + namelist = line.strip("()") + namelist = namelist.strip() + if "namelist:adjoint" < namelist: + source = re.sub( + line, + rf" namelist:adjoint\n{line}", + source, + ) + break + self.change_setting_value( + config, ["file:configuration.nml", "source"], source + ) + # Default value + self.add_setting( + config, ["namelist:adjoint", "l_compute_annexed_dofs"], ".true." + ) + + return config, self.reports diff --git a/rose-stem/app/adjoint_tests/rose-app.conf b/rose-stem/app/adjoint_tests/rose-app.conf index 19a68630e..4c6172ee1 100644 --- a/rose-stem/app/adjoint_tests/rose-app.conf +++ b/rose-stem/app/adjoint_tests/rose-app.conf @@ -1,4 +1,4 @@ -meta=lfric-adjoint_tests/vn3.1 +meta=lfric-adjoint_tests/vn3.1_t322 [command] default=rose env-cat iodef_temp.xml -o iodef.xml; $LAUNCH_SCRIPT/launch-exe diff --git a/rose-stem/app/jedi_forecast/rose-app.conf b/rose-stem/app/jedi_forecast/rose-app.conf index 064ee951b..cd8f5a119 100644 --- a/rose-stem/app/jedi_forecast/rose-app.conf +++ b/rose-stem/app/jedi_forecast/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_forecast/vn3.1 +meta=jedi_forecast/vn3.1_t322 [command] default=$CORE_ROOT_DIR/bin/tweak_iodef ; \ @@ -17,7 +17,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_model @@ -94,6 +95,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf index 78cef3e9c..dd3e98922 100644 --- a/rose-stem/app/jedi_forecast_pseudo/rose-app.conf +++ b/rose-stem/app/jedi_forecast_pseudo/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_forecast_pseudo/vn3.1 +meta=jedi_forecast_pseudo/vn3.1_t322 [command] default=$LAUNCH_SCRIPT/launch-exe @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_lfric_settings = namelist:jedi_geometry = namelist:jedi_state @@ -92,6 +93,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf index 42cc71336..b0f2f668b 100644 --- a/rose-stem/app/jedi_id_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_id_tlm_tests/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_id_tlm_tests/vn3.1 +meta=jedi_id_tlm_tests/vn3.1_t322 [command] default=$LAUNCH_SCRIPT/launch-exe @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_increment @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_lfric_tests/rose-app.conf b/rose-stem/app/jedi_lfric_tests/rose-app.conf index a1f6d636e..d280582d0 100644 --- a/rose-stem/app/jedi_lfric_tests/rose-app.conf +++ b/rose-stem/app/jedi_lfric_tests/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_lfric_tests/vn3.1 +meta=jedi_lfric_tests/vn3.1_t322 [command] default=rose env-cat iodef_temp.xml -o iodef.xml; $LAUNCH_SCRIPT/launch-exe @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_increment @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf index af46e888f..e378f3847 100644 --- a/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf +++ b/rose-stem/app/jedi_tlm_forecast_tl/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_tlm_forecast_tl/vn3.1 +meta=jedi_tlm_forecast_tl/vn3.1_t322 [command] default=$LAUNCH_SCRIPT/launch-exe @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_increment @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/rose-stem/app/jedi_tlm_tests/rose-app.conf b/rose-stem/app/jedi_tlm_tests/rose-app.conf index c3a7be783..b374ccf02 100644 --- a/rose-stem/app/jedi_tlm_tests/rose-app.conf +++ b/rose-stem/app/jedi_tlm_tests/rose-app.conf @@ -1,4 +1,4 @@ -meta=jedi_tlm_tests/vn3.1 +meta=jedi_tlm_tests/vn3.1_t322 [command] default=$LAUNCH_SCRIPT/launch-exe @@ -16,7 +16,8 @@ mode=mkdir [file:configuration.nml] mode=auto -source=namelist:jedi_lfric_tests +source=namelist:adjoint + =namelist:jedi_lfric_tests = namelist:jedi_geometry = namelist:jedi_state = namelist:jedi_increment @@ -106,6 +107,9 @@ source=namelist:jedi_lfric_tests = (namelist:vertadvect) = (namelist:wind_forcing) +[namelist:adjoint] +l_compute_annexed_dofs=.true. + [!!namelist:aerosol] !!aclw_file='' !!acsw_file='' diff --git a/science/adjoint/rose-meta/lfric-adjoint/versions.py b/science/adjoint/rose-meta/lfric-adjoint/versions.py index d5d0f5f62..8c420c8f7 100644 --- a/science/adjoint/rose-meta/lfric-adjoint/versions.py +++ b/science/adjoint/rose-meta/lfric-adjoint/versions.py @@ -19,21 +19,6 @@ def __repr__(self): __str__ = __repr__ -""" -Copy this template and complete to add your macro - -class vnXX_txxx(MacroUpgrade): - # Upgrade macro for by - - BEFORE_TAG = "vnX.X" - AFTER_TAG = "vnX.X_txxx" - - def upgrade(self, config, meta_config=None): - # Add settings - return config, self.reports -""" - - class vn31_t322(MacroUpgrade): """Upgrade macro for ticket #322 by Terence Vockerodt.""" @@ -41,6 +26,7 @@ class vn31_t322(MacroUpgrade): AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): + # Commands From: rose-meta/lfric-adjoint # Adds new namelist entry alphabetically source = self.get_setting_value( config, ["file:configuration.nml", "source"]