61 real(kind=
rp) :: time_end
83 integer,
intent(in),
optional :: size
84 real(kind=
rp),
intent(in) :: time_end
85 character(len=LOG_SIZE) :: log_buf
90 if (
present(size))
then
96 allocate(this%output_list(n))
97 allocate(this%controllers(n))
100 this%output_list(i)%ptr => null()
105 this%time_end = time_end
113 if (
allocated(this%output_list))
then
114 deallocate(this%output_list)
116 if (
allocated(this%controllers))
then
117 deallocate(this%controllers)
135 class(
output_t),
intent(inout),
target :: out
136 real(kind=
rp),
intent(in) :: write_par
137 character(len=*),
intent(in) :: write_control
138 real(kind=
rp),
optional,
intent(in) :: start_time
141 character(len=LOG_SIZE) :: log_buf
143 class(*),
pointer :: ft
145 if (this%n .ge. this%size)
then
146 allocate(tmp(this%size * 2))
147 tmp(1:this%size) = this%output_list
148 call move_alloc(tmp, this%output_list)
150 allocate(tmp_ctrl(this%size * 2))
151 tmp_ctrl(1:this%size) = this%controllers
152 call move_alloc(tmp_ctrl, this%controllers)
154 this%size = this%size * 2
159 this%output_list(this%n)%ptr => out
161 if (trim(write_control) .eq.
"org")
then
162 this%controllers(n) = this%controllers(1)
164 call this%controllers(n)%init(this%time_end, write_control, write_par, &
169 call neko_log%section(
'Adding write output')
170 call neko_log%message(
'File name : '// &
171 trim(this%output_list(this%n)%ptr%file_%file_type%fname))
172 call neko_log%message(
'Write control : '//trim(write_control))
175 select type (ft => out%file_%file_type)
177 if (ft%dp_precision)
then
178 call neko_log%message(
'Output precision : double')
180 call neko_log%message(
'Output precision : single')
184 if (trim(write_control) .eq.
'simulationtime')
then
185 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
186 this%controllers(n)%frequency
188 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
189 this%controllers(n)%time_interval
191 else if (trim(write_control) .eq.
'nsamples')
then
192 write(log_buf,
'(A,I13)')
'Total samples: ', int(write_par)
194 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
195 this%controllers(n)%frequency
197 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
198 this%controllers(n)%time_interval
200 else if (trim(write_control) .eq.
'tsteps')
then
201 write(log_buf,
'(A,I13)')
'Time step interval: ', int(write_par)
203 else if (trim(write_control) .eq.
'org')
then
204 write(log_buf,
'(A)') &
205 'Write control not set, defaulting to first output settings'
219 real(kind=
rp),
intent(in) :: t
220 integer,
intent(in) :: tstep
221 logical,
intent(in),
optional :: ifforce
222 real(kind=
dp) :: sample_start_time, sample_end_time
223 real(kind=
dp) :: sample_time
224 character(len=LOG_SIZE) :: log_buf
226 logical :: force, write_output, write_output_test
228 if (
present(ifforce))
then
237 sample_start_time = mpi_wtime()
239 write_output = .false.
244 select type (samp => this)
247 if (this%controllers(i)%check(t, tstep, force))
then
248 write_output = .true.
254 if (write_output)
then
255 call neko_log%section(
'Writer output ')
262 select type (samp => this)
265 if (this%controllers(i)%check(t, tstep, force))
then
266 call neko_log%message(
'File name : '// &
267 trim(samp%output_list(i)%ptr%file_%file_type%fname))
269 write(log_buf,
'(A,I6)')
'Output number :', &
270 int(this%controllers(i)%nexecutions)
273 call samp%output_list(i)%ptr%sample(t)
275 call this%controllers(i)%register_execution()
279 call neko_error(
'Invalid output_controller output list')
283 sample_end_time = mpi_wtime()
285 sample_time = sample_end_time - sample_start_time
286 if (write_output)
then
287 write(log_buf,
'(A16,1x,F12.6,A,F9.6)')
'Writing at time:', t, &
288 ' Output time (s): ', sample_time
299 real(kind=
rp),
intent(in) :: t
300 integer :: i, nexecutions
304 if (this%controllers(i)%nsteps .eq. 0)
then
305 nexecutions = int(t / this%controllers(i)%time_interval) + 1
306 this%controllers(i)%nexecutions = nexecutions
308 call this%output_list(i)%ptr%set_counter(nexecutions)
309 call this%output_list(i)%ptr%set_start_counter(nexecutions)
319 integer,
intent(in) :: counter
323 this%controllers(i)%nexecutions = counter
324 call this%output_list(i)%ptr%set_counter(counter)
325 call this%output_list(i)%ptr%set_start_counter(counter)
type(mpi_comm) neko_comm
MPI communicator.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
Implements output_controller_t
subroutine output_controller_free(this)
Destructor.
subroutine output_controller_init(this, time_end, size)
Constructor.
subroutine output_controller_set_counter(this, t)
Set write counter based on time (after restart)
subroutine output_controller_add(this, out, write_par, write_control, start_time)
Add an output out to the controller.
subroutine output_controller_execute(this, t, tstep, ifforce)
Query each of the controllers whether it is time to write, and if so, do so for the corresponding out...
subroutine output_controller_set_write_count(this, counter)
Set write counter (after restart) explicitly.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
subroutine, public profiler_end_region(name, region_id)
End the most recently started profiler region.
Contains the time_based_controller_t type.
Interface for NEKTON fld files.
Wrapper around an output_t pointer.
Abstract type defining an output type.
Centralized controller for a list of outputs.
A utility type for determening whether an action should be executed based on the current time value....