MONC
Data Types | Functions/Subroutines
writer_types_mod Module Reference

Writer types which are shared across writing functionality. Also includes serialisation functionality for these types. More...

Data Types

type  collective_q_field_representation_type
 
type  netcdf_diagnostics_timeseries_type
 
type  netcdf_diagnostics_type
 
type  pending_write_type
 
type  write_field_collective_descriptor_type
 
type  write_field_collective_monc_info_type
 
type  write_field_collective_values_type
 
type  writer_field_type
 
type  writer_type
 

Functions/Subroutines

integer(kind=8) function, public prepare_to_serialise_writer_type (writer_to_serialise)
 Prepares to serialise the writer type by issuing locks and determining the size of serialised bytes needed. More...
 
subroutine, public serialise_writer_type (writer_to_serialise, byte_data)
 Serialises a specific writer type into byte data (for storage or transmission.) Releases any locks issued during preparation. More...
 
subroutine, public unserialise_writer_type (writer_to_unserialise, byte_data)
 Unserialises some byte data into the writer in order to recreate the state of the writer. More...
 
integer(kind=8) function prepare_to_serialise_writer_field_type (writer_field_to_serialise)
 Prepares to serialise a specific writer field, both determines the data size and issues any locks. More...
 
subroutine serialise_writer_field_type (writer_field_to_serialise, byte_data, current_data_point)
 Serialises a specific writer field type for storage or transmission. This releases any locks issued during preparation. More...
 
subroutine unserialise_writer_field_type (writer_field_to_unserialise, byte_data)
 Unserialises byte data into a writer field type. More...
 
integer(kind=8) function prepare_to_serialise_collective_values_type (collective_values_to_serialise)
 Prepares to serialise a specific collective value, both determines the required byte storate size and issues any locks. More...
 
subroutine serialise_collective_values_type (collective_values_to_serialise, byte_data, current_data_point)
 Serialises collective values. This releases any locks issued during preparation. More...
 
type(write_field_collective_values_type) function, pointer unserialise_collective_values_type (byte_data)
 Unserialsies collective values contained in some data. More...
 
integer(kind=8) function, public prepare_to_serialise_data_values_type (data_values_to_serialise)
 Prepares to serialise a specific data values type, both determines the byte size required and also issues any locks. More...
 
subroutine, public serialise_data_values_type (data_values_to_serialise, byte_data, current_data_point)
 Serialises some data values to store or transmit. This releases any locks issued during preparation. More...
 
type(data_values_type) function, pointer, public unserialise_data_values_type (byte_data)
 Unserialises some byte data into data values. More...
 
integer(kind=8) function prepare_to_serialise_string_map (map_to_serialise)
 Prepares a map for serialisation, both determines the size of storage required and also issues any locks. More...
 
subroutine serialise_string_map (map_to_serialise, byte_data, current_data_point)
 Serialises a string map, where the values are assumed to be strings. This releases any locks issued during preparation. More...
 
type(map_type) function, pointer unserialise_string_map (byte_data)
 Inflates some byte data into a string map. More...
 

Detailed Description

Writer types which are shared across writing functionality. Also includes serialisation functionality for these types.

Function/Subroutine Documentation

◆ prepare_to_serialise_collective_values_type()

integer(kind=8) function writer_types_mod::prepare_to_serialise_collective_values_type ( type(write_field_collective_values_type), intent(inout)  collective_values_to_serialise)
private

Prepares to serialise a specific collective value, both determines the required byte storate size and issues any locks.

Parameters
collective_values_to_serialiseThe collective values to prepare for serialisation
Returns
The number of bytes needed to store the serialised state

Definition at line 361 of file writer_types.F90.

