38 use mpi_f08,
only : mpi_barrier, mpi_wtime
56 real(kind=
rp) :: t_begin
57 real(kind=
rp) :: t_diff
58 integer :: samp_interval
69 class(
quantp_t),
intent(inout) :: this
75 subroutine stats_init(this, T_begin, samp_interval, size)
76 class(
stats_t),
intent(inout) :: this
77 real(kind=
rp),
intent(in) :: t_begin
78 integer,
intent(in) :: samp_interval
79 integer,
intent(inout),
optional ::size
84 if (
present(size))
then
90 allocate(this%quant_list(n))
93 this%quant_list(i)%quantp => null()
98 this%T_begin = t_begin
99 this%samp_interval = samp_interval
106 class(
stats_t),
intent(inout) :: this
109 if (
allocated(this%quant_list))
then
110 do i = 1,
size(this%quant_list)
111 call this%quant_list(i)%free()
114 deallocate(this%quant_list)
123 class(
stats_t),
intent(inout) :: this
125 type(
quantp_t),
allocatable :: tmp(:)
127 if (this%n .ge. this%size)
then
128 allocate(tmp(this%size * 2))
129 tmp(1:this%size) = this%quant_list
130 call move_alloc(tmp, this%quant_list)
131 this%size = this%size * 2
135 this%quant_list(this%n)%quantp => quant
140 class(
stats_t),
intent(inout) :: this
141 real(kind=
rp),
intent(in) :: t
142 real(kind=
rp),
intent(in) :: dt
143 integer,
intent(in) :: tstep
145 character(len=LOG_SIZE) :: log_buf
146 real(kind=
rp) :: sample_start_time, sample_end_time
147 real(kind=
dp) :: sample_time
149 if (t .ge. this%T_begin .and. this%n .gt. 0)
then
150 this%t_diff = this%t_diff + dt
154 if (mod(tstep,this%samp_interval) .eq. 0)
then
157 sample_start_time = mpi_wtime()
159 call this%quant_list(i)%quantp%update(this%t_diff)
163 sample_end_time = mpi_wtime()
164 sample_time = sample_end_time - sample_start_time
165 write(log_buf,
'(A17,1x,F10.6,A,F9.6)')
'Sampling at time:', t, &
166 ' Sampling time (s): ', sample_time
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.
Defines a statistical quantity.
Defines a container for all statistics.
subroutine stats_eval(this, t, dt, tstep)
Evaluated all statistical quantities.
subroutine stats_free(this)
Deallocate.
subroutine stats_init(this, t_begin, samp_interval, size)
Initialize statistics, computed after T_begin.
subroutine stats_add(this, quant)
Add a statistic quantitiy quant to the backend.
subroutine quantp_free(this)
Destructor for quantp_t.
Pointer to an arbitrary quantitiy.
Abstract type defining a statistical quantity.