Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
2d404b5
All changes except updating canned test namelist
tom-j-h Jan 7, 2026
8494703
Duplicate of testing from #71
tom-j-h Jan 7, 2026
addf153
Update canned namelist
tom-j-h Jan 7, 2026
7f80c68
Signed CLA
tom-j-h Jan 14, 2026
423b9b0
Merge branch 'main' into align_adjoint_tests_to_linear_model
tom-j-h Jan 14, 2026
e3d05de
Added canned mesh namelist and file
tom-j-h Jan 14, 2026
9ab0595
Merge branch 'align_adjoint_tests_to_linear_model' of github.com:tom-…
tom-j-h Jan 14, 2026
e349cb5
Added namelist variable for adjoint test tolerance to jedi_tlm_tests
tom-j-h Jan 14, 2026
4a25162
Moved variable definition so it's not needed where it's irrelevant
tom-j-h Jan 14, 2026
47a08a5
rose config-dump
tom-j-h Jan 14, 2026
fb3fd3a
Moved back to jedi_common and made non-compulsory
tom-j-h Jan 14, 2026
b5f9e37
Merge branch 'main' into align_adjoint_tests_to_linear_model
tom-j-h Jan 15, 2026
0679604
Fix merge error
tom-j-h Jan 15, 2026
5b05c03
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 15, 2026
bc02651
Should be all changes for jedi_tlm_tests and jedi_id_tlm_tests. Untes…
tom-j-h Jan 15, 2026
9aae208
SR response
tom-j-h Jan 16, 2026
b803e14
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 16, 2026
5415cc0
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 16, 2026
cae8bb1
Merge branch 'main' into align_adjoint_tests_to_linear_model
tom-j-h Jan 16, 2026
fab2cd8
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 16, 2026
79b2134
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 16, 2026
78a319f
rose config fix
tom-j-h Jan 16, 2026
ae855bb
Adjust test tolerances
tom-j-h Jan 19, 2026
4a5487c
Canned tests
tom-j-h Jan 19, 2026
3979361
Added real increment test
tom-j-h Jan 20, 2026
6c3059d
Tolerance was a bit tight before
tom-j-h Jan 20, 2026
41e2de7
Empty commit to test signing
tom-j-h Jan 20, 2026
ae5415e
Majority of changes
tom-j-h Jan 20, 2026
054f999
Removing change that's meant for a later PR
tom-j-h Jan 20, 2026
e2aeff6
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 20, 2026
8a10b7d
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 20, 2026
02438dd
Link to new files
tom-j-h Jan 20, 2026
5c36313
opt conf corrections
tom-j-h Jan 20, 2026
33b96bc
Turn off XIOS server mode
tom-j-h Jan 22, 2026
b1d0eb7
Initial commit - transfer of changes from Tim's branch
tom-j-h Jan 22, 2026
d5248c2
config_dump_checker and style_checker
tom-j-h Jan 22, 2026
0cd0a26
jedi_lfric build errors
tom-j-h Jan 22, 2026
a434536
Other minor fixes
tom-j-h Jan 22, 2026
2fea9a9
rose config-dump
tom-j-h Jan 22, 2026
6b108db
minor fixes
tom-j-h Jan 22, 2026
c57429a
Minor fixes
tom-j-h Jan 22, 2026
8e97dc3
iodef updates
tom-j-h Jan 22, 2026
5ff06b4
Test config fixes
tom-j-h Jan 23, 2026
a9672df
Config updates
tom-j-h Jan 23, 2026
404e36b
bugfix
tom-j-h Jan 23, 2026
90f2249
Bugfix
tom-j-h Jan 23, 2026
df880a6
Debugging code
tom-j-h Jan 23, 2026
945525d
Alternate name for land fraction
tom-j-h Jan 23, 2026
73651cb
Fixed dimension assignment
tom-j-h Jan 26, 2026
1c03fac
Fix variables in rose-stem configs
tom-j-h Jan 26, 2026
9d18e24
rose config-dump, removing unnecessary changes
tom-j-h Jan 26, 2026
4b8b73d
Deleted duplicate file
tom-j-h Jan 26, 2026
ba7904a
Accidentally put land_fraction in increment rather than state variables
tom-j-h Jan 26, 2026
0539f5b
rose config-dump
tom-j-h Jan 26, 2026
beeb3d5
upgrade macro
tom-j-h Jan 26, 2026
905c760
upgrade macro
tom-j-h Jan 26, 2026
a1dfa7e
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 26, 2026
2ee7264
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 26, 2026
59f6035
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 26, 2026
605147e
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 26, 2026
1000322
Reverted erroneous change
tom-j-h Jan 27, 2026
f521d7e
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 27, 2026
c81b05d
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 27, 2026
5cbc9da
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 27, 2026
3ad6836
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 27, 2026
9206c07
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 27, 2026
c01e185
Responding to CR
tom-j-h Jan 27, 2026
2022bd1
Merge branch 'main' into align_adjoint_tests_to_linear_model
tom-j-h Jan 27, 2026
551fc98
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 27, 2026
f1d25ca
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 27, 2026
665c91d
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 27, 2026
36b8741
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 27, 2026
0b30374
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 27, 2026
258c386
Responding to SR
tom-j-h Jan 27, 2026
a269be6
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 27, 2026
f2068bf
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 27, 2026
30497cc
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 27, 2026
f99c585
Corrected merge
tom-j-h Jan 27, 2026
9223d31
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 27, 2026
25e36f2
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 27, 2026
4b0c0c9
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 27, 2026
e438b01
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 27, 2026
eeec47c
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 27, 2026
d01551c
Responding to SR
tom-j-h Jan 28, 2026
d67c2b9
Responding to SR
tom-j-h Jan 28, 2026
6360fc2
Fixings versions.py
tom-j-h Jan 28, 2026
1c993b7
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 28, 2026
f69bc9a
Updating canned configs
tom-j-h Jan 28, 2026
9d97da9
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 28, 2026
03bb23b
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 28, 2026
5dcf6ba
Merge upstream
tom-j-h Jan 28, 2026
71ce052
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 28, 2026
e6a5e46
Fixing versions.py
tom-j-h Jan 28, 2026
55e7a2e
Remove erroneous file
tom-j-h Jan 28, 2026
5509e9c
Responding to SR (not done)
tom-j-h Jan 28, 2026
4b9814f
Refactor tl_compute_qe_kernel_mod
tom-j-h Jan 28, 2026
43529b0
Responding to SR
tom-j-h Jan 29, 2026
0dae5e5
Merge branch 'main' into align_adjoint_tests_to_linear_model
TeranIvy Jan 29, 2026
e0c2518
Factor out TL/AD physics and new NML variable help/description sections
tom-j-h Jan 29, 2026
b766bea
Linear physics namelist variables in their own section
tom-j-h Jan 29, 2026
f4eb769
No boundary layer scheme for semi-implicit and dcmip tests
tom-j-h Jan 29, 2026
b2b3085
Trigger for TLM BL options
tom-j-h Jan 29, 2026
8ad1482
Merge remote-tracking branch 'upstream/main' into align_adjoint_tests…
tom-j-h Jan 29, 2026
f15d817
Merge branch 'align_adjoint_tests_to_linear_model' into jelf_adjoint_…
tom-j-h Jan 29, 2026
9b5c7de
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Jan 29, 2026
85d0520
More SR changes
tom-j-h Jan 29, 2026
2c887a8
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Jan 29, 2026
775951b
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Jan 29, 2026
a327fe2
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Jan 29, 2026
978324f
jelf canned nmls
tom-j-h Jan 29, 2026
5898833
Refactor how 2D LS are handled in jedi_lfric
tom-j-h Jan 29, 2026
b70722d
SR 3
tom-j-h Jan 30, 2026
6aad6a4
Revert unnecessary change
tom-j-h Jan 30, 2026
211572f
Merge branch 'main' into jelf_adjoint_test_tolerance_nml
tom-j-h Feb 2, 2026
24b02e7
Merge branch 'jelf_adjoint_test_tolerance_nml' into align_jedi_lfric_…
tom-j-h Feb 2, 2026
4b4d3b2
Merge branch 'align_jedi_lfric_tests_to_linear_model' into jelf_real_…
tom-j-h Feb 2, 2026
cbc7253
Merge branch 'jelf_real_increment_adjoint_test' into jelf_C224_adjoin…
tom-j-h Feb 2, 2026
29b61ee
Merge branch 'jelf_C224_adjoint_tests' into tlad_boundary_layer
tom-j-h Feb 2, 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
17 changes: 14 additions & 3 deletions applications/adjoint_tests/example/configuration.nml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ stretching_method='smooth',
ancil_directory='/data/users/lfricadmin/data/ancils/basic-gal/yak/C12',
checkpoint_stem_name='',
diag_stem_name='diagGungho',
ls_directory='/data/users/lfricadmin/data/tangent-linear/Ticket354',
ls_filename='final_ls',
ls_directory='/data/users/tim.payne/lfric_apps/files',
ls_filename='final_ls_with_land',
orography_mean_ancil_path='orography/gmted_ramp2/qrparm.orog',
start_dump_directory='/data/users/lfricadmin/data/tangent-linear/Ticket354',
start_dump_filename='final_pert',
Expand Down Expand Up @@ -221,12 +221,23 @@ write_minmax_tseries=.false.,
/
&linear
fixed_ls=.true.,
l_stabilise_bl=.true.,
l_stabilise_bl=.false.,
ls_read_w2h=.false.,
max_bl_stabilisation=0.75,
n_bl_levels_to_stabilise=15,
pert_option='file',
/
&linear_physics
blevs_m=15,
e_folding_levs_m=10,
l_0_m=80.0,
l_boundary_layer=.true.,
log_layer=2,
u_land_m=0.4,
u_sea_m=0.4,
z_land_m=0.05,
z_sea_m=0.0005,
/
&logging
log_to_rank_zero_only=.false.,
run_log_level='debug',
Expand Down
6 changes: 6 additions & 0 deletions applications/adjoint_tests/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<axis axis_ref="vert_axis_half_levels"/>
<axis axis_ref="ls_axis"/>
</grid>
<grid id="one_level_face_time_grid">
<domain domain_ref="face"/>
<axis axis_ref="1"/>
<axis axis_ref="ls_axis"/>
</grid>
</grid_definition>