361  type(write_field_collective_values_type), intent(inout) :: collective_values_to_serialise
362 
363  class(*), pointer :: generic
364  type(mapentry_type) :: map_entry
365  type(iterator_type) :: iterator
366 
367  prepare_to_serialise_collective_values_type=kind(prepare_to_serialise_collective_values_type)
368  if (c_size(collective_values_to_serialise%monc_values) .gt. 0) then
369  iterator=c_get_iterator(collective_values_to_serialise%monc_values)
370  do while (c_has_next(iterator))
371  map_entry=c_next_mapentry(iterator)
372  generic=>c_get_generic(map_entry)
373  if (associated(generic)) then
374  select type(generic)
375  type is (data_values_type)
376  prepare_to_serialise_collective_values_type=prepare_to_serialise_collective_values_type+&
377  prepare_to_serialise_data_values_type(generic)+&
378  (kind(prepare_to_serialise_collective_values_type)*2)+len(trim(map_entry%key))
379  class default
380  call log_log(log_error, "Unknown data type in collective values type")
381  end select
382  end if
383  end do
384  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_to_serialise_data_values_type()

integer(kind=8) function, public writer_types_mod::prepare_to_serialise_data_values_type ( type(data_values_type), intent(inout)  data_values_to_serialise)

Prepares to serialise a specific data values type, both determines the byte size required and also issues any locks.

Parameters
data_values_to_serialiseThe data values to prepare for serialisation
Returns
The number of bytes needed to store the serialised state

Definition at line 463 of file writer_types.F90.

463  type(data_values_type), intent(inout) :: data_values_to_serialise
464 
465  integer :: values_size
466 
467  prepare_to_serialise_data_values_type=kind(prepare_to_serialise_data_values_type) * 8
468 
469  if (allocated(data_values_to_serialise%values)) then
470  prepare_to_serialise_data_values_type=prepare_to_serialise_data_values_type+&
471  (kind(data_values_to_serialise%values)*size(data_values_to_serialise%values))
472  else if (allocated(data_values_to_serialise%string_values)) then
473  prepare_to_serialise_data_values_type=prepare_to_serialise_data_values_type+&
474  (size(data_values_to_serialise%string_values) * string_length)
475  else
476  prepare_to_serialise_data_values_type=prepare_to_serialise_data_values_type+&
477  prepare_to_serialise_string_map(data_values_to_serialise%map_values)
478  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_to_serialise_string_map()

integer(kind=8) function writer_types_mod::prepare_to_serialise_string_map ( type(map_type), intent(inout)  map_to_serialise)
private

Prepares a map for serialisation, both determines the size of storage required and also issues any locks.

Parameters
map_to_serialiseThe map which will be prepared for serialisation
Returns
The number of bytes needed to store the serialised state

Definition at line 562 of file writer_types.F90.

562  type(map_type), intent(inout) :: map_to_serialise
563 
564  type(mapentry_type) :: map_entry
565  type(iterator_type) :: iterator
566  character(len=STRING_LENGTH) :: str_value
567 
568  prepare_to_serialise_string_map=kind(prepare_to_serialise_string_map)
569  iterator=c_get_iterator(map_to_serialise)
570  do while (c_has_next(iterator))
571  map_entry=c_next_mapentry(iterator)
572  str_value=c_get_string(map_entry)
573  prepare_to_serialise_string_map=prepare_to_serialise_string_map+len(trim(map_entry%key)) + &
574  len(trim(str_value)) + (kind(prepare_to_serialise_string_map) * 2)
575  end do
Here is the caller graph for this function:

◆ prepare_to_serialise_writer_field_type()

integer(kind=8) function writer_types_mod::prepare_to_serialise_writer_field_type ( type(writer_field_type), intent(inout)  writer_field_to_serialise)
private

Prepares to serialise a specific writer field, both determines the data size and issues any locks.

Parameters
writer_field_to_serialiseThe writer field type to prepare for serialisation
Returns
The number of bytes needed to store the serialised state

Definition at line 238 of file writer_types.F90.

