62 real(kind=
rp) :: time_end
84 integer,
intent(in),
optional :: size
85 real(kind=
rp),
intent(in) :: time_end
86 character(len=LOG_SIZE) :: log_buf
91 if (
present(size))
then
97 allocate(this%output_list(n))
98 allocate(this%controllers(n))
101 this%output_list(i)%ptr => null()
106 this%time_end = time_end
114 if (
allocated(this%output_list))
then
115 deallocate(this%output_list)
117 if (
allocated(this%controllers))
then
118 deallocate(this%controllers)
136 class(
output_t),
intent(inout),
target :: out
137 real(kind=
rp),
intent(in) :: write_par
138 character(len=*),
intent(in) :: write_control
139 real(kind=
rp),
optional,
intent(in) :: start_time
142 character(len=LOG_SIZE) :: log_buf
143 integer :: n, nexecutions
144 class(*),
pointer :: ft
146 if (this%n .ge. this%size)
then
147 allocate(tmp(this%size * 2))
148 tmp(1:this%size) = this%output_list
149 call move_alloc(tmp, this%output_list)
151 allocate(tmp_ctrl(this%size * 2))
152 tmp_ctrl(1:this%size) = this%controllers
153 call move_alloc(tmp_ctrl, this%controllers)
155 this%size = this%size * 2
161 this%output_list(this%n)%ptr => out
163 if (trim(write_control) .eq.
"org")
then
164 this%controllers(n) = this%controllers(1)
166 call this%controllers(n)%init(this%time_end, write_control, write_par)
169 if (
present(start_time))
then
170 if (start_time .gt. 0.0_rp)
then
171 nexecutions = int(start_time / this%controllers(n)%time_interval) + 1
172 this%controllers(n)%nexecutions = nexecutions
173 call this%output_list(n)%ptr%set_counter(nexecutions)
174 call this%output_list(n)%ptr%set_start_counter(nexecutions)
178 call neko_log%section(
'Adding write output')
179 call neko_log%message(
'File name : '// &
180 trim(this%output_list(this%n)%ptr%file_%file_type%fname))
181 call neko_log%message(
'Write control : '//trim(write_control))
184 select type (ft => out%file_%file_type)
186 if (ft%dp_precision)
then
187 call neko_log%message(
'Output precision : double')
189 call neko_log%message(
'Output precision : single')
193 if (trim(write_control) .eq.
'simulationtime')
then
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.
'nsamples')
then
201 write(log_buf,
'(A,I13)')
'Total samples: ', int(write_par)
203 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
204 this%controllers(n)%frequency
206 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
207 this%controllers(n)%time_interval
209 else if (trim(write_control) .eq.
'tsteps')
then
210 write(log_buf,
'(A,I13)')
'Time step interval: ', int(write_par)
212 else if (trim(write_control) .eq.
'org')
then
213 write(log_buf,
'(A)') &
214 'Write control not set, defaulting to first output settings'
229 logical,
intent(in),
optional :: ifforce
230 real(kind=
dp) :: sample_start_time, sample_end_time
231 real(kind=
dp) :: sample_time
232 character(len=LOG_SIZE) :: log_buf
234 logical :: force, write_output, write_output_test
236 if (
present(ifforce))
then
245 sample_start_time = mpi_wtime()
247 write_output = .false.
252 select type (samp => this)
255 if (this%controllers(i)%check(time, force))
then
256 write_output = .true.
262 if (write_output)
then
263 call neko_log%section(
'Writer output ')
270 select type (samp => this)
273 if (this%controllers(i)%check(time, force))
then
274 call neko_log%message(
'File name : '// &
275 trim(samp%output_list(i)%ptr%file_%file_type%fname))
277 write(log_buf,
'(A,I6)')
'Output number :', &
278 int(this%controllers(i)%nexecutions)
281 call samp%output_list(i)%ptr%sample(time%t)
283 call this%controllers(i)%register_execution()
287 call neko_error(
'Invalid output_controller output list')
291 sample_end_time = mpi_wtime()
293 sample_time = sample_end_time - sample_start_time
294 if (write_output)
then
295 write(log_buf,
'(A16,1x,F12.6,A,F9.6)')
'Writing at time:', time%t, &
296 ' Output time (s): ', sample_time
308 integer :: i, nexecutions
312 if (this%controllers(i)%nsteps .eq. 0)
then
313 call this%controllers(i)%set_counter(time)
314 nexecutions =this%controllers(i)%nexecutions
315 call this%output_list(i)%ptr%set_counter(nexecutions)
316 call this%output_list(i)%ptr%set_start_counter(nexecutions)
326 integer,
intent(in) :: counter
330 this%controllers(i)%nexecutions = counter
331 call this%output_list(i)%ptr%set_counter(counter)
332 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_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_free(this)
Destructor.
subroutine output_controller_init(this, time_end, size)
Constructor.
subroutine output_controller_add(this, out, write_par, write_control, start_time)
Add an output out to the controller.
subroutine output_controller_set_counter(this, time)
Set write counter based on time (after restart)
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.
Module with things related to the simulation time.
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 determining whether an action should be executed based on the current time value....
A struct that contains all info about the time, expand as needed.