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
forthread_mod::forthread_mutex_init
integer function forthread_mutex_init(mutex_id, attr_id)
Definition: forthread.F90:274
forthread_mod
Definition: forthread.F90:1
inter_io_specifics_mod
Inter IO server communication specific functionality. This manages all of the communication that migh...
Definition: inter-io-specifics.F90:3
io_server_client_mod::pack_array_field
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
forthread_mod::forthread_rwlock_destroy
integer function forthread_rwlock_destroy(rwlock_id)
Definition: forthread.F90:495
inter_io_specifics_mod::package_inter_io_communication_message
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.
Definition: inter-io-specifics.F90:84
configuration_parser_mod::data_size_stride
integer, parameter, public data_size_stride
Definition: configurationparser.F90:26
configuration_parser_mod::extend_inter_io_comm_array
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...
Definition: configurationparser.F90:960
configuration_parser_mod::io_configuration_data_definition_type
Configuration of a specific data definition.
Definition: configurationparser.F90:58
io_server_client_mod
This defines some constants and procedures that are useful to the IO server and clients that call it....
Definition: ioclient.F90:3
threadpool_mod
This is a thread pool and the single management "main" thread will spawn out free threads in the pool...
Definition: threadpool.F90:5
threadpool_mod::check_thread_status
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
forthread_mod::forthread_rwlock_init
integer function forthread_rwlock_init(rwlock_id, attr_id)
Definition: forthread.F90:504
configuration_parser_mod::io_configuration_type
Overall IO configuration.
Definition: configurationparser.F90:104
inter_io_specifics_mod::register_inter_io_communication
subroutine, public register_inter_io_communication(io_configuration, message_tag, handling_procedure, name)
Registers an inter IO communication operation.
Definition: inter-io-specifics.F90:39
io_server_client_mod::data_sizing_description_type
Definition: ioclient.F90:16
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
inter_io_specifics_mod::find_inter_io_from_name
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.
Definition: inter-io-specifics.F90:63
datadefn_mod::string_length
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
inter_io_specifics_mod::unpackage_inter_io_communication_message
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...
Definition: inter-io-specifics.F90:110
forthread_mod::forthread_rwlock_wrlock
integer function forthread_rwlock_wrlock(lock_id)
Definition: forthread.F90:532
forthread_mod::forthread_rwlock_rdlock
integer function forthread_rwlock_rdlock(lock_id)
Definition: forthread.F90:514
configuration_parser_mod
Parses the XML configuration file to produce the io configuration description which contains the data...
Definition: configurationparser.F90:3
forthread_mod::forthread_rwlock_unlock
integer function forthread_rwlock_unlock(lock_id)
Definition: forthread.F90:550
inter_io_specifics_mod::starting_tag
integer starting_tag
Definition: inter-io-specifics.F90:27
io_server_client_mod::pack_scalar_field
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
inter_io_specifics_mod::handle_completion
Definition: inter-io-specifics.F90:18
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17
configuration_parser_mod::io_configuration_inter_communication_description
Definition: configurationparser.F90:66