238  type(writer_field_type), intent(inout) :: writer_field_to_serialise
239 
240  type(iterator_type) :: iterator
241  class(*), pointer :: generic
242  type(mapentry_type) :: map_entry
243 
244  call check_thread_status(forthread_mutex_lock(writer_field_to_serialise%values_mutex))
245  prepare_to_serialise_writer_field_type=(kind(writer_field_to_serialise%latest_timestep_values) * 2) + &
246  (kind(writer_field_to_serialise%previous_write_time) * 2)
247 
248  iterator=c_get_iterator(writer_field_to_serialise%values_to_write)
249  do while (c_has_next(iterator))
250  map_entry=c_next_mapentry(iterator)
251  generic=>c_get_generic(map_entry)
252  if (associated(generic)) then
253  select type(generic)
254  type is (data_values_type)
255  prepare_to_serialise_writer_field_type=prepare_to_serialise_writer_field_type+&
256  prepare_to_serialise_data_values_type(generic)+&
257  (kind(prepare_to_serialise_writer_field_type)*3)+len(trim(map_entry%key))
258  type is (write_field_collective_values_type)
259  prepare_to_serialise_writer_field_type=prepare_to_serialise_writer_field_type+&
260  prepare_to_serialise_collective_values_type(generic)+&
261  (kind(prepare_to_serialise_writer_field_type)*3)+len(trim(map_entry%key))
262  class default
263  call log_log(log_error, "Unknown data type in writer field type")
264  end select
265  end if
266  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_to_serialise_writer_type()

integer(kind=8) function, public writer_types_mod::prepare_to_serialise_writer_type ( type(writer_type), intent(inout)  writer_to_serialise)

Prepares to serialise the writer type by issuing locks and determining the size of serialised bytes needed.

Parameters
writer_to_serialiseWriter type to serialise
Returns
The number of bytes needed to store the serialised state

Definition at line 119 of file writer_types.F90.

119  type(writer_type), intent(inout) :: writer_to_serialise
120 
121  integer :: i
122 
123  prepare_to_serialise_writer_type=(kind(writer_to_serialise%write_timestep) * 6) + &
124  (kind(writer_to_serialise%previous_write_time) * 4) + &
125  c_size(writer_to_serialise%pending_writes) * (kind(writer_to_serialise%write_timestep) + &
126  kind(writer_to_serialise%previous_write_time))
127 
128  call check_thread_status(forthread_mutex_lock(writer_to_serialise%num_fields_to_write_mutex))
129 
130  if (size(writer_to_serialise%contents) .gt. 0) then
131  do i=1, size(writer_to_serialise%contents)
132  prepare_to_serialise_writer_type=prepare_to_serialise_writer_type+&
133  prepare_to_serialise_writer_field_type(writer_to_serialise%contents(i))+kind(prepare_to_serialise_writer_type)
134  end do
135  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialise_collective_values_type()

subroutine writer_types_mod::serialise_collective_values_type ( type(write_field_collective_values_type), intent(inout)  collective_values_to_serialise,
character, dimension(:), intent(inout), allocatable  byte_data,
integer, intent(inout)  current_data_point 
)
private

Serialises collective values. This releases any locks issued during preparation.

Parameters
collective_values_to_serialiseThe collective values to serialise
byte_dataThe byte data which will be packed with the serialised byte code
current_data_pointThe current write point in the byte data, is updated during call so represents next point on return

Definition at line 392 of file writer_types.F90.

392  type(write_field_collective_values_type), intent(inout) :: collective_values_to_serialise
393  character, dimension(:), allocatable, intent(inout) :: byte_data
394  integer, intent(inout) :: current_data_point
395 
396  integer :: prev_pt
397  class(*), pointer :: generic
398  type(mapentry_type) :: map_entry
399  type(iterator_type) :: iterator
400 
401  current_data_point=pack_scalar_field(byte_data, current_data_point, c_size(collective_values_to_serialise%monc_values))
402 
403  if (c_size(collective_values_to_serialise%monc_values) .gt. 0) then
404  iterator=c_get_iterator(collective_values_to_serialise%monc_values)
405  do while (c_has_next(iterator))
406  map_entry=c_next_mapentry(iterator)
407  generic=>c_get_generic(map_entry)
408  if (associated(generic)) then
409  select type(generic)
410  type is (data_values_type)
411  current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
412  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
413  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
414  current_data_point=current_data_point+len(trim(map_entry%key))
415 
416  prev_pt=current_data_point
417  current_data_point=current_data_point+kind(current_data_point)
418  call serialise_data_values_type(generic, byte_data, current_data_point)
419 
420  prev_pt=pack_scalar_field(byte_data, prev_pt, (current_data_point-kind(current_data_point))-prev_pt)
421  class default
422  call log_log(log_error, "Unknown data type in collective values type")
423  end select
424  end if
425  end do
426  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialise_data_values_type()

subroutine, public writer_types_mod::serialise_data_values_type ( type(data_values_type), intent(inout)  data_values_to_serialise,
character, dimension(:), intent(inout), allocatable  byte_data,
integer, intent(inout)  current_data_point 
)

Serialises some data values to store or transmit. This releases any locks issued during preparation.

Parameters
data_values_to_serialiseThe data values to serialise
byte_dataThe byte data which will be packaged with the serialised byte code
current_data_pointThe current write point in the byte data, is updated during call so represents next point on return

Definition at line 486 of file writer_types.F90.

486  type(data_values_type), intent(inout) :: data_values_to_serialise
487  character, dimension(:), allocatable, intent(inout) :: byte_data
488  integer, intent(inout) :: current_data_point
489 
490  integer :: values_size, prev_pt
491  character, dimension(:), allocatable :: dvt_byte_data, temp
492 
493  if (allocated(data_values_to_serialise%values)) then
494  values_size=kind(data_values_to_serialise%values)*size(data_values_to_serialise%values)
495  else if (allocated(data_values_to_serialise%string_values)) then
496  values_size=size(data_values_to_serialise%string_values) * string_length
497  else
498  values_size=0
499  end if
500 
501  current_data_point=pack_scalar_field(byte_data, current_data_point, data_values_to_serialise%data_type)
502  current_data_point=pack_scalar_field(byte_data, current_data_point, data_values_to_serialise%dimensions)
503  current_data_point=pack_array_field(byte_data, current_data_point, data_values_to_serialise%dim_sizes)
504  if (allocated(data_values_to_serialise%values)) then
505  current_data_point=pack_scalar_field(byte_data, current_data_point, 1)
506  current_data_point=pack_scalar_field(byte_data, current_data_point, size(data_values_to_serialise%values))
507  current_data_point=pack_array_field(byte_data, current_data_point, real_array_1d=data_values_to_serialise%values)
508  else if (allocated(data_values_to_serialise%string_values)) then
509  current_data_point=pack_scalar_field(byte_data, current_data_point, 2)
510  current_data_point=pack_scalar_field(byte_data, current_data_point, &
511  size(data_values_to_serialise%string_values) * string_length)
512  byte_data(current_data_point:current_data_point+(size(data_values_to_serialise%string_values) * string_length)-1) = &
513  transfer(data_values_to_serialise%string_values, &
514  byte_data(current_data_point:current_data_point+(size(data_values_to_serialise%string_values) * string_length)-1))
515  else
516  current_data_point=pack_scalar_field(byte_data, current_data_point, 3)
517  call serialise_string_map(data_values_to_serialise%map_values, byte_data, current_data_point)
518  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialise_string_map()

subroutine writer_types_mod::serialise_string_map ( type(map_type), intent(inout)  map_to_serialise,
character, dimension(:), intent(inout), allocatable  byte_data,
integer, intent(inout)  current_data_point 
)
private

Serialises a string map, where the values are assumed to be strings. This releases any locks issued during preparation.

