44 use mpi_f08,
only : mpi_wtime
63 real(kind=
rp) :: time_end
85 integer,
intent(in),
optional :: size
86 real(kind=
rp),
intent(in) :: time_end
87 character(len=LOG_SIZE) :: log_buf
92 if (
present(size))
then
98 allocate(this%output_list(n))
99 allocate(this%controllers(n))
102 this%output_list(i)%ptr => null()
107 this%time_end = time_end
115 if (
allocated(this%output_list))
then
116 deallocate(this%output_list)
118 if (
allocated(this%controllers))
then
119 deallocate(this%controllers)
137 class(
output_t),
intent(inout),
target :: out
138 real(kind=
rp),
intent(in) :: write_par
139 character(len=*),
intent(in) :: write_control
140 real(kind=
rp),
optional,
intent(in) :: start_time
141 real(kind=
rp) :: start_time_
144 character(len=LOG_SIZE) :: log_buf
145 integer :: n, nexecutions
146 class(*),
pointer :: ft
148 if (
present(start_time))
then
149 start_time_ = start_time
155 if (this%n .ge. this%size)
then
156 allocate(tmp(this%size * 2))
157 tmp(1:this%size) = this%output_list
158 call move_alloc(tmp, this%output_list)
160 allocate(tmp_ctrl(this%size * 2))
161 tmp_ctrl(1:this%size) = this%controllers
162 call move_alloc(tmp_ctrl, this%controllers)
164 this%size = this%size * 2
170 this%output_list(this%n)%ptr => out
172 if (trim(write_control) .eq.
"org")
then
173 this%controllers(n) = this%controllers(1)
175 call this%controllers(n)%init(start_time_, this%time_end, &
176 write_control, write_par)
180 call neko_log%section(
'Adding write output')
181 call neko_log%message(
'File name : '// &
182 trim(this%output_list(this%n)%ptr%file_%file_type%fname))
183 call neko_log%message(
'Write control : '//trim(write_control))
186 select type (ft => out%file_%file_type)
188 if (ft%dp_precision)
then
189 call neko_log%message(
'Output precision : double')
191 call neko_log%message(
'Output precision : single')
195 if (trim(write_control) .eq.
'simulationtime')
then
196 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
197 this%controllers(n)%frequency
199 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
200 this%controllers(n)%time_interval
202 else if (trim(write_control) .eq.
'nsamples')
then
203 write(log_buf,
'(A,I13)')
'Total samples: ', int(write_par)
205 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
206 this%controllers(n)%frequency
208 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
209 this%controllers(n)%time_interval
211 else if (trim(write_control) .eq.
'tsteps')
then
212 write(log_buf,
'(A,I13)')
'Time step interval: ', int(write_par)
214 else if (trim(write_control) .eq.
'org')
then
215 write(log_buf,
'(A)') &
216 'Write control not set, defaulting to first output settings'
231 logical,
intent(in),
optional :: ifforce
232 real(kind=
dp) :: sample_start_time, sample_end_time
233 real(kind=
dp) :: sample_time
234 character(len=LOG_SIZE) :: log_buf
236 logical :: force, write_output, write_output_test
238 if (
present(ifforce))
then
247 sample_start_time = mpi_wtime()
249 write_output = .false.
254 select type (samp => this)
257 if (this%controllers(i)%check(time, force))
then
258 write_output = .true.
264 if (write_output)
then
265 call neko_log%section(
'Writer output ')
272 select type (samp => this)
275 if (this%controllers(i)%check(time, force))
then
276 call neko_log%message(
'File name : '// &
277 trim(samp%output_list(i)%ptr%file_%file_type%fname))
279 write(log_buf,
'(A,I6)')
'Output number :', &
280 int(this%controllers(i)%nexecutions)
283 call samp%output_list(i)%ptr%sample(time%t)
285 call this%controllers(i)%register_execution()
289 call neko_error(
'Invalid output_controller output list')
293 sample_end_time = mpi_wtime()
295 sample_time = sample_end_time - sample_start_time
296 if (write_output)
then
297 write(log_buf,
'(A16,1x,F12.6,A,F9.6)')
'Writing at time:', time%t, &
298 ' Output time (s): ', sample_time
310 integer :: i, nexecutions
314 if (this%controllers(i)%nsteps .eq. 0)
then
315 call this%controllers(i)%set_counter(time)
316 nexecutions =this%controllers(i)%nexecutions
317 call this%output_list(i)%ptr%set_counter(nexecutions)
318 call this%output_list(i)%ptr%set_start_counter(nexecutions)
328 integer,
intent(in) :: counter
332 this%controllers(i)%nexecutions = counter
333 call this%output_list(i)%ptr%set_counter(counter)
334 call this%output_list(i)%ptr%set_start_counter(counter)
type(mpi_comm), public 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.