Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
122b823
Created adjoint namelist proxy variable, equivalent to COMPUTE_ANNEXE…
DrTVockerodtMO Mar 5, 2026
3d80d17
Fixed upgrade macros
DrTVockerodtMO Mar 5, 2026
c976b7e
Added PSyclone issue to where namelist variable is used
DrTVockerodtMO Mar 5, 2026
7366921
Further fixes to upgrade macros
DrTVockerodtMO Mar 5, 2026
0f8f6de
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 6, 2026
b06a9eb
Reverted rose-app.conf and upgrade macros for non lfric-adjoint. Upda…
DrTVockerodtMO Mar 6, 2026
eb813dd
Possible syntax fix
DrTVockerodtMO Mar 6, 2026
098f848
Did not solve macro problem, reverted to original
DrTVockerodtMO Mar 6, 2026
3156c17
Added missing import
DrTVockerodtMO Mar 6, 2026
97b6af0
Amended pattern matching to find the brackets instead of just ignorin…
DrTVockerodtMO Mar 6, 2026
5832908
Aligned source formatting properly in substitution
DrTVockerodtMO Mar 6, 2026
e1d81e7
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 6, 2026
0b392d8
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 9, 2026
6e96a2f
Attempted logic at preventing update to non-base configs
DrTVockerodtMO Mar 9, 2026
da5a34e
Clarified comment
DrTVockerodtMO Mar 9, 2026
027dd1f
Fixed faulty macro by manually upgrading adjoint_tests config
DrTVockerodtMO Mar 9, 2026
b953317
Further attempt at a fix...
DrTVockerodtMO Mar 9, 2026
0c41a0d
...and again...
DrTVockerodtMO Mar 9, 2026
b3782bf
Another attempt, this time using different logic
DrTVockerodtMO Mar 9, 2026
906ebc0
Temporary logging for debugging
DrTVockerodtMO Mar 9, 2026
1a3bf65
Further testing
DrTVockerodtMO Mar 9, 2026
db00ef9
Fixed the macro
DrTVockerodtMO Mar 9, 2026
4894236
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 10, 2026
8fcdd7d
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 11, 2026
44a7e0e
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 13, 2026
e8e363d
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 17, 2026
c794fd6
Merge branch 'main' into psykal_lite_adjoint_fix
DrTVockerodtMO Mar 18, 2026
b985019
Merge remote-tracking branch 'upstream/main' into psykal_lite_adjoint…
stevemullerworth Mar 19, 2026
65b3223
Further merge of main to pick up last minute fix on main
stevemullerworth Mar 19, 2026
dbfa35c
Upgrade macro application
stevemullerworth Mar 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions applications/adjoint_tests/example/configuration.nml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
&adjoint
l_compute_annexed_dofs=.false.,
/

&base_mesh
file_prefix='mesh_C12_MG',
geometry='spherical',
Expand Down
3 changes: 3 additions & 0 deletions applications/jedi_lfric_tests/example/configuration.nml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
&adjoint
l_compute_annexed_dofs=.true.,
/
&base_mesh
file_prefix='mesh_C12_MG',
geometry='spherical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ forecast_length='P0DT6H0M0S',

#### Configure LFRic

&adjoint
l_compute_annexed_dofs=.true.,
/
&base_mesh
file_prefix='mesh_C12',
geometry='spherical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ time_step='P0DT1H0M0S',

#### Configure LFRic

&adjoint
l_compute_annexed_dofs=.true.,
/
&base_mesh
file_prefix='mesh_C12',
geometry='spherical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ time_step='P0DT1H0M0S',

#### Configure LFRic

&adjoint
l_compute_annexed_dofs=.true.,
/
&base_mesh
file_prefix='mesh_C12',
geometry='spherical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ forecast_length='P0DT6H0M0S',

#### Configure LFRic

&adjoint
l_compute_annexed_dofs=.true.,
/
&base_mesh
file_prefix='mesh_C12',
geometry='spherical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion rose-stem/app/adjoint_tests/rose-app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=''
Expand Down
16 changes: 16 additions & 0 deletions science/adjoint/rose-meta/lfric-adjoint/HEAD/rose-meta.conf
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions science/adjoint/rose-meta/lfric-adjoint/versions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys

from metomi.rose.upgrade import MacroUpgrade # noqa: F401
Expand Down Expand Up @@ -31,3 +32,37 @@ 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):
# 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
55 changes: 40 additions & 15 deletions science/adjoint/source/psy/adj_sci_psykal_builtin_light_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading