54 type(
outp_t),
allocatable :: output_list(:)
62 real(kind=
rp) :: t_end
81 integer,
intent(in),
optional :: size
82 real(kind=
rp),
intent(in) :: t_end
83 character(len=LOG_SIZE) :: log_buf
89 if (
present(size))
then
95 allocate(this%output_list(n))
96 allocate(this%controllers(n))
99 this%output_list(i)%outp => null()
112 if (
allocated(this%output_list))
then
113 deallocate(this%output_list)
115 if (
allocated(this%controllers))
then
116 deallocate(this%controllers)
127 class(
output_t),
intent(inout),
target :: out
128 real(kind=
rp),
intent(in) :: write_par
129 character(len=*),
intent(in) :: write_control
130 type(
outp_t),
allocatable :: tmp(:)
132 character(len=LOG_SIZE) :: log_buf
134 class(*),
pointer :: ft
136 if (this%n .ge. this%size)
then
137 allocate(tmp(this%size * 2))
138 tmp(1:this%size) = this%output_list
139 call move_alloc(tmp, this%output_list)
141 allocate(tmp_ctrl(this%size * 2))
142 tmp_ctrl(1:this%size) = this%controllers
143 call move_alloc(tmp_ctrl, this%controllers)
145 this%size = this%size * 2
150 this%output_list(this%n)%outp => out
152 if (trim(write_control) .eq.
"org")
then
153 this%controllers(n) = this%controllers(1)
155 call this%controllers(n)%init(this%T_end, write_control, write_par)
159 call neko_log%section(
'Adding write output')
160 call neko_log%message(
'File name : '// &
161 trim(this%output_list(this%n)%outp%file_%file_type%fname))
162 call neko_log%message(
'Write control : '//trim(write_control))
165 select type(ft => out%file_%file_type)
167 if (ft%dp_precision)
then
168 call neko_log%message(
'Output precision : double')
170 call neko_log%message(
'Output precision : single')
174 if (trim(write_control) .eq.
'simulationtime')
then
175 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
176 this%controllers(n)%frequency
178 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
179 this%controllers(n)%time_interval
181 else if (trim(write_control) .eq.
'nsamples')
then
182 write(log_buf,
'(A,I13)')
'Total samples: ', int(write_par)
184 write(log_buf,
'(A,ES13.6)')
'Writes per time unit (Freq.): ', &
185 this%controllers(n)%frequency
187 write(log_buf,
'(A,ES13.6)')
'Time between writes: ', &
188 this%controllers(n)%time_interval
190 else if (trim(write_control) .eq.
'tsteps')
then
191 write(log_buf,
'(A,I13)')
'Time step interval: ', int(write_par)
193 else if (trim(write_control) .eq.
'org')
then
194 write(log_buf,
'(A)') &
195 'Write control not set, defaulting to first output settings'
205 real(kind=
rp),
intent(in) :: t
206 integer,
intent(in) :: tstep
207 logical,
intent(in),
optional :: ifforce
208 real(kind=
dp) :: sample_start_time, sample_end_time
209 real(kind=
dp) :: sample_time
210 character(len=LOG_SIZE) :: log_buf
212 logical :: force, write_output, write_output_test
214 if (
present(ifforce))
then
223 sample_start_time = mpi_wtime()
225 write_output = .false.
230 select type (samp => this)
233 if (this%controllers(i)%check(t, tstep, force))
then
234 write_output = .true.
240 if (write_output)
then
241 call neko_log%section(
'Writer output ')
248 select type (samp => this)
251 if (this%controllers(i)%check(t, tstep, force))
then
252 call neko_log%message(
'File name : '// &
253 trim(samp%output_list(i)%outp%file_%file_type%fname))
255 write(log_buf,
'(A,I6)')
'Output number :', &
256 int(this%controllers(i)%nexecutions)
259 call samp%output_list(i)%outp%sample(t)
261 call this%controllers(i)%register_execution()
265 call neko_error(
'Invalid sampler output list')
269 sample_end_time = mpi_wtime()
271 sample_time = sample_end_time - sample_start_time
272 if (write_output)
then
273 write(log_buf,
'(A16,1x,F10.6,A,F9.6)')
'Writing at time:', t, &
274 ' Output time (s): ', sample_time
284 real(kind=
rp),
intent(in) :: t
289 if (this%controllers(i)%nsteps .eq. 0)
then
290 this%controllers(i)%nexecutions = &
291 int(t / this%controllers(i)%time_interval) + 1
293 call this%output_list(i)%outp%set_counter(this%controllers(i)%nexecutions)
294 call this%output_list(i)%outp%set_start_counter(this%controllers(i)%nexecutions)
303 integer,
intent(in) :: sample_number
307 this%controllers(i)%nexecutions = sample_number
308 call this%output_list(i)%outp%set_counter(this%controllers(i)%nexecutions)
309 call this%output_list(i)%outp%set_start_counter(this%controllers(i)%nexecutions)
type(mpi_comm) neko_comm
MPI communicator.
type(log_t), public neko_log
Global log stream.
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
subroutine, public profiler_end_region
End the most recently started profiler region.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
subroutine sampler_add(this, out, write_par, write_control)
Add an output out to the sampler.
subroutine sampler_sample(this, t, tstep, ifforce)
Sample all outputs in the sampler.
subroutine sampler_set_sample_count(this, sample_number)
Set sampling counter (after restart) explicitly.
subroutine sampler_free(this)
Deallocate a sampler.
subroutine sampler_set_counter(this, t)
Set sampling counter based on time (after restart)
subroutine sampler_init(this, T_end, size)
Initialize a sampler.
Contains the time_based_controller_t type.
Interface for NEKTON fld files.
Abstract type defining an output type.
Pointer to an arbitrary output.
A utility type for determening whether an action should be executed based on the current time value....