32 character(len=STRING_LENGTH) :: field_name, field_namespace
33 integer :: timestep, frequency, source
40 integer :: access_mutex, last_timestep_access, frequency
60 logical,
intent(in) :: continuation_run
65 if (continuation_run)
then
80 integer,
intent(in) :: timestep
84 class(*),
pointer :: generic
94 if (generic%last_timestep_access .lt. timestep)
then
111 integer,
intent(in) :: source, data_id
112 character,
dimension(:),
allocatable,
intent(in) :: data_dump
114 integer :: i, num_fields, timestep
115 character(len=STRING_LENGTH) :: field_name, field_namespace
118 logical :: terminated_case
127 io_configuration%data_definitions(data_id)%send_on_terminate
129 terminated_case=.false.
132 num_fields=io_configuration%data_definitions(data_id)%number_of_data_fields
135 field_name=io_configuration%data_definitions(data_id)%fields(i)%name
136 field_namespace=io_configuration%data_definitions(data_id)%fields(i)%namespace
141 io_configuration%data_definitions(data_id)%frequency, source, terminated_case)
147 call log_log(
log_warn,
"Can not run pass MONC fields to writer federator without a time and timestep")
160 integer,
intent(in) :: source, data_id
161 character,
dimension(:),
allocatable,
intent(in) :: data_dump
162 character(len=*),
intent(in) :: field_name, field_namespace
168 integer :: field_data_type, field_field_type, i
169 integer,
dimension(:),
allocatable :: int_values
171 call get_type_of_field(io_configuration%data_definitions(data_id)%fields, field_name, field_namespace, &
172 field_field_type, field_data_type)
173 if (field_data_type == 0)
then
177 if (field_data_type == double_data_type)
then
180 else if (field_data_type == integer_data_type)
then
184 do i=1,
size(int_values)
187 deallocate(int_values)
188 else if (field_data_type == string_data_type)
then
190 if (field_field_type == scalar_field_type)
then
193 else if (field_field_type == map_field_type)
then
205 character(len=*),
intent(in) :: field_name, field_namespace
206 integer,
intent(out) :: field_type, data_type
211 if (fields(i)%name .eq. field_name .and. fields(i)%namespace .eq. field_namespace)
then
212 data_type=fields(i)%data_type
213 field_type=fields(i)%field_type
222 field_values, timestep, time, frequency, source)
224 character(len=*),
intent(in) :: field_name, field_namespace
225 integer,
intent(in) :: timestep, frequency, source
231 allocate(packaged_data%values(
size(field_values)))
232 packaged_data%values=field_values
233 packaged_data%data_type=double_data_type
235 timestep, time, frequency, source)
239 field_values, timestep, time, frequency)
241 character(len=*),
intent(in) :: field_name, field_namespace
242 integer,
intent(in) :: timestep, frequency
247 field_values, timestep, time, frequency, -1)
258 field_values, timestep, time, frequency)
260 character(len=*),
intent(in) :: field_name, field_namespace
261 integer,
intent(in) :: timestep, frequency
266 field_values, timestep, time, frequency, -1)
278 field_values, timestep, time, frequency, source, terminated_case)
280 character(len=*),
intent(in) :: field_name, field_namespace
281 integer,
intent(in) :: timestep, frequency, source
284 logical,
intent(in),
optional :: terminated_case
287 class(*),
pointer :: generic
288 logical :: this_is_termination
290 if (
present(terminated_case))
then
291 this_is_termination=terminated_case
293 this_is_termination=.false.
298 if (timestep == field_ordering%last_timestep_access + frequency .or. this_is_termination)
then
299 if (.not. this_is_termination) field_ordering%last_timestep_access=timestep
301 field_values, timestep, time, source)
302 if (
allocated(field_values%values))
deallocate(field_values%values)
319 integer :: next_timestep
322 do while (.not.
c_is_empty(field_ordering%timestep_to_value))
323 next_timestep=field_ordering%last_timestep_access + field_ordering%frequency
327 field_ordering%last_timestep_access=next_timestep
329 field_ordering_value_at_timestep%field_namespace, field_ordering_value_at_timestep%field_values, &
330 field_ordering_value_at_timestep%timestep, field_ordering_value_at_timestep%time, &
331 field_ordering_value_at_timestep%source)
332 if (
allocated(field_ordering_value_at_timestep%field_values))
then
333 if (
allocated(field_ordering_value_at_timestep%field_values%values)) &
334 deallocate(field_ordering_value_at_timestep%field_values%values)
335 deallocate(field_ordering_value_at_timestep%field_values)
337 deallocate(field_ordering_value_at_timestep)
350 integer,
intent(in) :: timestep
353 class(*),
pointer :: generic
356 if (
associated(generic))
then
376 character(len=*),
intent(in) :: field_name, field_namespace
377 integer,
intent(in) :: timestep, frequency, source
398 character(len=*),
intent(in) :: field_name, field_namespace
399 integer,
intent(in) :: frequency, source
402 class(*),
pointer :: generic
403 character(len=STRING_LENGTH) :: entry_key
405 if (source .gt. -1)
then
406 entry_key=trim(field_name)//
"#"//trim(field_namespace)//
"#"//trim(
conv_to_string(source))
432 character(len=*),
intent(in) :: field_name
433 logical,
intent(in) :: do_lock
436 class(*),
pointer :: generic
441 if (
associated(generic))
then
456 class(*),
pointer :: generic
465 if (
associated(generic))
then
479 character,
dimension(:),
allocatable,
intent(inout) :: byte_data
481 integer :: current_data_point, prev_pt
484 class(*),
pointer :: generic
493 if (
associated(generic))
then
496 current_data_point=
pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
497 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
498 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
499 current_data_point=current_data_point+len(trim(map_entry%key))
501 prev_pt=current_data_point
502 current_data_point=current_data_point+kind(current_data_point)
504 prev_pt=
pack_scalar_field(byte_data, prev_pt, (current_data_point-kind(current_data_point))-prev_pt)
515 character,
dimension(:),
intent(in) :: byte_data
517 integer :: current_data_point, number_of_entries, i, byte_size, key_size
518 character(len=STRING_LENGTH) :: value_key
519 class(*),
pointer :: generic
524 if (number_of_entries .gt. 0)
then
525 do i=1, number_of_entries
527 value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
528 value_key(key_size+1:)=
" "
529 current_data_point=current_data_point+key_size
533 current_data_point=current_data_point+byte_size
546 class(*),
pointer :: generic
552 iterator=
c_get_iterator(specific_field_ordering%timestep_to_value)
556 if (
associated(generic))
then
561 len(trim(map_entry%key))
573 character,
dimension(:),
allocatable,
intent(inout) :: byte_data
574 integer,
intent(inout) :: current_data_point
579 class(*),
pointer :: generic
581 current_data_point=
pack_scalar_field(byte_data, current_data_point, specific_field_ordering%last_timestep_access)
582 current_data_point=
pack_scalar_field(byte_data, current_data_point, specific_field_ordering%frequency)
583 current_data_point=
pack_scalar_field(byte_data, current_data_point,
c_size(specific_field_ordering%timestep_to_value))
585 iterator=
c_get_iterator(specific_field_ordering%timestep_to_value)
589 if (
associated(generic))
then
592 current_data_point=
pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
593 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
594 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
595 current_data_point=current_data_point+len(trim(map_entry%key))
597 prev_pt=current_data_point
598 current_data_point=current_data_point+kind(current_data_point)
600 prev_pt=
pack_scalar_field(byte_data, prev_pt, (current_data_point-kind(current_data_point))-prev_pt)
612 character,
dimension(:),
intent(in) :: byte_data
615 integer :: current_data_point, number_of_values, byte_size, i, key_size
616 character(len=STRING_LENGTH) :: value_key
617 class(*),
pointer :: generic
626 if (number_of_values .gt. 0)
then
627 do i=1, number_of_values
629 value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
630 value_key(key_size+1:)=
" "
631 current_data_point=current_data_point+key_size
635 current_data_point=current_data_point+byte_size
649 (kind(specific_field_value%timestep) * 6) + len(trim(specific_field_value%field_name)) + &
650 len(trim(specific_field_value%field_namespace)) + kind(specific_field_value%time)
659 character,
dimension(:),
allocatable,
intent(inout) :: byte_data
660 integer,
intent(inout) :: current_data_point
664 current_data_point=
pack_scalar_field(byte_data, current_data_point, specific_field_value%timestep)
665 current_data_point=
pack_scalar_field(byte_data, current_data_point, specific_field_value%frequency)
666 current_data_point=
pack_scalar_field(byte_data, current_data_point, specific_field_value%source)
667 current_data_point=
pack_scalar_field(byte_data, current_data_point, len(trim(specific_field_value%field_name)))
668 byte_data(current_data_point:current_data_point+len(trim(specific_field_value%field_name))-1) = &
669 transfer(trim(specific_field_value%field_name), byte_data(current_data_point:current_data_point+&
670 len(trim(specific_field_value%field_name))-1))
671 current_data_point=current_data_point+len(trim(specific_field_value%field_name))
672 current_data_point=
pack_scalar_field(byte_data, current_data_point, len(trim(specific_field_value%field_namespace)))
673 byte_data(current_data_point:current_data_point+len(trim(specific_field_value%field_namespace))-1) = &
674 transfer(trim(specific_field_value%field_namespace), byte_data(current_data_point:current_data_point+&
675 len(trim(specific_field_value%field_namespace))-1))
676 current_data_point=current_data_point+len(trim(specific_field_value%field_namespace))
677 current_data_point=
pack_scalar_field(byte_data, current_data_point, double_real_value=specific_field_value%time)
679 prev_pt=current_data_point
680 current_data_point=current_data_point+kind(current_data_point)
682 prev_pt=
pack_scalar_field(byte_data, prev_pt, (current_data_point-kind(current_data_point))-prev_pt)
689 character,
dimension(:),
intent(in) :: byte_data
692 integer :: current_data_point, byte_size, str_size
703 current_data_point=current_data_point+str_size
708 current_data_point=current_data_point+str_size
712 current_data_point+byte_size-1))