MONC
inter-io-specifics.F90
Go to the documentation of this file.
1 
5  use configuration_parser_mod, only : data_size_stride, handle_recv_data_from_io_server, io_configuration_type, &
11  implicit none
12 
13 #ifndef TEST_MODE
14  private
15 #endif
16 
17  abstract interface
18  subroutine handle_completion(io_configuration, values, field_name, timestep)
20  type(io_configuration_type), intent(inout) :: io_configuration
21  real(DEFAULT_PRECISION), dimension(:) :: values
22  character(len=STRING_LENGTH) :: field_name
23  integer :: timestep
24  end subroutine handle_completion
25  end interface
26 
27  integer :: starting_tag=20
28 
31 contains
32 
38  subroutine register_inter_io_communication(io_configuration, message_tag, handling_procedure, name)
39  type(io_configuration_type), intent(inout) :: io_configuration
40  integer, intent(in) :: message_tag
41  procedure(handle_recv_data_from_io_server) :: handling_procedure
42  character(len=*), intent(in) :: name
43 
44  integer :: new_index
45 
46  io_configuration%number_inter_io_communications=io_configuration%number_inter_io_communications+1
47 
48  if (io_configuration%number_inter_io_communications .gt. size(io_configuration%inter_io_communications)) then
49  call extend_inter_io_comm_array(io_configuration)
50  end if
51 
52  new_index=io_configuration%number_inter_io_communications
53  io_configuration%inter_io_communications(new_index)%message_tag=message_tag+starting_tag
54  io_configuration%inter_io_communications(new_index)%handling_procedure=>handling_procedure
55  io_configuration%inter_io_communications(new_index)%name=name
56  end subroutine register_inter_io_communication
57 
62  integer function find_inter_io_from_name(io_configuration, name)
63  type(io_configuration_type), intent(inout) :: io_configuration
64  character(len=*), intent(in) :: name
65 
66  integer :: i
67 
68  do i=1, io_configuration%number_inter_io_communications
69  if (io_configuration%inter_io_communications(i)%name .eq. name) then
71  return
72  end if
73  end do
75  end function find_inter_io_from_name
76 
83  function package_inter_io_communication_message(field_name, timestep, field_values, other_int)
84  character(len=STRING_LENGTH), intent(in) :: field_name
85  integer, intent(in) :: timestep
86  integer, intent(in), optional :: other_int
87  real(kind=DEFAULT_PRECISION), dimension(:), intent(in) :: field_values
88  character, dimension(:), allocatable :: package_inter_io_communication_message
89 
90  integer :: current_location
91 
92  allocate(package_inter_io_communication_message(string_length+8+(8*size(field_values))))
93 
94  current_location=pack_scalar_field(package_inter_io_communication_message, 1, string_value=field_name)
95  current_location=pack_scalar_field(package_inter_io_communication_message, current_location, int_value=timestep)
96  if (present(other_int)) then
97  current_location=pack_scalar_field(package_inter_io_communication_message, current_location, int_value=other_int)
98  end if
99  current_location=pack_array_field(package_inter_io_communication_message, current_location, real_array_1d=field_values)
101 
109  subroutine unpackage_inter_io_communication_message(data_buffer, field_name, timestep, field_values, other_int)
110  character, dimension(:), intent(in) :: data_buffer
111  character(len=STRING_LENGTH), intent(out) :: field_name
112  integer, intent(out) :: timestep
113  integer, intent(out), optional :: other_int
114  real(kind=DEFAULT_PRECISION), dimension(:), allocatable, intent(out) :: field_values
115 
116  integer :: values_entries
117 
118  values_entries=(size(data_buffer) - (string_length+8))/8
119 
120  allocate(field_values(values_entries))
121  field_name=transfer(data_buffer(1:string_length), field_name)
122  timestep=transfer(data_buffer(string_length+1:string_length+4), timestep)
123  if (present(other_int)) other_int=transfer(data_buffer(string_length+5:string_length+8), other_int)
124  field_values=transfer(data_buffer(string_length+9:), field_values)
126 end module inter_io_specifics_mod
integer function forthread_rwlock_init(rwlock_id, attr_id)
Definition: forthread.F90:504
character function, dimension(:), allocatable, public package_inter_io_communication_message(field_name, timestep, field_values, other_int)
Packages up fields into an io binary message (allocated here) which is used for sending.
integer, parameter, public data_size_stride
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17
integer function forthread_rwlock_rdlock(lock_id)
Definition: forthread.F90:514
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
integer function forthread_mutex_init(mutex_id, attr_id)
Definition: forthread.F90:274
integer function forthread_rwlock_wrlock(lock_id)
Definition: forthread.F90:532
This defines some constants and procedures that are useful to the IO server and clients that call it...
Definition: ioclient.F90:3
This is a thread pool and the single management "main" thread will spawn out free threads in the pool...
Definition: threadpool.F90:5
subroutine, public check_thread_status(ierr)
Checks the error status of any thread operation and reports an error if it failed.
Definition: threadpool.F90:229
subroutine, public extend_inter_io_comm_array(io_configuration)
Extends the array of inter io communications from its current suze to current size+data_stride+curren...
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
subroutine, public unpackage_inter_io_communication_message(data_buffer, field_name, timestep, field_values, other_int)
Unpackages some binary data into its individual fields. The field values are allocated here and the s...
Inter IO server communication specific functionality. This manages all of the communication that migh...
integer function forthread_rwlock_destroy(rwlock_id)
Definition: forthread.F90:495
integer function, public find_inter_io_from_name(io_configuration, name)
Locates a the index of an inter IO entry from the operator name or returns 0 if none is found...
integer function, public pack_array_field(buffer, start_offset, int_array, real_array_1d, real_array_2d, real_array_3d, real_array_4d)
Packs an array field into the sending buffer.
Definition: ioclient.F90:273
integer function forthread_rwlock_unlock(lock_id)
Definition: forthread.F90:550
subroutine, public register_inter_io_communication(io_configuration, message_tag, handling_procedure, name)
Registers an inter IO communication operation.
Parses the XML configuration file to produce the io configuration description which contains the data...
integer function, public pack_scalar_field(buffer, start_offset, int_value, real_value, single_real_value, double_real_value, string_value, logical_value)
Packs the data of a scalar field into a buffer.
Definition: ioclient.F90:312