Skip to content
Draft
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: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
| MetBenjaminWent | Benjamin Went | Met Office | 2026-01-30 |
| jcsmeto | James Cunningham-Smith | Met Office | 2026-02-06 |
| thomasmelvin | Thomas Melvin | Met Office | 2026-01-15 |
| ericaneininger | Erica Neininger | Met Office | 2026-03-02 |
| ericaneininger | Erica Neininger | Met Office | 2026-03-02 |
| allynt | Allyn Treshansky | Met Office | 2026-02-12 |
8 changes: 4 additions & 4 deletions components/lfric-xios/source/lfric_xios_read_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ subroutine checkpoint_read_value(io_value, value_name)
class(io_value_type), intent(inout) :: io_value
character(*), optional, intent(in) :: value_name
character(str_def) :: restart_id
integer(i_def) :: array_dims
real(kind=r_def), allocatable :: data_value(:)
integer(tik) :: timing_id

if ( LPROF ) call start_timing(timing_id, 'lfric_xios.chkpt_readv')
Expand All @@ -129,11 +129,11 @@ subroutine checkpoint_read_value(io_value, value_name)
else
restart_id = "restart_" // trim(io_value%io_id)
end if
array_dims = size(io_value%data)

allocate(data_value, source=io_value%get_data())

if ( xios_is_valid_field(trim(restart_id)) ) then
call xios_recv_field( trim(restart_id), &
io_value%data(1:array_dims) )
call xios_recv_field( trim(restart_id), data_value )
else
call log_event( 'No XIOS field with id="'//trim(restart_id)//'" is defined', &
LOG_LEVEL_ERROR )
Expand Down
15 changes: 9 additions & 6 deletions components/lfric-xios/source/lfric_xios_write_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ subroutine write_value_generic(io_value, value_name)
class(io_value_type), intent(inout) :: io_value
character(*), optional, intent(in) :: value_name

integer(i_def) :: array_dims
real(kind=r_def), allocatable :: data_value(:)
character(:), allocatable :: value_id

if (present(value_name)) then
Expand All @@ -92,10 +92,11 @@ subroutine write_value_generic(io_value, value_name)
value_id = io_value%io_id
end if

array_dims = size(io_value%data)
allocate(data_value, source=io_value%get_data())

if ( xios_is_valid_field(trim(value_id)) ) then
call xios_send_field( trim(value_id), &
reshape(io_value%data, (/ 1, array_dims /)) )
reshape(data_value, (/ 1, size(data_value) /)) )
else
call log_event( 'No XIOS field with id="'//trim(io_value%io_id)//'" is defined', &
LOG_LEVEL_ERROR )
Expand Down Expand Up @@ -191,17 +192,19 @@ subroutine checkpoint_write_value(io_value, value_name)
character(*), optional, intent(in) :: value_name

character(str_def) :: checkpoint_id
integer(i_def) :: array_dims
real(kind=r_def), allocatable :: data_value(:)

if(present(value_name)) then
checkpoint_id = trim(value_name)
else
checkpoint_id = trim(io_value%io_id)
end if
array_dims = size(io_value%data)

allocate(data_value, source=io_value%get_data())

if ( xios_is_valid_field(trim(checkpoint_id)) ) then
call xios_send_field( trim(checkpoint_id), &
reshape(io_value%data, (/ 1, array_dims /)) )
reshape(data_value, (/ 1, size(data_value) /)) )
else
call log_event( 'No XIOS field with id="'//trim(checkpoint_id)//'" is defined', &
LOG_LEVEL_ERROR )
Expand Down
35 changes: 31 additions & 4 deletions infrastructure/source/io/io_value_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ module io_value_mod
!> that can be stored in a key-value pair
type, extends(abstract_value_type) :: io_value_type
character(str_def) :: io_id
! TODO:
! real(kind=r_def), private, allocatable :: data(:)
real(kind=r_def), allocatable :: data(:)
procedure(io_operation_interface), pointer :: write_method => null()
procedure(io_operation_interface), pointer :: checkpoint_read_method => null()
procedure(io_operation_interface), pointer :: checkpoint_write_method => null()
contains
procedure, public :: init
procedure, public :: set_data
procedure, public :: get_data
procedure, public :: set_write_behaviour
procedure, public :: set_checkpoint_write_behaviour
procedure, public :: set_checkpoint_read_behaviour
Expand All @@ -49,18 +53,41 @@ end subroutine io_operation_interface

!> @brief Initialiser for the io_value_type
!> @param[in] io_id The ID used for managing I/O operations
!> @param[in] data An array holding the data
subroutine init(self, io_id, data)
!> @param[in] data_value An array holding the data
subroutine init(self, io_id, data_value)
class(io_value_type), intent(inout) :: self

character(len=*), intent(in) :: io_id
real(kind=r_def), intent(in) :: data(:)
real(kind=r_def), intent(in) :: data_value(:)

self%io_id = io_id
allocate(self%data, source=data)
allocate(self%data, source=data_value)

end subroutine init

!> @brief Setter for the data array
!> @param[in] data_value An array holding the data
subroutine set_data(self, data_value)
class(io_value_type), intent(inout) :: self
real(kind=r_def), intent(in) :: data_value(:)

if (allocated(self%data)) then
deallocate(self%data)
end if
allocate(self%data, source=data_value)

end subroutine set_data

!> @brief Getter for the data array
!> @return An array holding the data
function get_data(self) result(data_value)
class(io_value_type), intent(in) :: self

real(kind=r_def), dimension(1:size(self%data)) :: data_value
data_value = self%data

end function get_data

!> @brief Sets the diagnostic write behaviour for io_value
!> @param[in] write_behaviour Pointer to procedure implementing the write method
subroutine set_write_behaviour(self, write_behaviour)
Expand Down