Parameters
map_to_serialiseThe map which will be serialised
byte_dataThe byte data representation of this map, this is allocated here
current_data_pointThe current write point in the byte data, is updated during call so represents next point on return

Definition at line 583 of file writer_types.F90.

583  type(map_type), intent(inout) :: map_to_serialise
584  character, dimension(:), allocatable, intent(inout) :: byte_data
585  integer, intent(inout) :: current_data_point
586 
587  type(mapentry_type) :: map_entry
588  type(iterator_type) :: iterator
589  character(len=STRING_LENGTH) :: str_value
590 
591  current_data_point=pack_scalar_field(byte_data, current_data_point, c_size(map_to_serialise))
592 
593  iterator=c_get_iterator(map_to_serialise)
594  do while (c_has_next(iterator))
595  map_entry=c_next_mapentry(iterator)
596  str_value=c_get_string(map_entry)
597 
598  current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
599  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
600  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
601  current_data_point=current_data_point+len(trim(map_entry%key))
602  current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(str_value)))
603  if (len(trim(str_value)) .gt. 0) then
604  byte_data(current_data_point:current_data_point+len(trim(str_value))-1) = transfer(trim(str_value), &
605  byte_data(current_data_point:current_data_point+len(trim(str_value))-1))
606  end if
607  current_data_point=current_data_point+len(trim(str_value))
608  end do
Here is the caller graph for this function:

◆ serialise_writer_field_type()

subroutine writer_types_mod::serialise_writer_field_type ( type(writer_field_type), intent(inout)  writer_field_to_serialise,
character, dimension(:), intent(inout), allocatable  byte_data,
integer, intent(inout)  current_data_point 
)
private

Serialises a specific writer field type for storage or transmission. This releases any locks issued during preparation.

Parameters
writer_field_to_serialiseThe writer field type to serialise
byte_dataThe byte data to pack with the serialised data
current_data_pointThe current write point in the byte data, is updated during call so represents next point on return

Definition at line 274 of file writer_types.F90.

274  type(writer_field_type), intent(inout) :: writer_field_to_serialise
275  character, dimension(:), allocatable, intent(inout) :: byte_data
276  integer, intent(inout) :: current_data_point
277 
278  integer :: prev_pt, byte_size, entry_type
279  class(*), pointer :: generic
280  type(mapentry_type) :: map_entry
281  type(iterator_type) :: iterator
282 
283  current_data_point=pack_scalar_field(byte_data, current_data_point, writer_field_to_serialise%latest_timestep_values)
284  current_data_point=pack_scalar_field(byte_data, current_data_point, &
285  single_real_value=writer_field_to_serialise%previous_write_time)
286  current_data_point=pack_scalar_field(byte_data, current_data_point, &
287  single_real_value=writer_field_to_serialise%previous_tracked_write_point)
288 
289  current_data_point=pack_scalar_field(byte_data, current_data_point, c_size(writer_field_to_serialise%values_to_write))
290 
291  iterator=c_get_iterator(writer_field_to_serialise%values_to_write)
292  do while (c_has_next(iterator))
293  map_entry=c_next_mapentry(iterator)
294  generic=>c_get_generic(map_entry)
295  if (associated(generic)) then
296  current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
297  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
298  byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
299  current_data_point=current_data_point+len(trim(map_entry%key))
300  prev_pt=current_data_point
301  current_data_point=current_data_point+(kind(current_data_point)*2)
302  select type(generic)
303  type is (data_values_type)
304  call serialise_data_values_type(generic, byte_data, current_data_point)
305  entry_type=1
306  type is (write_field_collective_values_type)
307  call serialise_collective_values_type(generic, byte_data, current_data_point)
308  entry_type=2
309  class default
310  call log_log(log_error, "Unknown data type in writer field type")
311  end select
312  prev_pt=pack_scalar_field(byte_data, prev_pt, (current_data_point-(kind(current_data_point)*2)) - prev_pt)
313  prev_pt=pack_scalar_field(byte_data, prev_pt, entry_type)
314  end if
315  end do
316  call check_thread_status(forthread_mutex_unlock(writer_field_to_serialise%values_mutex))
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialise_writer_type()

