Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
| timgraham-Met | Tim Graham | Met Office | 2026-05-20 |
| tinyendian | Wolfgang Hayek | Earth Sciences New Zealand | 2026-05-04 |
| Adrian-Lock | Adrian Lock | Met Office | 2026-05-21 |
| ukmo-juan-castillo | Juan M. Castillo | Met Office | 2026-03-24 |
| mcdalvi | Mohit Dalvi | Met Office | 2026-06-19 |
| cjohnson-pi | Christine Johnson | Met Office | 2026-06-29 |
1 change: 0 additions & 1 deletion applications/coupled/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<variable_definition>
<variable_group id = "buffer">
<variable id = "optimal_buffer_size" type = "string" >performance</variable>
<variable id = "buffer_factor_size" type = "double" >1.0</variable>
</variable_group>

<variable_group id = "parameters" >
Expand Down
1 change: 0 additions & 1 deletion applications/io_demo/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<variable_definition>
<variable_group id = "buffer">
<variable id = "optimal_buffer_size" type = "string" >performance</variable>
<variable id = "buffer_factor_size" type = "double" >1.0</variable>
</variable_group>

<variable_group id = "parameters" >
Expand Down
6 changes: 2 additions & 4 deletions applications/io_demo/source/driver/io_demo_checkpoint_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module io_demo_checkpoint_mod
use field_mod, only: field_type
use field_collection_mod, only: field_collection_type
use file_mod, only: FILE_MODE_WRITE, FILE_MODE_READ
use io_context_mod, only: io_context_type, callback_clock_arg
use io_context_mod, only: io_context_type
use linked_list_mod, only: linked_list_type
use lfric_xios_action_mod, only: advance
use lfric_xios_context_mod, only: lfric_xios_context_type
Expand Down Expand Up @@ -48,7 +48,6 @@ subroutine setup_checkpoint_io(modeldb, chi, panel_id)

class(event_actor_type), pointer :: event_actor_ptr
procedure(event_action), pointer :: context_advance
procedure(callback_clock_arg), pointer :: before_close

character(len=str_max_filename) :: checkpoint_write_filename
character(len=str_max_filename) :: checkpoint_read_filename
Expand Down Expand Up @@ -126,9 +125,8 @@ subroutine setup_checkpoint_io(modeldb, chi, panel_id)
! Add checkpoint context to clock events so that it is advanced at each timestep
event_actor_ptr => cp_context
context_advance => advance
before_close => null()
call cp_context%initialise_xios_context( modeldb%mpi%get_comm(), chi, panel_id, &
modeldb%clock, modeldb%calendar, before_close )
modeldb%clock, modeldb%calendar )

call modeldb%clock%add_event(context_advance, event_actor_ptr)
call cp_context%set_active(.true.)
Expand Down
1 change: 0 additions & 1 deletion applications/io_demo/source/driver/io_demo_driver_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module io_demo_driver_mod
LOG_LEVEL_TRACE
use mesh_mod, only : mesh_type
use mesh_collection_mod, only : mesh_collection
use model_clock_mod, only : model_clock_type
use multifile_field_setup_mod, only : create_multifile_io_fields
use multifile_io_mod, only : init_multifile_io, step_multifile_io
use io_benchmark_setup_mod, only : create_io_benchmark_fields, &
Expand Down
8 changes: 4 additions & 4 deletions applications/io_demo/source/driver/io_demo_temporal_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module io_demo_temporal_mod
use function_space_collection_mod, only : function_space_collection
use function_space_mod, only : function_space_type
use fs_continuity_mod, only: Wtheta
use io_context_mod, only: io_context_type, callback_clock_arg
use io_context_mod, only: io_context_type
use linked_list_mod, only: linked_list_type
use lfric_xios_action_mod, only: advance
use lfric_xios_context_mod, only: lfric_xios_context_type
Expand Down Expand Up @@ -87,7 +87,6 @@ subroutine setup_temporal_io(modeldb, chi, panel_id)

class(event_actor_type), pointer :: event_actor_ptr
procedure(event_action), pointer :: context_advance
procedure(callback_clock_arg), pointer :: before_close

