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..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/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..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 915553a27..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 @@ -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 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/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..8c420c8f7 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 @@ -18,16 +19,36 @@ def __repr__(self): __str__ = __repr__ -""" -Copy this template and complete to add your macro +class vn31_t322(MacroUpgrade): + """Upgrade macro for ticket #322 by Terence Vockerodt.""" -class vnXX_txxx(MacroUpgrade): - # Upgrade macro for by - - BEFORE_TAG = "vnX.X" - AFTER_TAG = "vnX.X_txxx" + BEFORE_TAG = "vn3.1" + AFTER_TAG = "vn3.1_t322" def upgrade(self, config, meta_config=None): - # Add settings + # 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/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..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 @@ -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,20 @@ 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() + ! 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 + 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 +140,20 @@ 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() + ! 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 + 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 +214,20 @@ 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() + ! 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 + 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