subroutine, public writer_types_mod::serialise_writer_type ( type(writer_type), intent(inout)  writer_to_serialise,
character, dimension(:), intent(inout), allocatable  byte_data 
)

Serialises a specific writer type into byte data (for storage or transmission.) Releases any locks issued during preparation.

Parameters
writer_to_serialiseThe writer type to serialise
byte_dataThe byte data which will be packed with the serialised data

Definition at line 142 of file writer_types.F90.

142  type(writer_type), intent(inout) :: writer_to_serialise
143  character, dimension(:), allocatable, intent(inout) :: byte_data
144 
145  integer :: prev_pt, i, current_data_point
146 
147  type(iterator_type) :: iterator
148  class(*), pointer :: generic
149 
150  current_data_point=1
151 
152  current_data_point=pack_scalar_field(byte_data, current_data_point, writer_to_serialise%write_timestep)
153  current_data_point=pack_scalar_field(byte_data, current_data_point, writer_to_serialise%num_fields_to_write)
154  call check_thread_status(forthread_mutex_unlock(writer_to_serialise%num_fields_to_write_mutex))
155  current_data_point=pack_scalar_field(byte_data, current_data_point, writer_to_serialise%previous_write_timestep)
156  current_data_point=pack_scalar_field(byte_data, current_data_point, writer_to_serialise%latest_pending_write_timestep)
157  current_data_point=pack_scalar_field(byte_data, current_data_point, single_real_value=writer_to_serialise%previous_write_time)
158  current_data_point=pack_scalar_field(byte_data, current_data_point, &
159  single_real_value=writer_to_serialise%latest_pending_write_time)
160  current_data_point=pack_scalar_field(byte_data, current_data_point, single_real_value=writer_to_serialise%write_time)
161  current_data_point=pack_scalar_field(byte_data, current_data_point, single_real_value=writer_to_serialise%defined_write_time)
162  current_data_point=pack_scalar_field(byte_data, current_data_point, c_size(writer_to_serialise%pending_writes))
163  current_data_point=pack_scalar_field(byte_data, current_data_point, size(writer_to_serialise%contents))
164 
165  if (c_size(writer_to_serialise%pending_writes) .gt. 0) then
166  iterator=c_get_iterator(writer_to_serialise%pending_writes)
167  do while (c_has_next(iterator))
168  generic=>c_next_generic(iterator)
169  select type(generic)
170  type is (pending_write_type)
171  current_data_point=pack_scalar_field(byte_data, current_data_point, generic%timestep)
172  current_data_point=pack_scalar_field(byte_data, current_data_point, single_real_value=generic%write_time)
173  end select
174  end do
175  end if
176 
177  if (size(writer_to_serialise%contents) .gt. 0) then
178  do i=1, size(writer_to_serialise%contents)
179  prev_pt=current_data_point
180  current_data_point=current_data_point+kind(current_data_point)
181  call serialise_writer_field_type(writer_to_serialise%contents(i), byte_data, current_data_point)
182  prev_pt=pack_scalar_field(byte_data, prev_pt, (current_data_point-prev_pt)-kind(current_data_point))
183  end do
184  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unserialise_collective_values_type()

type(write_field_collective_values_type) function, pointer writer_types_mod::unserialise_collective_values_type ( character, dimension(:), intent(in)  byte_data)
private

Unserialsies collective values contained in some data.

Parameters
byte_dataThe byte data to unserialise
Returns
The collective values type which represents this byte data

Definition at line 433 of file writer_types.F90.

