96 integer,
intent(in),
optional :: size
97 real(kind=
dp),
intent(in) :: time_end
98 real(kind=
dp),
intent(in),
optional :: time_start
99 logical,
intent(in),
optional :: write_at_start
100 character(len=LOG_SIZE) :: log_buf
105 if (
present(size))
then
111 allocate(this%output_list(n))
112 allocate(this%controllers(n))
115 this%output_list(i)%ptr => null()
120 this%time_end = time_end
122 if (
present(time_start))
then
123 this%time_start = time_start
125 this%time_start = 0.0_dp
128 if (
present(write_at_start))
then
129 this%write_at_start = write_at_start
131 this%write_at_start = .true.
166 start_time, write_at_start)
168 class(
output_t),
intent(inout),
target :: out
169 real(kind=
dp),
intent(in) :: write_par
170 character(len=*),
intent(in) :: write_control
171 real(kind=
dp),
optional,
intent(in) :: start_time
172 logical,
optional,
intent(in) :: write_at_start
173 real(kind=
dp) :: start_time_
174 logical :: write_at_start_
177 character(len=LOG_SIZE) :: log_buf
178 integer :: n, nexecutions
179 class(*),
pointer :: ft
181 if (
present(start_time))
then
182 start_time_ = start_time
184 start_time_ = this%time_start
187 if (
present(write_at_start))
then
188 write_at_start_ = write_at_start
190 write_at_start_ = this%write_at_start
194 if (this%n .ge. this%size)
then
195 allocate(tmp(this%size * 2))
196 tmp(1:this%size) = this%output_list
197 call move_alloc(tmp, this%output_list)
199 allocate(tmp_ctrl(this%size * 2))
200 tmp_ctrl(1:this%size) = this%controllers
201 call move_alloc(tmp_ctrl, this%controllers)
203 this%size = this%size * 2
209 this%output_list(this%n)%ptr => out
211 if (trim(write_control) .eq.
"org")
then
212 this%controllers(n) = this%controllers(1)
214 call this%controllers(n)%init(start_time_, this%time_end, &
215 write_control, write_par, write_at_start_, &
216 direction = this%time_end - this%time_start)
220 call neko_log%section(
'Adding write output')
221 call neko_log%message(
'File name : '// &
222 trim(this%output_list(this%n)%ptr%file_%file_type%get_fname()))
223 call neko_log%message(
'Write control : '//trim(write_control))
224 if (.not. this%controllers(n)%never)
then
225 write(log_buf,
'(A,ES13.6)')
'First write at : ', &
226 this%controllers(n)%next_time()
227 if (trim(write_control) .ne.
'tsteps')
call neko_log%message(log_buf)
231 select type (ft => out%file_%file_type)
233 if (ft%dp_precision)
then
234 call neko_log%message(
'Output precision : double')
236 call neko_log%message(
'Output precision : single')
240 if (trim(write_control) .eq.
'simulationtime')
then
241 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
242 this%controllers(n)%frequency
244 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
245 this%controllers(n)%time_interval
247 else if (trim(write_control) .eq.
'nsamples')
then
248 write(log_buf,
'(A,I13)')
'Total samples: ', int(write_par)
250 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
251 this%controllers(n)%frequency
253 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
254 this%controllers(n)%time_interval
256 else if (trim(write_control) .eq.
'tsteps')
then
257 write(log_buf,
'(A,I13)')
'Time step interval: ', int(write_par)
259 else if (trim(write_control) .eq.
'org')
then
260 write(log_buf,
'(A)') &
261 'Write control not set, defaulting to first output settings'
276 logical,
intent(in),
optional :: ifforce
277 real(kind=
dp) :: sample_start_time, sample_end_time
278 real(kind=
dp) :: sample_time
279 character(len=LOG_SIZE) :: log_buf
280 character(len=1024) :: output_fname
282 logical :: force, write_output, write_output_test
284 if (
present(ifforce))
then
293 sample_start_time = mpi_wtime()
295 write_output = .false.
300 select type (samp => this)
303 if (this%controllers(i)%check(time, force))
then
304 write_output = .true.
310 if (write_output)
then
311 call neko_log%section(
'Writer output ')
318 select type (samp => this)
321 if (this%controllers(i)%check(time, force))
then
323 samp%output_list(i)%ptr%file_%file_type% &
324 get_next_output_fname()
325 call neko_log%message(
'File name : '//trim(output_fname))
327 write(log_buf,
'(A,I6)')
'Output number :', &
328 int(this%controllers(i)%nexecutions)
332 call samp%output_list(i)%ptr%sample(time%t)
334 call this%controllers(i)%register_execution(time)
338 call neko_error(
'Invalid output_controller output list')
342 sample_end_time = mpi_wtime()
344 sample_time = sample_end_time - sample_start_time
345 if (write_output)
then
346 write(log_buf,
'(A16,1x,F12.6,A,F9.6)')
'Writing at time:', time%t, &
347 ' Output time (s): ', sample_time
360 character(len=LOG_SIZE) :: log_buf
361 character(len=1024) :: output_fname
362 integer :: i, nexecutions
363 logical :: file_exists
366 call this%controllers(i)%set_counter(time)
369 if (this%controllers(i)%nsteps .eq. 0)
then
370 nexecutions = this%controllers(i)%nexecutions
371 call this%output_list(i)%ptr%set_counter(-1)
372 call this%output_list(i)%ptr%set_start_counter(nexecutions)
380 if (this%controllers(i)%never) cycle
381 file_exists = .false.
383 this%output_list(i)%ptr%file_%file_type%get_next_output_fname()
385 inquire(
file = trim(output_fname), exist = file_exists)
387 if (file_exists)
then
388 write(log_buf,
'(A,A)')
'Overwriting from: ', trim(output_fname)
subroutine output_controller_execute(this, time, ifforce)
Query each of the controllers whether it is time to write, and if so, do so for the corresponding out...
subroutine output_controller_add(this, out, write_par, write_control, start_time, write_at_start)
Add an output out to the controller.