23 character(len=STRING_LENGTH) :: field_name
26 logical :: empty_values
50 latest_timestep, write_timestep)
51 real,
intent(in) :: latest_time, output_frequency, write_time
52 integer,
intent(in) :: latest_timestep, write_timestep
65 field_name, timestep, time)
67 real,
intent(in) :: output_frequency
69 character(len=*),
intent(in) :: field_name
70 integer,
intent(in) :: timestep
77 call time_average(timeaveraged_value, instant_values, time)
79 if ((aint(time*10000000.0)-aint(timeaveraged_value%previous_output_time*10000000.0))/10000000.0 .ge. output_frequency)
then
80 timeaveraged_value%previous_output_time=time
83 timeaveraged_value%time_averaged_values=0.0_default_precision
84 timeaveraged_value%start_time=time
85 timeaveraged_value%previous_time=time
86 timeaveraged_value%empty_values=.true.
97 real(kind=default_precision),
dimension(:),
intent(in) :: instant_values
98 real(kind=default_precision),
intent(in) :: time
101 real(kind=default_precision) :: timeav, timedg, combined_add
103 timeav=time-timeaveraged_value%start_time
104 timedg=time-timeaveraged_value%previous_time
105 combined_add=timeav+timedg
107 if (.not.
allocated(timeaveraged_value%time_averaged_values))
then
108 allocate(timeaveraged_value%time_averaged_values(
size(instant_values)))
109 timeaveraged_value%time_averaged_values=0.0_default_precision
112 if (timeaveraged_value%empty_values)
then
113 timeaveraged_value%empty_values=.false.
114 timeaveraged_value%time_averaged_values=instant_values
116 do i=1,
size(instant_values)
117 timeaveraged_value%time_averaged_values(i)=(timeav*timeaveraged_value%time_averaged_values(i)+&
118 timedg*instant_values(i)) / combined_add
122 timeaveraged_value%previous_time=time
128 type(mapentry_type) :: map_entry
129 type(iterator_type) :: iterator
130 class(*),
pointer :: generic
136 do while (c_has_next(iterator))
137 map_entry=c_next_mapentry(iterator)
138 generic=>c_get_generic(map_entry)
139 if (
associated(generic))
then
153 character,
dimension(:),
allocatable,
intent(inout) :: byte_data
155 integer :: current_data_point, prev_pt
156 type(mapentry_type) :: map_entry
157 type(iterator_type) :: iterator
158 class(*),
pointer :: generic
161 current_data_point=pack_scalar_field(byte_data, current_data_point, c_size(
timeaveraged_values))
164 do while (c_has_next(iterator))
165 map_entry=c_next_mapentry(iterator)
166 generic=>c_get_generic(map_entry)
167 if (
associated(generic))
then
170 current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(map_entry%key)))
171 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1) = transfer(trim(map_entry%key), &
172 byte_data(current_data_point:current_data_point+len(trim(map_entry%key))-1))
173 current_data_point=current_data_point+len(trim(map_entry%key))
175 prev_pt=current_data_point
176 current_data_point=current_data_point+kind(current_data_point)
178 prev_pt=pack_scalar_field(byte_data, prev_pt, (current_data_point-kind(current_data_point)) - prev_pt)
188 character,
dimension(:),
intent(in) :: byte_data
190 integer :: current_data_point, number_entries, i, key_size, byte_size
191 character(len=STRING_LENGTH) :: value_key
192 class(*),
pointer :: generic
195 number_entries=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
196 if (number_entries .gt. 0)
then
197 do i=1, number_entries
198 key_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
199 value_key=transfer(byte_data(current_data_point:current_data_point+key_size-1), value_key)
200 value_key(key_size+1:)=
" "
201 current_data_point=current_data_point+key_size
202 byte_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
205 current_data_point=current_data_point+byte_size
216 call check_thread_status(forthread_mutex_lock(time_av_value%mutex))
219 (
size(time_av_value%time_averaged_values) * kind(time_av_value%time_averaged_values)) + &
229 character,
dimension(:),
allocatable,
intent(inout) :: byte_data
230 integer,
intent(inout) :: current_data_point
234 current_data_point=pack_scalar_field(byte_data, current_data_point, double_real_value=time_av_value%start_time)
235 current_data_point=pack_scalar_field(byte_data, current_data_point, double_real_value=time_av_value%previous_time)
236 current_data_point=pack_scalar_field(byte_data, current_data_point, double_real_value=time_av_value%previous_output_time)
237 current_data_point=pack_scalar_field(byte_data, current_data_point, logical_value=time_av_value%empty_values)
238 current_data_point=pack_scalar_field(byte_data, current_data_point, len(trim(time_av_value%field_name)))
239 byte_data(current_data_point:current_data_point+len(trim(time_av_value%field_name))-1) = transfer(&
240 trim(time_av_value%field_name), byte_data(current_data_point:current_data_point+len(trim(time_av_value%field_name))-1))
241 current_data_point=current_data_point+len(trim(time_av_value%field_name))
242 current_data_point=pack_scalar_field(byte_data, current_data_point,
size(time_av_value%time_averaged_values))
243 current_data_point=pack_array_field(byte_data, current_data_point, real_array_1d=time_av_value%time_averaged_values)
244 call check_thread_status(forthread_mutex_unlock(time_av_value%mutex))
250 character,
dimension(:),
intent(in) :: byte_data
253 integer :: current_data_point, i, values_size, byte_size, str_size
260 unpack_scalar_dp_real_from_bytedata(byte_data, current_data_point)
262 str_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
264 transfer(byte_data(current_data_point:current_data_point+str_size-1), &
267 current_data_point=current_data_point+str_size
268 values_size=unpack_scalar_integer_from_bytedata(byte_data, current_data_point)
281 integer,
intent(in) :: timestep
282 character(len=*),
intent(in) :: field_name
285 class(*),
pointer :: generic
294 new_entry%field_name=field_name
295 new_entry%start_time=0.0_default_precision
296 new_entry%previous_time=0.0_default_precision
297 new_entry%empty_values=.true.
298 new_entry%previous_output_time=0.0_default_precision
299 call check_thread_status(forthread_mutex_init(new_entry%mutex, -1))
313 character(len=*),
intent(in) :: field_name
315 logical,
intent(in),
optional :: issue_read_lock
317 class(*),
pointer :: generic
318 logical :: do_read_lock
320 if (
present(issue_read_lock))
then
321 do_read_lock=issue_read_lock
329 if (
associated(generic))
then