call log_event( 'io_demo: Setting up temporal I/O', LOG_LEVEL_DEBUG )

Expand Down Expand Up @@ -125,9 +124,8 @@ subroutine setup_temporal_io(modeldb, chi, panel_id)
end if

! Initialise the XIOS context attached to the temporal context object
before_close => null()
call temporal_context%initialise_xios_context( modeldb%mpi%get_comm(), chi, panel_id, &
modeldb%clock, modeldb%calendar, before_close )
modeldb%clock, modeldb%calendar )

! Add context object to the model clock's event loop, this means that the
! temporal context will be advanced at each model time step, and the
Expand All @@ -137,6 +135,8 @@ subroutine setup_temporal_io(modeldb, chi, panel_id)
call modeldb%clock%add_event(context_advance, event_actor_ptr)
call temporal_context%set_active(.true.)

call temporal_context%close_context_definition()

! Set current context back to main
call modeldb%io_contexts%get_io_context("io_demo", io_context)
call io_context%set_current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module multifile_io_mod
use multifile_file_setup_mod,only: init_multifile_files
use inventory_by_mesh_mod, only: inventory_by_mesh_type
use io_context_collection_mod, only: io_context_collection_type
use io_context_mod, only: io_context_type, callback_clock_arg
use io_context_mod, only: io_context_type
use log_mod, only: log_event, log_level_error, &
log_level_trace, log_level_info, &
log_scratch_space
Expand All @@ -29,7 +29,6 @@ module multifile_io_mod
use lfric_xios_action_mod, only: advance_read_only
use mesh_mod, only: mesh_type
use mesh_collection_mod, only: mesh_collection
use model_clock_mod, only: model_clock_type
use step_calendar_mod, only: step_calendar_type

use multifile_io_nml_iterator_mod, only: multifile_io_nml_iterator_type
Expand Down Expand Up @@ -121,12 +120,10 @@ subroutine step_multifile_io(modeldb, chi_inventory, panel_id_inventory)
character(str_def) :: time_start

procedure(event_action), pointer :: context_advance
procedure(callback_clock_arg), pointer :: before_close

nullify(mesh)
nullify(chi)
nullify(panel_id)
nullify(before_close)

call iter%initialise(modeldb%config%multifile_io)
do while (iter%has_next())
Expand Down Expand Up @@ -162,9 +159,10 @@ subroutine step_multifile_io(modeldb, chi_inventory, panel_id_inventory)
call io_context%initialise_xios_context( modeldb%mpi%get_comm(), &
chi, panel_id, &
modeldb%clock, tmp_calendar, &
before_close, &
start_at_zero=.true. )

call io_context%close_context_definition()

! Attach context advancement to the model's clock
context_advance => advance_read_only
event_actor_ptr => io_context
Expand Down
1 change: 0 additions & 1 deletion applications/lbc_demo/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<variable_definition>
<variable_group id = "buffer">
<variable id = "optimal_buffer_size" type = "string" >performance</variable>
<variable id = "buffer_factor_size" type = "double" >1.0</variable>
</variable_group>

<variable_group id = "parameters" >
Expand Down
19 changes: 10 additions & 9 deletions applications/lbc_demo/example/mesh_config.nml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
/

&planar_mesh
edge_cells_x = 30
edge_cells_y = 30
domain_size = 24.0, 22.0
domain_centre = 0.0, 0.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
lbc_rim_depth = 6
lbc_parent_mesh = 'primary'
edge_cells_x = 30
edge_cells_y = 30
domain_size = 24.0, 22.0
domain_centre = 0.0, 0.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
lbc_rim_depth = 6
lbc_parent_mesh = 'primary'
stretch_function = 'uniform'
/

&partitions
Expand Down
1 change: 0 additions & 1 deletion applications/simple_diffusion/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<variable_definition>
<variable_group id = "buffer">
<variable id = "optimal_buffer_size" type = "string" >performance</variable>
<variable id = "buffer_factor_size" type = "double" >1.0</variable>
</variable_group>

