From 6b5e52b32f628b81fb0c0bd16a45c2fb92cc5183 Mon Sep 17 00:00:00 2001 From: Thomas Bendall <14180399+tommbendall@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:55:27 +0000 Subject: [PATCH 1/5] Change stencil depths to be an array --- .../source/driver/coupled_driver_mod.f90 | 2 +- .../source/driver/io_demo_driver_mod.f90 | 2 +- .../driver/simple_diffusion_driver_mod.f90 | 2 +- .../source/driver/skeleton_driver_mod.f90 | 2 +- components/driver/source/driver_mesh_mod.f90 | 46 ++++++++++++++----- .../source/mesh/check_local_mesh_mod.f90 | 20 ++++---- .../source/mesh/runtime_partition_mod.f90 | 10 ++-- 7 files changed, 54 insertions(+), 30 deletions(-) diff --git a/applications/coupled/source/driver/coupled_driver_mod.f90 b/applications/coupled/source/driver/coupled_driver_mod.f90 index 892f59215..38ab7cd4d 100644 --- a/applications/coupled/source/driver/coupled_driver_mod.f90 +++ b/applications/coupled/source/driver/coupled_driver_mod.f90 @@ -75,7 +75,7 @@ subroutine initialise( program_name, modeldb, calendar ) character(str_def) :: prime_mesh_name - integer(i_def) :: stencil_depth + integer(i_def) :: stencil_depth(1) integer(i_def) :: geometry integer(i_def) :: method integer(i_def) :: number_of_layers diff --git a/applications/io_demo/source/driver/io_demo_driver_mod.f90 b/applications/io_demo/source/driver/io_demo_driver_mod.f90 index 6d8733d99..82351d1a3 100644 --- a/applications/io_demo/source/driver/io_demo_driver_mod.f90 +++ b/applications/io_demo/source/driver/io_demo_driver_mod.f90 @@ -88,7 +88,7 @@ subroutine initialise( program_name, modeldb) character(str_def) :: prime_mesh_name - integer(i_def) :: stencil_depth + integer(i_def) :: stencil_depth(1) integer(i_def) :: geometry integer(i_def) :: method integer(i_def) :: number_of_layers diff --git a/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 b/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 index 3710e98d4..3de0bf0f1 100644 --- a/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 +++ b/applications/simple_diffusion/source/driver/simple_diffusion_driver_mod.f90 @@ -86,7 +86,7 @@ subroutine initialise( program_name, modeldb) character(str_def) :: prime_mesh_name - integer(i_def) :: stencil_depth + integer(i_def) :: stencil_depth(1) integer(i_def) :: geometry integer(i_def) :: method integer(i_def) :: number_of_layers diff --git a/applications/skeleton/source/driver/skeleton_driver_mod.f90 b/applications/skeleton/source/driver/skeleton_driver_mod.f90 index 42a9597a2..b7217e9cc 100644 --- a/applications/skeleton/source/driver/skeleton_driver_mod.f90 +++ b/applications/skeleton/source/driver/skeleton_driver_mod.f90 @@ -83,7 +83,7 @@ subroutine initialise( program_name, modeldb, calendar ) character(str_def) :: prime_mesh_name - integer(i_def) :: stencil_depth + integer(i_def) :: stencil_depth(1) integer(i_def) :: geometry integer(i_def) :: method integer(i_def) :: number_of_layers diff --git a/components/driver/source/driver_mesh_mod.f90 b/components/driver/source/driver_mesh_mod.f90 index 37452a28a..7889431c4 100644 --- a/components/driver/source/driver_mesh_mod.f90 +++ b/components/driver/source/driver_mesh_mod.f90 @@ -80,7 +80,8 @@ module driver_mesh_mod !> @param[in] total_ranks Total number of MPI ranks in this job. !> @param[in] mesh_names Mesh names to load from the mesh input file(s). !> @param[in] extrusion Extrusion object to be applied to meshes. -!> @param[in] stencil_depth Required stencil depth for the application. +!> @param[in] stencil_depths_in Required stencil depth for each mesh for +!! the application. !> @param[in] check_partitions Apply check for even partitions with the !> configured partition stratedy. !> (unpartitioned mesh input only) @@ -90,7 +91,7 @@ module driver_mesh_mod subroutine init_mesh( configuration, & local_rank, total_ranks, & mesh_names, extrusion, & - stencil_depth, & + stencil_depths_in, & check_partitions, & alt_names ) @@ -104,7 +105,7 @@ subroutine init_mesh( configuration, & character(str_def), intent(in) :: mesh_names(:) class(extrusion_type), intent(in) :: extrusion - integer(i_def), intent(in) :: stencil_depth + integer(i_def), intent(in) :: stencil_depths_in(:) logical(l_def), intent(in) :: check_partitions character(str_def), optional, intent(in) :: alt_names(:) @@ -132,12 +133,13 @@ subroutine init_mesh( configuration, & character(str_def), allocatable :: names(:) character(str_def), allocatable :: tmp_mesh_names(:) character(str_max_filename) :: input_mesh_file + integer(i_def), allocatable :: stencil_depths(:) procedure(partitioner_interface), pointer :: partitioner_ptr class(panel_decomposition_type), allocatable :: decomposition - integer(i_def) :: n_digit + integer(i_def) :: i, n_digit character(str_def) :: fmt_str, number_str !============================================================================ @@ -160,13 +162,33 @@ subroutine init_mesh( configuration, & !============================================================================ ! 0.1 Some basic checks !============================================================================ - ! Set up stencil depth - if (stencil_depth < 0_i_def) then - write(log_scratch_space,'(A)') & - 'Standard partitioned meshes must support a not -ve stencil_depth' + + if ( size(stencil_depths_in) == 1 ) then + ! Single stencil depth specified, apply to all meshes + allocate( stencil_depths( size(mesh_names) ) ) + do i = 1, size(mesh_names) + stencil_depths(i) = stencil_depths_in(1) + end do + else if ( size(stencil_depths_in) == size(mesh_names) ) then + ! Stencil depths specified per mesh + allocate( stencil_depths( size(mesh_names) ) ) + stencil_depths = stencil_depths_in + else + write(log_scratch_space, '(A)') & + 'Number of stencil depths specified does not '// & + 'match number of requested meshes.' call log_event(log_scratch_space, LOG_LEVEL_ERROR) end if + ! Check stencil depths are valid + do i = 1, size(stencil_depths) + if (stencil_depths(i) < 0_i_def) then + write(log_scratch_space,'(A)') & + 'Standard partitioned meshes must support a not -ve stencil_depth' + call log_event(log_scratch_space, LOG_LEVEL_ERROR) + end if + end do + ! Currently only quad elements are fully functional if (cellshape /= CELLSHAPE_QUADRILATERAL) then call log_event( "Reference_element must be QUAD for now...", & @@ -240,8 +262,8 @@ subroutine init_mesh( configuration, & ! meshes are suitable for the supplied application ! configuration. !=========================================================== - call check_local_mesh( configuration, & - stencil_depth, & + call check_local_mesh( configuration, & + stencil_depths, & mesh_names ) ! 2.1c Load and assign mesh maps. @@ -300,7 +322,7 @@ subroutine init_mesh( configuration, & call create_local_mesh( mesh_names, & local_rank, total_ranks, & decomposition, & - stencil_depth, & + stencil_depths, & generate_inner_halos, & partitioner_ptr ) @@ -328,6 +350,8 @@ subroutine init_mesh( configuration, & !============================================================================ call assign_mesh_maps(mesh_names) + deallocate(stencil_depths) + end subroutine init_mesh end module driver_mesh_mod diff --git a/components/driver/source/mesh/check_local_mesh_mod.f90 b/components/driver/source/mesh/check_local_mesh_mod.f90 index fc9bd8ed3..72cede6a5 100644 --- a/components/driver/source/mesh/check_local_mesh_mod.f90 +++ b/components/driver/source/mesh/check_local_mesh_mod.f90 @@ -31,19 +31,19 @@ module check_local_mesh_mod !> @brief Basic validation that local meshes are suitable !! for the specified configuration. -!> @param[in] configuration Configuration object. -!> @param[in] stencil_depth Stencil depth that local meshes -!> need to support. -!> @param[in] mesh_names Local meshes held in application -!! local mesh collection object. -subroutine check_local_mesh( configuration, & - stencil_depth, & +!> @param[in] configuration Configuration object. +!> @param[in] stencil_depths Stencil depths that each local mesh +!> needs to support. +!> @param[in] mesh_names Local meshes held in application +!! local mesh collection object. +subroutine check_local_mesh( configuration, & + stencil_depths, & mesh_names ) implicit none type(namelist_collection_type), intent(in) :: configuration - integer(i_def), intent(in) :: stencil_depth + integer(i_def), intent(in) :: stencil_depths(:) character(str_def), intent(in) :: mesh_names(:) integer(i_def) :: topology @@ -120,10 +120,10 @@ subroutine check_local_mesh( configuration, & !===================================== max_stencil_depth = local_mesh%get_max_stencil_depth() - if ( max_stencil_depth < stencil_depth ) then + if ( max_stencil_depth < stencil_depths(i) ) then write(log_scratch_space,'(2(A,I0),A)') & 'Insufficient stencil depth, configuration requires ', & - stencil_depth, '. Mesh "'//trim(mesh_names(i))// & + stencil_depths(i), '. Mesh "'//trim(mesh_names(i))// & '" supports a maximum stencil depth of ', & max_stencil_depth, '.' call log_event(log_scratch_space, log_level_error) diff --git a/components/driver/source/mesh/runtime_partition_mod.f90 b/components/driver/source/mesh/runtime_partition_mod.f90 index 34cd14101..e8b649c91 100644 --- a/components/driver/source/mesh/runtime_partition_mod.f90 +++ b/components/driver/source/mesh/runtime_partition_mod.f90 @@ -113,13 +113,13 @@ end subroutine get_partition_strategy !> and method !> @param[in] generate_inner_halos Generate inner halo regions !! to overlap comms & compute -!> @param[in] stencil_depth Depth of cells outside the base cell -!! of stencil. +!> @param[in] stencil_depths Depth of cells outside the base cell +!! of stencil for each mesh. !> @param[in] partitioner_ptr Mesh partitioning strategy subroutine create_local_mesh( mesh_names, & local_rank, total_ranks, & decomposition, & - stencil_depth, & + stencil_depths, & generate_inner_halos, & partitioner_ptr ) @@ -131,7 +131,7 @@ subroutine create_local_mesh( mesh_names, & integer(i_def), intent(in) :: local_rank integer(i_def), intent(in) :: total_ranks - integer(i_def), intent(in) :: stencil_depth + integer(i_def), intent(in) :: stencil_depths(:) logical(l_def), intent(in) :: generate_inner_halos @@ -154,7 +154,7 @@ subroutine create_local_mesh( mesh_names, & partition = partition_type( global_mesh_ptr, & partitioner_ptr, & decomposition, & - stencil_depth, & + stencil_depths(i), & generate_inner_halos, & local_rank, & total_ranks, & From 56518b3f2baa8ea3158fd9dacabda97017ae788a Mon Sep 17 00:00:00 2001 From: Thomas Bendall <14180399+tommbendall@users.noreply.github.com> Date: Thu, 22 Jan 2026 09:55:11 +0000 Subject: [PATCH 2/5] Fix lbc_demo --- applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 b/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 index 02b814d53..922fa767f 100644 --- a/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 +++ b/applications/lbc_demo/source/driver/lbc_demo_driver_mod.f90 @@ -89,7 +89,7 @@ subroutine initialise( program_name, modeldb) character(str_def) :: output_mesh_name character(str_def) :: context_name - integer(i_def) :: stencil_depth + integer(i_def) :: stencil_depth(1) integer(i_def) :: geometry integer(i_def) :: method integer(i_def) :: number_of_layers From 94e3f989819cf9c586581d1112947dc9a0004128 Mon Sep 17 00:00:00 2001 From: Thomas Bendall <14180399+tommbendall@users.noreply.github.com> Date: Thu, 22 Jan 2026 10:23:15 +0000 Subject: [PATCH 3/5] improve comment and sign contributors on another branch --- CONTRIBUTORS.md | 1 + components/driver/source/driver_mesh_mod.f90 | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 65f2e4058..3aa6b536e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,3 +7,4 @@ | jennyhickson | Jenny Hickson | Met Office | 2025-12-10 | | mo-marqh | Mark Hedley | Met Office | 2025-12-11 | | MatthewHambley | Matthew Hambley | Met Office | 2025-12-15 | +| tommbendall | Thomas Bendall | Met Office | 2026-01-22 | diff --git a/components/driver/source/driver_mesh_mod.f90 b/components/driver/source/driver_mesh_mod.f90 index 7889431c4..02b3f6519 100644 --- a/components/driver/source/driver_mesh_mod.f90 +++ b/components/driver/source/driver_mesh_mod.f90 @@ -81,7 +81,11 @@ module driver_mesh_mod !> @param[in] mesh_names Mesh names to load from the mesh input file(s). !> @param[in] extrusion Extrusion object to be applied to meshes. !> @param[in] stencil_depths_in Required stencil depth for each mesh for -!! the application. +!! the application. If this array is of size 1 then +!! the single value is applied to all meshes. +!! Otherwise the array size must match the size +!! the mesh name array, allowing different depths +!! to be specified for different meshes. !> @param[in] check_partitions Apply check for even partitions with the !> configured partition stratedy. !> (unpartitioned mesh input only) From d70a4c1a4f90e003693e3f7a1e11d6e31b835f61 Mon Sep 17 00:00:00 2001 From: Thomas Bendall <14180399+tommbendall@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:49:05 +0000 Subject: [PATCH 4/5] alignment --- components/driver/source/driver_mesh_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/driver/source/driver_mesh_mod.f90 b/components/driver/source/driver_mesh_mod.f90 index 02b3f6519..74d2d2af0 100644 --- a/components/driver/source/driver_mesh_mod.f90 +++ b/components/driver/source/driver_mesh_mod.f90 @@ -178,7 +178,7 @@ subroutine init_mesh( configuration, & allocate( stencil_depths( size(mesh_names) ) ) stencil_depths = stencil_depths_in else - write(log_scratch_space, '(A)') & + write(log_scratch_space, '(A)') & 'Number of stencil depths specified does not '// & 'match number of requested meshes.' call log_event(log_scratch_space, LOG_LEVEL_ERROR) From a47bb3d69e20c3467fc885ad557d0a9241820c76 Mon Sep 17 00:00:00 2001 From: Thomas Bendall <14180399+tommbendall@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:13:49 +0000 Subject: [PATCH 5/5] remove myself from contributors --- CONTRIBUTORS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3aa6b536e..65f2e4058 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,4 +7,3 @@ | jennyhickson | Jenny Hickson | Met Office | 2025-12-10 | | mo-marqh | Mark Hedley | Met Office | 2025-12-11 | | MatthewHambley | Matthew Hambley | Met Office | 2025-12-15 | -| tommbendall | Thomas Bendall | Met Office | 2026-01-22 |