<field_definition prec="8" >
Expand Down Expand Up @@ -318,6 +323,7 @@
<field id="ls_u_in_w3_data" name="u_in_w3" long_name="NS wind" unit="m s-1" grid_ref="half_level_face_time_grid" operation="once"/>
<field id="ls_v_in_w3_data" name="v_in_w3" long_name="EW wind" unit="m s-1" grid_ref="half_level_face_time_grid" operation="once"/>
<field id="ls_w_in_wth_data" name="w_in_wth" long_name="Upward wind" unit="m s-1" grid_ref="full_level_face_time_grid" operation="once"/>
<field id="ls_land_fraction_data" name="land_area_fraction" long_name="land_area_fraction" unit="1" grid_ref="one_level_face_time_grid" operation="once" />
</file>

</file_definition>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
!-----------------------------------------------------------------------------
! (c) Crown copyright 2026 Met Office. All rights reserved.
! The file LICENCE, distributed with this code, contains details of the terms
! under which the code may be brief.
!-----------------------------------------------------------------------------
!> @brief Module containing adjoint test for atl_bdy_lyr_alg
module atlt_bdy_lyr_alg_mod

use sci_assign_field_random_range_alg_mod, &
only : assign_field_random_range
use field_mod, only : field_type
use function_space_mod, only : function_space_type
use constants_mod, only : r_def, i_def, l_def
use field_indices_mod, only : igh_u, igh_t, &
igh_d, igh_p
use log_mod, only : log_event, &
log_scratch_space, &
LOG_LEVEL_INFO, &
LOG_LEVEL_DEBUG, &
LOG_LEVEL_ERROR
use mesh_mod, only : mesh_type
use derived_config_mod, only : bundle_size
use driver_modeldb_mod, only : modeldb_type
use finite_element_config_mod, only : element_order_h, element_order_v
use fs_continuity_mod, only : W2, W3, Wtheta
use function_space_collection_mod, only : function_space_collection
use adjoint_test_parameters_mod, only : ls_u_range, ls_theta_range, &
ls_rho_range, ls_exner_range
use timing_mod, only : start_timing, stop_timing, tik, LPROF