<variable_group id = "parameters" >
Expand Down
1 change: 0 additions & 1 deletion applications/skeleton/example/iodef.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<variable_definition>
<variable_group id = "buffer">
<variable id = "optimal_buffer_size" type = "string" >performance</variable>
<variable id = "buffer_factor_size" type = "double" >1.0</variable>
</variable_group>

<variable_group id = "parameters" >
Expand Down
43 changes: 27 additions & 16 deletions components/driver/source/driver_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module driver_io_mod
use field_mod, only: field_type
use inventory_by_mesh_mod, only: inventory_by_mesh_type
use io_context_collection_mod, only: io_context_collection_type
use io_context_mod, only: io_context_type, callback_clock_arg
use io_context_mod, only: io_context_type
use log_mod, only: log_event, log_level_error, &
log_level_trace, log_level_info, &
log_scratch_space
Expand All @@ -47,6 +47,19 @@ subroutine filelist_populator(files_list, modeldb)
end subroutine filelist_populator
end interface

abstract interface
!> @brief Callback interface for bespoke IO configuration
!> @param[in] config configuration to be passed in at call site
!> @param[in] clock Clock to be passed in at call site
subroutine io_configuration_callback(config,clock)
use config_mod, only: config_type
use clock_mod, only : clock_type
implicit none
type(config_type), intent(in) :: config
class(clock_type), intent(in) :: clock
end subroutine io_configuration_callback
end interface

contains

!> @brief Initialises the model I/O
Expand Down Expand Up @@ -82,9 +95,10 @@ subroutine init_io( context_name, &
procedure(filelist_populator), &
pointer, optional, intent(in) :: populate_filelist
character(len=str_def), optional, intent(in) :: alt_mesh_names(:)
procedure(callback_clock_arg), optional :: before_close
procedure(io_configuration_callback), &
optional :: before_close

procedure(callback_clock_arg), pointer :: before_close_ptr
type(lfric_xios_context_type), pointer :: context

logical(l_def) :: use_xios_io

Expand All @@ -93,20 +107,22 @@ subroutine init_io( context_name, &
! Allocate IO context type based on model configuration
if ( use_xios_io ) then
#ifdef USE_XIOS
if (present(before_close)) then
before_close_ptr => before_close
else
before_close_ptr => null()
end if

call init_xios_io_context( context_name, &
mesh_name, &
modeldb, &
chi_inventory, &
panel_id_inventory, &
before_close_ptr, &
populate_filelist, &
alt_mesh_names )

call modeldb%io_contexts%get_io_context(context_name, context)
call context%set_current()
if (present(before_close)) then
call before_close(modeldb%config, modeldb%clock)
end if

call context%close_context_definition()

#else
call log_event( "Cannot use XIOS I/O: model has not been built with " // &
"XIOS enabled", log_level_error )
Expand Down Expand Up @@ -154,7 +170,6 @@ end subroutine init_empty_io_context
!> @param[in] modeldb Model state
!> @param[in] chi_inventory Contains the model's coordinate fields
!> @param[in] panel_id_inventory Contains the model's panel ID fields
!> @param[in] before_close Routine to be called before context closes
!> @param[in] populate_filelist Optional procedure for creating a list of
!! file descriptions used by the model I/O
!> @param[in] alt_mesh_names Optional array of names for other meshes
Expand All @@ -164,7 +179,6 @@ subroutine init_xios_io_context( context_name, &
modeldb, &
chi_inventory, &
panel_id_inventory, &
before_close, &
populate_filelist, &
alt_mesh_names )

Expand All @@ -175,7 +189,6 @@ subroutine init_xios_io_context( context_name, &
class(modeldb_type), intent(inout) :: modeldb
type(inventory_by_mesh_type), intent(in) :: chi_inventory
type(inventory_by_mesh_type), intent(in) :: panel_id_inventory
procedure(callback_clock_arg), pointer, intent(in) :: before_close
procedure(filelist_populator), &
pointer, optional, intent(in) :: populate_filelist
character(len=str_def), optional, intent(in) :: alt_mesh_names(:)
Expand Down Expand Up @@ -255,7 +268,6 @@ subroutine init_xios_io_context( context_name, &
chi, panel_id, &
modeldb%clock, &
modeldb%calendar, &
before_close, &
alt_coords, &
alt_panel_ids )
deallocate(alt_coords)
Expand All @@ -264,8 +276,7 @@ subroutine init_xios_io_context( context_name, &
call io_context%initialise_xios_context( modeldb%mpi%get_comm(), &
chi, panel_id, &
modeldb%clock, &
modeldb%calendar, &
before_close )
modeldb%calendar )
end if

! Attach context advancement to the model's clock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
program lfric_xios_context_test

use field_mod, only: field_type
use io_context_mod, only: callback_clock_arg
use lfric_xios_context_mod, only: lfric_xios_context_type
use lfric_xios_driver_mod, only: lfric_xios_initialise, lfric_xios_finalise
use log_mod, only: log_event, log_level_info
Expand All @@ -23,7 +22,6 @@ program lfric_xios_context_test
type(test_db_type) :: test_db
type(lfric_xios_context_type), allocatable :: io_context

procedure(callback_clock_arg), pointer :: before_close => null()

call test_db%initialise()
call lfric_xios_initialise( "test", test_db%comm, .false. )
Expand All @@ -34,8 +32,7 @@ program lfric_xios_context_test
call io_context%initialise( "test_io_context", 1, 10 )
call io_context%initialise_xios_context( test_db%comm, &
test_db%chi, test_db%panel_id, &
test_db%clock, test_db%calendar, &
before_close )
test_db%clock, test_db%calendar )
deallocate(io_context)

! ============================== Finish test =================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ program lfric_xios_cyclic_temporal_test
use event_actor_mod, only: event_actor_type
use field_mod, only: field_type, field_proxy_type
use file_mod, only: FILE_MODE_READ, FILE_MODE_WRITE
use io_context_mod, only: callback_clock_arg
use lfric_xios_action_mod, only: advance
use lfric_xios_context_mod, only: lfric_xios_context_type
use lfric_xios_driver_mod, only: lfric_xios_initialise, lfric_xios_finalise
Expand All @@ -28,7 +27,6 @@ program lfric_xios_cyclic_temporal_test
type(test_db_type) :: test_db
type(lfric_xios_context_type), target, allocatable :: io_context

procedure(callback_clock_arg), pointer :: before_close
type(linked_list_type), pointer :: file_list
class(event_actor_type), pointer :: context_actor
procedure(event_action), pointer :: context_advance
Expand Down Expand Up @@ -63,11 +61,9 @@ program lfric_xios_cyclic_temporal_test
freq=1, &
fields_in_file=test_db%temporal_fields ) )