433  character, dimension(:), intent(in) :: byte_data
434  type(write_field_collective_values_type), pointer :: unserialise_collective_values_type
435 
436  integer :: current_data_point, number_entries, i, key_size, byte_size
437  character(len=STRING_LENGTH) :: value_key
438  class(*), pointer :: generic
439 
440  allocate(unserialise_collective_values_type)
441 
442  current_data_point=1
443  number_entries=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
444 
445  if (number_entries .gt. 0) then
446  do i=1, number_entries
447  key_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
448  value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
449  value_key(key_size+1:)=" "
450  current_data_point=current_data_point+key_size
451  byte_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
452  generic=>unserialise_data_values_type(byte_data(current_data_point:current_data_point+byte_size-1))
453  call c_put_generic(unserialise_collective_values_type%monc_values, value_key, generic, .false.)
454  current_data_point=current_data_point+byte_size
455  end do
456  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unserialise_data_values_type()

type(data_values_type) function, pointer, public writer_types_mod::unserialise_data_values_type ( character, dimension(:), intent(in)  byte_data)

Unserialises some byte data into data values.

Parameters
byte_dataThe byte data which is read from
Returns
The unserialised and allocated data values

Definition at line 525 of file writer_types.F90.

525  character, dimension(:), intent(in) :: byte_data
526  type(data_values_type), pointer :: unserialise_data_values_type
527 
528  integer :: current_data_point, i, values_size, byte_size, values_type
529 
530  allocate(unserialise_data_values_type)
531  current_data_point=1
532  unserialise_data_values_type%data_type=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
533  unserialise_data_values_type%dimensions=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
534  do i=1, 4
535  unserialise_data_values_type%dim_sizes(i)=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
536  end do
537  values_type=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
538  if (values_type == 1) then
539  values_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
540  allocate(unserialise_data_values_type%values(values_size))
541  byte_size=values_size*kind(unserialise_data_values_type%values)
542  unserialise_data_values_type%values=transfer(byte_data(current_data_point:current_data_point+byte_size-1), &
543  unserialise_data_values_type%values)
544  else if (values_type == 2) then
545  values_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
546  allocate(unserialise_data_values_type%string_values(values_size))
547  byte_size=values_size*string_length
548  unserialise_data_values_type%string_values=transfer(byte_data(current_data_point:current_data_point+byte_size-1), &
549  unserialise_data_values_type%string_values)
550  else if (values_type == 3) then
551  byte_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
552  unserialise_data_values_type%map_values=unserialise_string_map(byte_data(current_data_point:current_data_point+byte_size-1))
553  else
554  call log_log(log_error, "Unknown values type in data values serialisation bytes")
555  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unserialise_string_map()

type(map_type) function, pointer writer_types_mod::unserialise_string_map ( character, dimension(:), intent(in)  byte_data)
private

Inflates some byte data into a string map.

Parameters
byte_dataThe byte data to unserialise
Returns
The inflated map representation

Definition at line 615 of file writer_types.F90.

615  character, dimension(:), intent(in) :: byte_data
616  type(map_type), pointer :: unserialise_string_map
617 
618  integer :: current_data_point, number_entries, i, key_size, value_size
619  character(len=STRING_LENGTH) :: value_key, value_value
620 
621  allocate(unserialise_string_map)
622  current_data_point=1
623  number_entries=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
624 
625  if (number_entries .gt. 0) then
626  do i=1, number_entries
627  key_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
628  value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
629  value_key(key_size+1:)=" "
630  current_data_point=current_data_point+key_size
631  value_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
632  if (value_size .gt. 0) then
633  value_value=transfer(byte_data(current_data_point:current_data_point+value_size-1), value_value)
634  else
635  value_value=""
636  end if
637  current_data_point=current_data_point+value_size
638  call c_put_string(unserialise_string_map, value_key, value_value)
639  end do
640  end if
Here is the caller graph for this function:

◆ unserialise_writer_field_type()

