25 use mpi,
only : mpi_comm_world, mpi_int, mpi_byte, mpi_request_null, mpi_statuses_ignore, mpi_status_ignore, mpi_status_size
38 integer :: number_dimensions, dimensions(4)
42 character(len=STRING_LENGTH) :: name
43 integer :: field_type, data_type
44 logical ::
optional, enabled
48 character(len=STRING_LENGTH) :: name
49 logical :: send_on_terminate
50 integer :: number_of_data_fields, frequency, mpi_datatype
52 integer :: dump_requests(2)
53 character,
dimension(:),
allocatable :: send_buffer
75 type(model_state_type),
target,
intent(inout) :: current_state
77 integer :: mpi_type_data_sizing_description, mpi_type_definition_description, mpi_type_field_description, ierr
79 if (.not. options_get_logical(current_state%options_database,
"enable_io_server"))
then
81 call log_master_log(log_warn,
"Enabled IO bridge but missing IO server compilation, therefore ignoring IO bridge component")
90 mpi_type_data_sizing_description=build_mpi_type_data_sizing_description()
91 mpi_type_definition_description=build_mpi_type_definition_description()
92 mpi_type_field_description=build_mpi_type_field_description()
97 call mpi_type_free(mpi_type_data_sizing_description, ierr)
98 call mpi_type_free(mpi_type_definition_description, ierr)
99 call mpi_type_free(mpi_type_field_description, ierr)
107 type(model_state_type),
target,
intent(inout) :: current_state
126 type(model_state_type),
target,
intent(inout) :: current_state
127 integer,
intent(in) :: data_index
129 integer :: command_to_send, ierr
131 if (
data_definitions(data_index)%dump_requests(1) .ne. mpi_request_null .or. &
134 call mpi_waitall(2,
data_definitions(data_index)%dump_requests, mpi_statuses_ignore, ierr)
140 command_to_send=data_command_start+data_index
141 call mpi_issend(command_to_send, 1, mpi_int, current_state%parallel%corresponding_io_server_process, &
142 command_tag, mpi_comm_world,
data_definitions(data_index)%dump_requests(1), ierr)
144 current_state%parallel%corresponding_io_server_process, data_tag+data_index, mpi_comm_world, &
151 type(model_state_type),
target,
intent(inout) :: current_state
164 call mpi_waitall(2,
data_definitions(i)%dump_requests, mpi_statuses_ignore, ierr)
169 call mpi_send(deregister_command, 1, mpi_int, current_state%parallel%corresponding_io_server_process, &
170 command_tag, mpi_comm_world, ierr)
175 integer :: i, dump_send_buffer_size
190 integer :: type_extents(5), type_counts, i, j, tempsize, field_start, data_type, field_array_sizes, &
191 temp_size, prev_data_type, old_types(20), offsets(20), block_counts(20), ierr, field_ignores
192 logical :: field_found
195 type_extents=populate_mpi_type_extents()
202 do i=1, specific_data_definition%number_of_data_fields
203 if (data_type == 0)
then
204 prev_data_type=data_type
205 data_type=specific_data_definition%fields(i)%data_type
207 if (data_type .ne. specific_data_definition%fields(i)%data_type)
then
209 call append_mpi_datatype(field_start, i-1-field_ignores, field_array_sizes, data_type, &
210 type_extents, prev_data_type, type_counts+1, old_types, offsets, block_counts)
214 prev_data_type=data_type
215 data_type=specific_data_definition%fields(i)%data_type
216 type_counts=type_counts+1
220 if (specific_data_definition%fields(i)%field_type .eq. array_field_type .or. &
221 specific_data_definition%fields(i)%field_type .eq. map_field_type)
then
224 specific_data_definition%fields(i)%enabled=field_found
225 if (.not. field_found .or. field_size_info%number_dimensions == 0)
then
227 if (.not. specific_data_definition%fields(i)%optional)
then
228 call log_log(log_error,
"Non optional field `"//trim(specific_data_definition%fields(i)%name)//&
229 "' omitted from MONC IO server registration")
231 field_ignores=field_ignores+1
235 do j=1, field_size_info%number_dimensions
236 temp_size=temp_size*field_size_info%dimensions(j)
238 if (specific_data_definition%fields(i)%field_type .eq. map_field_type)
then
239 field_array_sizes=(field_array_sizes+temp_size*string_length*2)-1
241 field_array_sizes=(field_array_sizes+temp_size)-1
245 if (specific_data_definition%fields(i)%optional)
then
247 specific_data_definition%fields(i)%enabled=field_found
248 if (.not. field_found) field_ignores=field_ignores+1
252 if (field_start .le. i-1)
then
254 call append_mpi_datatype(field_start, i-1, field_array_sizes, data_type, &
255 type_extents, prev_data_type, type_counts+1, old_types, offsets, block_counts)
256 type_counts=type_counts+1
259 call mpi_type_struct(type_counts, block_counts, offsets, old_types, specific_data_definition%mpi_datatype, ierr)
260 call mpi_type_commit(specific_data_definition%mpi_datatype, ierr)
261 call mpi_type_size(specific_data_definition%mpi_datatype, tempsize, ierr)
268 type(model_state_type),
target,
intent(inout) :: current_state
270 type(list_type) :: published_field_descriptors
274 published_field_descriptors=get_all_component_published_fields()
275 do i=1, c_size(published_field_descriptors)
283 type(model_state_type),
target,
intent(inout) :: current_state
284 character(len=*),
intent(in) :: field_name
286 class(*),
pointer :: generic_data
288 type(component_field_information_type) :: field_information
289 type(component_field_information_type),
pointer :: field_information_info_alloc
292 field_information=get_component_field_information(current_state, field_name)
293 if (field_information%enabled)
then
294 allocate(field_information_info_alloc, source=field_information)
295 generic_data=>field_information_info_alloc
298 allocate(field_sizing)
299 field_sizing%number_dimensions=field_information%number_dimensions
300 field_sizing%dimensions=field_information%dimension_sizes
301 generic_data=>field_sizing
309 type(model_state_type),
target,
intent(inout) :: current_state
311 integer :: x_size, y_size, z_size
312 class(*),
pointer :: raw_generic
314 z_size=current_state%local_grid%size(z_index)
315 y_size=current_state%local_grid%size(y_index)
316 x_size=current_state%local_grid%size(x_index)
319 call c_put_generic(
sendable_fields,
"options_database", raw_generic, .false.)
320 if (get_number_active_q_indices() .gt. 0)
then
322 call c_put_generic(
sendable_fields,
"q_indicies", raw_generic, .false.)
325 call c_put_generic(
sendable_fields,
"local_grid_size", raw_generic, .false.)
326 call c_put_generic(
sendable_fields,
"local_grid_start", raw_generic, .false.)
331 call c_put_generic(
sendable_fields,
"x_resolution", raw_generic, .false.)
336 if (
allocated(current_state%global_grid%configuration%vertical%olubar))
then
346 call c_put_generic(
sendable_fields,
"y_resolution", raw_generic, .false.)
351 if (
allocated(current_state%global_grid%configuration%vertical%olvbar))
then
368 if (current_state%number_q_fields .gt. 0)
then
372 if (
allocated(current_state%global_grid%configuration%vertical%olqbar))
then
378 if (current_state%th%active)
then
382 if (
allocated(current_state%global_grid%configuration%vertical%olthbar))
then
388 if (current_state%p%active)
then
393 if (is_component_enabled(current_state%options_database,
"socrates_couple"))
then
399 if (is_component_enabled(current_state%options_database,
"pdf_analysis"))
then
400 if (
allocated(current_state%global_grid%configuration%vertical%w_up))
then
405 if (
allocated(current_state%global_grid%configuration%vertical%w_dwn))
then
421 integer,
intent(in),
optional :: dim1, dim2, dim3, dim4
425 integer :: number_dimensions
430 if (
present(dim1))
then
431 field%dimensions(1)=dim1
432 number_dimensions=number_dimensions+1
434 if (
present(dim2))
then
435 field%dimensions(2)=dim2
436 number_dimensions=number_dimensions+1
438 if (
present(dim3))
then
439 field%dimensions(3)=dim3
440 number_dimensions=number_dimensions+1
442 if (
present(dim4))
then
443 field%dimensions(4)=dim4
444 number_dimensions=number_dimensions+1
446 field%number_dimensions=number_dimensions
455 type(model_state_type),
target,
intent(inout) :: current_state
456 integer,
intent(in) :: mpi_type_data_sizing_description
458 type(data_sizing_description_type),
dimension(:),
allocatable :: data_description
459 character,
dimension(:),
allocatable :: buffer
460 integer :: number_unique_fields, buffer_size, request_handles(2), ierr
461 real(kind=default_precision) :: dreal
464 allocate(data_description(number_unique_fields+4))
466 data_description, number_unique_fields)
467 buffer_size=(kind(dreal)*current_state%local_grid%size(z_index))*2 + (string_length * current_state%number_q_fields &
468 + 4*ncond*string_length + 2*ndiag*string_length )
469 allocate(buffer(buffer_size))
471 call mpi_waitall(2, request_handles, mpi_statuses_ignore, ierr)
472 deallocate(data_description)
482 data_description, number_unique_fields)
483 type(model_state_type),
target,
intent(inout) :: current_state
484 integer,
intent(in) :: mpi_type_data_sizing_description, number_unique_fields
485 type(data_sizing_description_type),
dimension(:),
intent(inout) :: data_description
487 integer :: ierr, i, next_index, request_handle
488 character(len=STRING_LENGTH) :: field_name
492 do i=1, number_unique_fields
496 next_index=next_index+1
500 call mpi_isend(data_description, next_index-1, mpi_type_data_sizing_description, &
501 current_state%parallel%corresponding_io_server_process, data_tag, mpi_comm_world, request_handle, ierr)
510 type(model_state_type),
target,
intent(inout) :: current_state
511 character,
dimension(:),
intent(inout) :: buffer
513 character(len=STRING_LENGTH) :: q_field_name, cd_field_name
514 type(q_metadata_type) :: q_meta_data
515 integer :: current_loc, n, ierr, request_handle
518 current_loc=pack_array_field(buffer, current_loc, real_array_1d=current_state%global_grid%configuration%vertical%zn)
519 if (current_state%number_q_fields .gt. 0)
then
520 do n=1, current_state%number_q_fields
521 q_meta_data=get_indices_descriptor(n)
522 if (q_meta_data%l_used)
then
523 q_field_name=q_meta_data%name
525 q_field_name=
"qfield_"//trim(conv_to_string(n))
527 current_loc=pack_scalar_field(buffer, current_loc, string_value=q_field_name)
530 current_loc=pack_array_field(buffer, current_loc, real_array_1d=current_state%global_grid%configuration%vertical%z)
533 if (n .le. ncond)
then
534 cd_field_name = cond_request(n)
535 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
536 cd_field_name = cond_long(n)
537 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
539 cd_field_name = .not.
" "//trim(cond_request(n-ncond))
540 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
541 cd_field_name = .not.
" "//trim(cond_long(n-ncond))
542 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
546 cd_field_name = diag_request(n)
547 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
548 cd_field_name = diag_long(n)
549 current_loc=pack_scalar_field(buffer, current_loc, string_value=cd_field_name)
553 call mpi_isend(buffer, current_loc-1, mpi_byte, current_state%parallel%corresponding_io_server_process, &
554 data_tag, mpi_comm_world, request_handle, ierr)
562 type(model_state_type),
target,
intent(inout) :: current_state
563 type(data_sizing_description_type),
dimension(:),
intent(inout) :: data_description
567 sizing_info%number_dimensions=3
568 sizing_info%dimensions(z_index)=current_state%local_grid%size(z_index)
569 sizing_info%dimensions(y_index)=current_state%local_grid%size(y_index)
570 sizing_info%dimensions(x_index)=current_state%local_grid%size(x_index)
572 sizing_info%dimensions(z_index)=current_state%local_grid%start(z_index)
573 sizing_info%dimensions(y_index)=current_state%local_grid%start(y_index)
574 sizing_info%dimensions(x_index)=current_state%local_grid%start(x_index)
576 sizing_info%dimensions(z_index)=current_state%local_grid%end(z_index)
577 sizing_info%dimensions(y_index)=current_state%local_grid%end(y_index)
578 sizing_info%dimensions(x_index)=current_state%local_grid%end(x_index)
580 sizing_info%number_dimensions=1
581 sizing_info%dimensions(1)=get_number_active_q_indices()
589 character(len=*),
intent(in) :: field_name
590 logical,
intent(out),
optional :: field_found
592 class(*),
pointer :: generic
594 if (
present(field_found)) field_found=.false.
600 if (
present(field_found)) field_found=.true.
608 character(len=*),
intent(in) :: field_name
610 class(*),
pointer :: generic
614 type is (component_field_information_type)
630 integer,
intent(in) :: index
631 character(len=*),
intent(in) :: field_name
633 type(data_sizing_description_type),
dimension(:),
intent(inout) :: data_description
635 data_description(index)%field_name=field_name
636 data_description(index)%dimensions=field_sizing_description%number_dimensions
637 data_description(index)%dim_sizes=field_sizing_description%dimensions
647 type(model_state_type),
target,
intent(inout) :: current_state
648 integer,
intent(in) :: mpi_type_definition_description, mpi_type_field_description
650 type(definition_description_type),
dimension(:),
allocatable :: definition_descriptions
651 type(field_description_type),
dimension(:),
allocatable :: field_descriptions
652 integer :: number_defns, number_fields, status(MPI_STATUS_SIZE), ierr
654 call mpi_send(register_command, 1, mpi_int, current_state%parallel%corresponding_io_server_process, &
655 command_tag, mpi_comm_world, ierr)
657 call mpi_probe(current_state%parallel%corresponding_io_server_process, data_tag, mpi_comm_world, status, ierr)
658 call mpi_get_count(status, mpi_type_definition_description, number_defns, ierr)
659 allocate(definition_descriptions(number_defns))
661 call mpi_recv(definition_descriptions, number_defns, mpi_type_definition_description, &
662 current_state%parallel%corresponding_io_server_process, data_tag, mpi_comm_world, mpi_status_ignore, ierr)
665 allocate(field_descriptions(number_fields))
666 call mpi_recv(field_descriptions, number_fields, mpi_type_field_description, &
667 current_state%parallel%corresponding_io_server_process, data_tag, mpi_comm_world, mpi_status_ignore, ierr)
669 deallocate(definition_descriptions)
677 type(definition_description_type),
dimension(:),
intent(inout) :: definition_descriptions
678 integer,
intent(in) :: number_defns
696 type(definition_description_type),
dimension(:),
intent(inout) :: definition_descriptions
697 type(field_description_type),
dimension(:),
intent(inout) :: field_descriptions
698 integer,
intent(in) :: number_defns, number_fields
700 integer :: i, definition_index, field_index
705 data_definitions(i)%send_on_terminate=definition_descriptions(i)%send_on_terminate
708 allocate(
data_definitions(i)%fields(definition_descriptions(i)%number_fields))
710 do i=1, number_fields
714 data_definitions(definition_index)%fields(field_index)%name=field_descriptions(i)%field_name
715 data_definitions(definition_index)%fields(field_index)%field_type=field_descriptions(i)%field_type
716 data_definitions(definition_index)%fields(field_index)%data_type=field_descriptions(i)%data_type
717 data_definitions(definition_index)%fields(field_index)%optional=field_descriptions(i)%optional
718 if (field_descriptions(i)%optional .or. field_descriptions(i)%field_type == array_field_type .or. &
719 field_descriptions(i)%field_type == map_field_type)
then
722 if (.not. field_descriptions(i)%optional)
data_definitions(definition_index)%fields(field_index)%enabled=.true.
730 character(len=*),
intent(in) :: name
747 type(model_state_type),
target,
intent(inout) :: current_state
750 integer :: current_buffer_point, i
752 current_buffer_point=1
753 do i=1, data_definition%number_of_data_fields
754 if (data_definition%fields(i)%enabled)
then
755 if (data_definition%fields(i)%field_type == array_field_type)
then
757 current_buffer_point)
758 else if (data_definition%fields(i)%field_type == map_field_type)
then
760 current_buffer_point)
761 else if (data_definition%fields(i)%field_type == scalar_field_type)
then
763 current_buffer_point)
776 type(model_state_type),
target,
intent(inout) :: current_state
779 integer,
intent(in) :: current_buffer_point
781 if (field%name .eq.
"timestep")
then
783 int_value=current_state%timestep)
784 else if (field%name .eq.
"terminated")
then
787 else if (field%name .eq.
"z_size")
then
789 int_value=current_state%global_grid%size(z_index))
790 else if (field%name .eq.
"y_size")
then
792 int_value=current_state%global_grid%size(y_index))
793 else if (field%name .eq.
"y_bottom")
then
795 real_value=current_state%global_grid%bottom(y_index))
796 else if (field%name .eq.
"y_top")
then
798 real_value=current_state%global_grid%top(y_index))
799 else if (field%name .eq.
"y_resolution")
then
801 real_value=current_state%global_grid%resolution(y_index))
802 else if (field%name .eq.
"x_size")
then
804 int_value=current_state%global_grid%size(x_index))
805 else if (field%name .eq.
"x_bottom")
then
807 real_value=current_state%global_grid%bottom(x_index))
808 else if (field%name .eq.
"x_top")
then
810 real_value=current_state%global_grid%top(x_index))
811 else if (field%name .eq.
"x_resolution")
then
813 real_value=current_state%global_grid%resolution(x_index))
814 else if (field%name .eq.
"time")
then
817 real_value=current_state%time+current_state%dtm)
818 else if (field%name .eq.
"ugal")
then
820 real_value=current_state%ugal)
821 else if (field%name .eq.
"vgal")
then
823 real_value=current_state%vgal)
824 else if (field%name .eq.
"nqfields")
then
826 int_value=current_state%number_q_fields)
827 else if (field%name .eq.
"dtm")
then
829 real_value=current_state%dtm)
830 else if (field%name .eq.
"dtm_new")
then
832 real_value=current_state%dtm_new)
833 else if (field%name .eq.
"absolute_new_dtm")
then
835 real_value=current_state%absolute_new_dtm)
836 else if (field%name .eq.
"rad_last_time")
then
838 real_value=current_state%rad_last_time)
842 data_definition, field, current_buffer_point)
854 field, current_buffer_point)
855 type(model_state_type),
target,
intent(inout) :: current_state
858 integer,
intent(in) :: current_buffer_point
860 type(component_field_information_type) :: field_descriptor
861 type(component_field_value_type) :: published_value
864 published_value=get_component_field_value(current_state, field%name)
865 if (field_descriptor%data_type == component_double_data_type)
then
867 current_buffer_point, real_value=published_value%scalar_real)
868 else if (field_descriptor%data_type == component_integer_data_type)
then
870 current_buffer_point, int_value=published_value%scalar_int)
881 type(model_state_type),
target,
intent(inout) :: current_state
884 integer,
intent(in) :: current_buffer_point
887 type(q_metadata_type) :: specific_q_data
888 type(hashmap_type) :: q_indicies_map
890 if (field%name .eq.
"options_database")
then
891 pack_map_into_send_buffer=pack_map_field(data_definition%send_buffer, current_buffer_point, current_state%options_database)
892 else if (field%name .eq.
"q_indicies")
then
893 do i=1, get_max_number_q_indices()
894 specific_q_data=get_indices_descriptor(i)
895 if (specific_q_data%l_used)
then
896 call c_put_integer(q_indicies_map, specific_q_data%name, i)
900 call c_free(q_indicies_map)
911 type(model_state_type),
target,
intent(inout) :: current_state
914 integer,
intent(in) :: current_buffer_point
916 if (field%name .eq.
"local_grid_size")
then
918 int_array=current_state%local_grid%size)
919 else if (field%name .eq.
"local_grid_start")
then
921 int_array=current_state%local_grid%start)
922 else if (field%name .eq.
"z")
then
924 real_array_1d=current_state%global_grid%configuration%vertical%z)
925 else if (field%name .eq.
"olubar")
then
927 real_array_1d=current_state%global_grid%configuration%vertical%olubar)
928 else if (field%name .eq.
"olzubar")
then
930 real_array_1d=current_state%global_grid%configuration%vertical%olzubar)
931 else if (field%name .eq.
"olvbar")
then
933 real_array_1d=current_state%global_grid%configuration%vertical%olvbar)
934 else if (field%name .eq.
"olzvbar")
then
936 real_array_1d=current_state%global_grid%configuration%vertical%olzvbar)
937 else if (field%name .eq.
"olthbar")
then
939 real_array_1d=current_state%global_grid%configuration%vertical%olthbar)
940 else if (field%name .eq.
"olzthbar")
then
942 real_array_1d=current_state%global_grid%configuration%vertical%olzthbar)
943 else if (field%name .eq.
"olqbar")
then
945 real_array_2d=current_state%global_grid%configuration%vertical%olqbar)
946 else if (field%name .eq.
"olzqbar")
then
948 real_array_2d=current_state%global_grid%configuration%vertical%olzqbar)
949 else if (field%name .eq.
"thref")
then
951 real_array_1d=current_state%global_grid%configuration%vertical%thref)
952 else if (field%name .eq.
"prefn")
then
954 real_array_1d=current_state%global_grid%configuration%vertical%prefn)
955 else if (field%name .eq.
"rhon")
then
957 real_array_1d=current_state%global_grid%configuration%vertical%rhon)
958 else if (field%name .eq.
"rho")
then
960 real_array_1d=current_state%global_grid%configuration%vertical%rho)
961 else if (field%name .eq.
"u")
then
962 current_state%u%data=current_state%u%data+current_state%ugal
964 current_buffer_point, current_state%local_grid)
965 current_state%u%data=current_state%u%data-current_state%ugal
966 else if (field%name .eq.
"u_nogal")
then
968 current_state%local_grid)
969 else if (field%name .eq.
"zu")
then
971 current_state%local_grid)
972 else if (field%name .eq.
"v")
then
973 current_state%v%data=current_state%v%data+current_state%vgal
975 current_state%local_grid)
976 current_state%v%data=current_state%v%data-current_state%vgal
977 else if (field%name .eq.
"v_nogal")
then
979 current_state%local_grid)
980 else if (field%name .eq.
"zv")
then
982 current_state%local_grid)
983 else if (field%name .eq.
"w")
then
985 current_state%local_grid)
986 else if (field%name .eq.
"zw")
then
988 current_state%local_grid)
989 else if (field%name .eq.
"q")
then
991 current_buffer_point, current_state%local_grid)
992 else if (field%name .eq.
"zq")
then
994 current_buffer_point, current_state%local_grid)
995 else if (field%name .eq.
"th")
then
997 current_state%local_grid)
998 else if (field%name .eq.
"zth")
then
1000 current_state%local_grid)
1001 else if (field%name .eq.
"p")
then
1003 current_state%local_grid)
1004 else if (field%name .eq.
"sth_lw")
then
1006 current_state%sth_lw, current_buffer_point, current_state%local_grid)
1007 else if (field%name .eq.
"sth_sw")
then
1009 current_state%sth_sw, current_buffer_point, current_state%local_grid)
1010 else if (field%name .eq.
"w_up")
then
1012 real_array_1d=current_state%global_grid%configuration%vertical%w_up)
1013 else if (field%name .eq.
"w_dwn")
then
1015 real_array_1d=current_state%global_grid%configuration%vertical%w_dwn)
1025 data_definition, field, current_buffer_point)
1037 field, current_buffer_point)
1038 type(model_state_type),
target,
intent(inout) :: current_state
1041 integer,
intent(in) :: current_buffer_point
1043 type(component_field_information_type) :: field_descriptor
1044 type(component_field_value_type) :: published_value
1047 published_value=get_component_field_value(current_state, field%name)
1048 if (field_descriptor%data_type == component_double_data_type)
then
1049 if (field_descriptor%number_dimensions == 1)
then
1051 current_buffer_point, real_array_1d=published_value%real_1d_array)
1052 deallocate(published_value%real_1d_array)
1053 else if (field_descriptor%number_dimensions == 2)
then
1055 current_buffer_point, real_array_2d=published_value%real_2d_array)
1056 deallocate(published_value%real_2d_array)
1057 else if (field_descriptor%number_dimensions == 3)
then
1059 current_buffer_point, real_array_3d=published_value%real_3d_array)
1060 deallocate(published_value%real_3d_array)
1061 else if (field_descriptor%number_dimensions == 4)
then
1063 current_buffer_point, real_array_4d=published_value%real_4d_array)
1064 deallocate(published_value%real_4d_array)
1076 character,
dimension(:),
allocatable,
intent(inout) :: buffer
1077 type(prognostic_field_type),
intent(inout) :: prognostic
1078 integer,
intent(in) :: start_offset
1079 type(local_grid_type),
intent(inout) :: local_grid
1081 integer :: target_end
1083 target_end=start_offset + (local_grid%size(z_index)*local_grid%size(y_index)*local_grid%size(x_index)*kind(prognostic%data)-1)
1085 buffer(start_offset : target_end) = transfer(prognostic%data(&
1086 local_grid%local_domain_start_index(z_index): local_grid%local_domain_end_index(z_index),&
1087 local_grid%local_domain_start_index(y_index): local_grid%local_domain_end_index(y_index), &
1088 local_grid%local_domain_start_index(x_index): local_grid%local_domain_end_index(x_index)), &
1089 buffer(start_offset : target_end))
1100 integer function pack_q_fields(buffer, q_fields, number_q_fields, start_offset, local_grid)
1101 character,
dimension(:),
allocatable,
intent(inout) :: buffer
1102 type(prognostic_field_type),
dimension(:),
intent(inout) :: q_fields
1103 integer,
intent(in) :: start_offset, number_q_fields
1104 type(local_grid_type),
intent(inout) :: local_grid
1106 integer :: target_end, i, current_starting_index
1108 current_starting_index=start_offset
1110 do i=1,number_q_fields
1111 target_end=current_starting_index + (local_grid%size(z_index)*local_grid%size(y_index)*&
1112 local_grid%size(x_index)*kind(q_fields(i)%data)-1)
1113 buffer(current_starting_index : target_end) = transfer(q_fields(i)%data(&
1114 local_grid%local_domain_start_index(z_index): local_grid%local_domain_end_index(z_index),&
1115 local_grid%local_domain_start_index(y_index): local_grid%local_domain_end_index(y_index), &
1116 local_grid%local_domain_start_index(x_index): local_grid%local_domain_end_index(x_index)), &
1117 buffer(current_starting_index : target_end))
1118 current_starting_index=target_end+1