implicit none

public

contains

!=============================================================================
!> @brief Adjoint test for atl_bdy_lyr_alg.
!> @details Passes if adjoint is transpose of tangent linear.
!> Determined by testing the equality of inner products <Mx, Mx> and <AMx, x>,
!> where M is the tangent linear and A is the adjoint.
!> @param[in,out] modeldb Structure containing the model state
!> @param[in] mesh The model mesh
subroutine atlt_bdy_lyr_alg( modeldb, mesh )

use tl_bdy_lyr_alg_mod, only : tl_bdy_lyr_alg
use atl_bdy_lyr_alg_mod, only : atl_bdy_lyr_alg

implicit none

! Arguments
type(modeldb_type), target, intent(inout) :: modeldb
type(mesh_type), pointer, intent(in) :: mesh

! Arguments for tl and atl calls
! Form of state is [u,theta,rho,exner]
type(field_type) :: state(bundle_size)
type(field_type) :: u_bl_inc
type(field_type) :: ls_state(bundle_size)

! Copies of input fields used in inner products
type(field_type) :: state_input(bundle_size)
type(field_type) :: u_bl_inc_input

! Pointers for initialising fields
type(function_space_type), pointer :: vector_space_wtheta_ptr
type(function_space_type), pointer :: vector_space_w2_ptr
type(function_space_type), pointer :: vector_space_w3_ptr