subroutine writer_types_mod::unserialise_writer_field_type ( type(writer_field_type), intent(inout)  writer_field_to_unserialise,
character, dimension(:), intent(in)  byte_data 
)
private

Unserialises byte data into a writer field type.

Parameters
writer_field_to_unserialiseThe writer field to fill in
byte_dataThe raw byte data to read from

Definition at line 323 of file writer_types.F90.

323  type(writer_field_type), intent(inout) :: writer_field_to_unserialise
324  character, dimension(:), intent(in) :: byte_data
325 
326  integer :: current_data_point, number_values_stored, i, byte_size, key_size, entry_type
327  character(len=STRING_LENGTH) :: value_key
328  class(*), pointer :: generic
329 
330  current_data_point=1
331  writer_field_to_unserialise%latest_timestep_values=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
332  writer_field_to_unserialise%previous_write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
333  writer_field_to_unserialise%previous_tracked_write_point=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
334  number_values_stored=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
335 
336  if (number_values_stored .gt. 0) then
337  do i=1, number_values_stored
338  key_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
339  value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
340  value_key(key_size+1:)=" "
341  current_data_point=current_data_point+key_size
342  byte_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
343  entry_type=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
344  if (entry_type == 1) then
345  generic=>unserialise_data_values_type(byte_data(current_data_point:current_data_point+byte_size-1))
346  else if (entry_type == 2) then
347  generic=>unserialise_collective_values_type(byte_data(current_data_point:current_data_point+byte_size-1))
348  else
349  call log_log(log_error, "Unknown entry type in writer field type serialisation bytes")
350  end if
351  call c_put_generic(writer_field_to_unserialise%values_to_write, value_key, generic, .false.)
352  current_data_point=current_data_point+byte_size
353  end do
354  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unserialise_writer_type()

subroutine, public writer_types_mod::unserialise_writer_type ( type(writer_type), intent(inout)  writer_to_unserialise,
character, dimension(:), intent(in)  byte_data 
)

Unserialises some byte data into the writer in order to recreate the state of the writer.

Parameters
writer_to_unserialiseThe writer to unserialise and fill in
byte_dataThe raw byte data to read from

Definition at line 191 of file writer_types.F90.

191  type(writer_type), intent(inout) :: writer_to_unserialise
192  character, dimension(:), intent(in) :: byte_data
193 
194  integer :: current_data_point, byte_size, expected_pending_writes, expected_contents, i
195  type(pending_write_type), pointer :: pwt
196  class(*), pointer :: generic
197 
198  current_data_point=1
199  writer_to_unserialise%write_timestep=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
200  writer_to_unserialise%num_fields_to_write=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
201  writer_to_unserialise%previous_write_timestep=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
202  writer_to_unserialise%latest_pending_write_timestep=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
203  writer_to_unserialise%previous_write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
204  writer_to_unserialise%latest_pending_write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
205  writer_to_unserialise%write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
206  writer_to_unserialise%defined_write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
207  expected_pending_writes=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
208  expected_contents=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
209 
210  if (expected_contents .ne. size(writer_to_unserialise%contents)) then
211  call log_log(log_error, "Expected number of writer entry fields in the checkpoint does not match the configured number")
212  end if
213 
214  if (expected_pending_writes .gt. 0) then
215  do i=1, expected_pending_writes
216  allocate(pwt)
217  pwt%timestep=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
218  pwt%write_time=unpack_scalar_real_from_bytedata(byte_data, current_data_point)
219  generic=>pwt
220  call c_push_generic(writer_to_unserialise%pending_writes, generic, .false.)
221  end do
222  end if
223 
224  if (expected_contents .gt. 0) then
225  do i=1, expected_contents
226  byte_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
227  call unserialise_writer_field_type(writer_to_unserialise%contents(i), &
228  byte_data(current_data_point:current_data_point+byte_size-1))
229  current_data_point=current_data_point+byte_size
230  end do
231  end if
Here is the call graph for this function:
Here is the caller graph for this function: