3 use iso_c_binding,
only: c_int, c_char, c_null_char, c_size_t, c_ptrdiff_t, c_ptr, c_loc, c_sizeof, c_long
5 use netcdf,
only : nf90_global, nf90_nowrite, nf90_inquire_attribute, nf90_open, nf90_inq_dimid, nf90_inquire_dimension, &
6 nf90_inq_varid, nf90_get_var, nf90_get_att, nf90_close
12 use mpi,
only : mpi_comm_rank, mpi_comm_size
27 use iso_c_binding,
only: c_int, c_size_t, c_char
29 integer(kind=c_int),
value :: ncid
30 integer(kind=c_int),
value :: dimid
31 character(kind=c_char),
intent(inout) :: name(*)
32 integer(kind=c_size_t),
intent(out) :: lenp
38 use iso_c_binding,
only: c_int, c_long, c_ptr
40 integer(kind=c_int),
value :: ncid, varid
41 type(c_ptr),
value :: startp, countp
42 integer(kind=c_long),
intent(out) :: ip(*)
48 use iso_c_binding,
only: c_int, c_ptr, c_char
50 integer(kind=c_int),
value :: ncid, varid
51 type(c_ptr),
value :: startp, countp, stridep
52 character(kind=c_char),
intent(out) :: ip(*)
59 character,
dimension(:),
intent(in) :: byte_data
72 character(len=STRING_LENGTH),
intent(in) :: checkpoint_filename
73 character,
dimension(:),
allocatable,
intent(inout) :: io_xml_configuration
74 integer,
intent(in) :: io_communicator_arg
76 integer :: ncid, number_io_server, my_io_server_rank, ierr
77 integer :: dim_id, dim_size
80 call mpi_comm_rank(io_communicator_arg, my_io_server_rank, ierr)
81 call mpi_comm_size(io_communicator_arg, number_io_server, ierr)
82 call check_netcdf_status(nf90_open(path = checkpoint_filename, mode = nf90_nowrite, ncid = ncid))
85 if (my_io_server_rank==0)
then
86 call log_log(
log_warn,
"Restarting the IO server fresh as the checkpoint file does not contain IO state")
92 if (dim_size .ne. number_io_server)
then
93 call log_log(
log_error,
"Can not restart IO server with a different number of IO servers")
108 type(
hashmap_type),
volatile,
intent(inout) :: time_points
110 integer :: ncid, ierr, i
111 character,
dimension(:),
allocatable :: raw_bytes
114 mode = nf90_nowrite, ncid = ncid))
116 do i=1,
size(writer_entries)
118 if (writer_entries(i)%include_in_io_state_write)
then
122 deallocate(raw_bytes)
127 "serialised_timeaveraged_manipulation", raw_bytes)
129 deallocate(raw_bytes)
132 "serialised_instantaneous_manipulation", raw_bytes)
134 deallocate(raw_bytes)
137 "serialised_timepoints", raw_bytes)
139 deallocate(raw_bytes)
152 integer :: ncid, ierr
153 character,
dimension(:),
allocatable :: raw_bytes
156 mode = nf90_nowrite, ncid = ncid))
159 "serialised_writer_manager", raw_bytes)
161 deallocate(raw_bytes)
170 integer,
intent(in) :: ncid
171 character,
dimension(:),
allocatable,
intent(inout) :: io_xml_configuration
173 integer :: dim_id, var_id, dim_size
177 if (.not. found)
return
181 if (.not. found)
return
182 allocate(io_xml_configuration(dim_size))
183 call check_netcdf_status(nf90_get_var(ncid, var_id, io_xml_configuration, count=(/dim_size/)))
194 integer,
intent(in) :: ncid, number_io_server, my_io_server_rank
195 character(len=*),
intent(in) :: base_key
196 character,
dimension(:),
allocatable,
intent(out) :: raw_bytes
198 integer :: dim_id, var_id
200 integer(kind=8) :: dim_size, serialised_range(2), number_serialised_entries
202 integer(kind=c_int) :: cncid, cdimid, cstatus, cvarid
203 integer(kind=c_size_t) :: cdlen
204 character(len=256) :: tmpname
205 integer(KIND=c_size_t),
target :: cstart(1), ccounts(1)
206 Integer(KIND=c_ptrdiff_t),
target :: cstrides(1)
207 type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
210 cstartptr=c_loc(cstart)
211 ccountsptr=c_loc(ccounts)
212 cstridesptr=c_loc(cstrides)
215 if (.not. found)
return
221 call check_netcdf_status(nf90_inq_varid(ncid, trim(base_key)//
"_directory", var_id), found)
222 if (.not. found)
return
224 cstart(1)=my_io_server_rank
225 if (my_io_server_rank .lt. number_io_server-1)
then
228 if (serialised_range(2) .gt. dim_size)
then
234 serialised_range(2)=dim_size
236 number_serialised_entries=(serialised_range(2)-serialised_range(1)) + 1
238 if (.not. found)
return
239 allocate(raw_bytes(number_serialised_entries))
242 cstart=serialised_range(1)-1
243 ccounts=number_serialised_entries
253 character,
dimension(:),
allocatable :: raw_bytes
255 integer :: i, number_entries, current_point, byte_size
257 if (.not.
allocated(raw_bytes))
then
263 if (number_entries .ne.
size(writer_entries))
then
264 call log_log(
log_error,
"On restart have a different number of configured entries than those in the checkpoint file")
266 do i=1,
size(writer_entries)
267 if (writer_entries(i)%include_in_io_state_write)
then
270 current_point=current_point+byte_size
279 type(
hashmap_type),
volatile,
intent(inout) :: time_points
280 character,
dimension(:),
allocatable :: raw_bytes
282 integer :: i, number_entries, current_point, byte_size, timestep_key
285 if (.not.
allocated(raw_bytes))
then
291 do i=1, number_entries
301 character,
dimension(:),
allocatable :: raw_bytes
303 if (.not.
allocated(raw_bytes))
then
313 character,
dimension(:),
allocatable :: raw_bytes
315 if (.not.
allocated(raw_bytes))
then
327 character,
dimension(:),
allocatable :: raw_bytes
329 if (.not.
allocated(raw_bytes))
then
333 call unserialise_writer_field_manager(raw_bytes)