! Inner products
real(kind=r_def) :: inner1
real(kind=r_def) :: inner2
real(kind=r_def) :: ip1(2),ip2(2)
real(kind=r_def) :: sf(2)

! Test parameters and variables
real(kind=r_def), parameter :: overall_tolerance = 1500.0_r_def
real(kind=r_def) :: machine_tol
real(kind=r_def) :: relative_diff
real(kind=r_def), parameter :: eps = 1e-30_r_def

! Misc
real(kind=r_def) :: dt

integer(kind=tik) :: id

if ( LPROF ) call start_timing( id, 'atlt_bdy_lyr_alg' )

! Determining time constants
dt = real(modeldb%clock%get_seconds_per_step(), r_def)
if ( dt <= 0.0_r_def ) then
write( log_scratch_space, * ) "dt cannot be leq 0, found dt = ", dt
call log_event( log_scratch_space, log_level_error )
end if

! Initialising fields
vector_space_wtheta_ptr => function_space_collection % get_fs( mesh, element_order_h, element_order_v, Wtheta )
vector_space_w2_ptr => function_space_collection % get_fs( mesh, element_order_h, element_order_v, W2 )
vector_space_w3_ptr => function_space_collection % get_fs( mesh, element_order_h, element_order_v, W3 )

call state(igh_u) % initialise( vector_space = vector_space_w2_ptr )
call state(igh_t) % initialise( vector_space = vector_space_wtheta_ptr )
call state(igh_d) % initialise( vector_space = vector_space_w3_ptr )
call state(igh_p) % initialise( vector_space = vector_space_w3_ptr )
call u_bl_inc % initialise( vector_space = vector_space_w2_ptr )

call state(igh_u) % copy_field_properties( state_input(igh_u) )
call state(igh_t) % copy_field_properties( state_input(igh_t) )
call state(igh_d) % copy_field_properties( state_input(igh_d) )
call state(igh_p) % copy_field_properties( state_input(igh_p) )
call state(igh_u) % copy_field_properties( u_bl_inc_input )