before_close => null()
call io_context%initialise_xios_context( test_db%comm, &
test_db%chi, test_db%panel_id, &
test_db%clock, test_db%calendar, &
before_close )
test_db%clock, test_db%calendar )


context_advance => advance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ program lfric_xios_temporal_interp_test
use event_actor_mod, only: event_actor_type
use field_mod, only: field_type, field_proxy_type
use file_mod, only: FILE_MODE_READ, FILE_MODE_WRITE
use io_context_mod, only: callback_clock_arg
use lfric_xios_action_mod, only: advance
use lfric_xios_context_mod, only: lfric_xios_context_type
use lfric_xios_driver_mod, only: lfric_xios_initialise, lfric_xios_finalise
Expand All @@ -29,7 +28,6 @@ program lfric_xios_temporal_interp_test
type(test_db_type) :: test_db
type(lfric_xios_context_type), target, allocatable :: io_context

procedure(callback_clock_arg), pointer :: before_close
type(linked_list_type), pointer :: file_list
class(event_actor_type), pointer :: context_actor
procedure(event_action), pointer :: context_advance
Expand Down Expand Up @@ -65,12 +63,9 @@ program lfric_xios_temporal_interp_test
freq=1, &
fields_in_file=test_db%temporal_fields ) )

before_close => null()
call io_context%initialise_xios_context( test_db%comm, &
test_db%chi, test_db%panel_id, &
test_db%clock, test_db%calendar, &
before_close )

test_db%clock, test_db%calendar )

context_advance => advance
context_actor => io_context
Expand Down
Loading