call state(igh_u) % copy_field_properties( ls_state(igh_u) )
call state(igh_t) % copy_field_properties( ls_state(igh_t) )
call state(igh_d) % copy_field_properties( ls_state(igh_d) )
call state(igh_p) % copy_field_properties( ls_state(igh_p) )

! Initialise values and call the tangent-linear alg.
call invoke( setval_random( u_bl_inc ), &
setval_x(u_bl_inc_input, u_bl_inc ), &
setval_random( state(igh_u) ), &
setval_x( state_input(igh_u), state(igh_u) ), &
setval_random( state(igh_t) ), &
setval_x( state_input(igh_t), state(igh_t) ), &
setval_random( state(igh_d) ), &
setval_x( state_input(igh_d), state(igh_d) ), &
setval_random( state(igh_p) ), &
setval_x( state_input(igh_p), state(igh_p) ) )

! LS init
call assign_field_random_range( ls_state(igh_u), ls_u_range(1), ls_u_range(2) )
call assign_field_random_range( ls_state(igh_t), ls_theta_range(1), ls_theta_range(2) )
call invoke( setval_random( ls_state(igh_d) ), setval_random( ls_state(igh_p) ) )

! Tangent linear
call tl_bdy_lyr_alg(modeldb, u_bl_inc, state(igh_u), ls_state, dt )

! < Mx, Mx >
call invoke( x_innerproduct_x( ip1(1), state(igh_u) ), &
x_innerproduct_x( ip1(2), u_bl_inc ) )

sf(1) = 1.0_r_def / (ip1(1) + eps)
sf(2) = 1.0_r_def / (ip1(2) + eps)

inner1 = 0.0_r_def
inner1 = inner1 + ip1(1) * sf(1)
inner1 = inner1 + ip1(2) * sf(2)

! Scaling fields
call invoke( inc_a_times_X( sf(1), state(igh_u) ), &
inc_a_times_X( sf(2), u_bl_inc ) )

! Adjoint alg call and inner products

! Adjoint
call atl_bdy_lyr_alg(modeldb, u_bl_inc, state(igh_u), ls_state, dt )

! < AMx, x >
call invoke( x_innerproduct_y( ip2(1), &
state(igh_u), &
state_input(igh_u) ), &
x_innerproduct_y( ip2(2), &
u_bl_inc, &
u_bl_inc_input ) )

inner2 = 0.0_r_def
inner2 = inner2 + ip2(1)
inner2 = inner2 + ip2(2)

write( log_scratch_space, * ) 'atlt_bdy_lyr_alg: ad test for tl_bdy_lyr_alg: ip1=', ip1(1) * sf(1), ip1(2) * sf(2)
call log_event( log_scratch_space, LOG_LEVEL_DEBUG )
write( log_scratch_space, * ) 'atlt_bdy_lyr_alg: ad test for tl_bdy_lyr_alg: ip2=', ip2
call log_event( log_scratch_space, LOG_LEVEL_DEBUG )
write( log_scratch_space, * ) 'atlt_bdy_lyr_alg: ad test for tl_bdy_lyr_alg: s(ip1),s(ip2)=', inner1, inner2
call log_event( log_scratch_space, LOG_LEVEL_DEBUG )

! Test the inner-product values for equality, allowing for the precision of the active variables
machine_tol = spacing( max( abs( inner1 ), abs( inner2 ) ) )
relative_diff = abs( inner1 - inner2 ) / machine_tol
if ( relative_diff < overall_tolerance ) then
write( log_scratch_space, * ) "PASSED tl_bdy_lyr_alg:", inner1, inner2, relative_diff
call log_event( log_scratch_space, LOG_LEVEL_INFO )
else
write( log_scratch_space, * ) "FAILED tl_bdy_lyr_alg:", inner1, inner2, relative_diff
call log_event( log_scratch_space, LOG_LEVEL_ERROR )
end if

if ( LPROF ) call stop_timing( id, 'atlt_bdy_lyr_alg' )

end subroutine atlt_bdy_lyr_alg

end module atlt_bdy_lyr_alg_mod
Loading
Loading