37 use json_module,
only : json_file
45 real(kind=
dp),
dimension(10) :: tlag = 0.0_dp
46 real(kind=
dp),
dimension(10) :: dtlag = 0.0_dp
47 real(kind=
dp) :: t = 0.0_dp
48 real(kind=
dp) :: dt = 0.0_dp
49 real(kind=
dp) :: start_time = 0.0_dp
50 real(kind=
dp) :: end_time = 0.0_dp
54 generic :: init => init_from_components, init_from_json
55 procedure, pass(this) :: init_from_components => &
69 type(json_file),
intent(inout) :: params
71 real(kind=
dp) :: time_step
72 real(kind=
dp) :: start_time
73 real(kind=
dp) :: end_time
74 logical :: is_variable
79 if (.not. is_variable)
then
86 call this%init_from_components(start_time, end_time, time_step)
93 real(kind=
dp),
intent(in) :: start_time
94 real(kind=
dp),
intent(in) :: end_time
95 real(kind=
dp),
intent(in) :: dt
97 if (dt .gt. 0.0_dp .and. start_time .gt. end_time .or. &
98 dt .lt. 0.0_dp .and. start_time .lt. end_time)
then
99 call neko_log%error(
'Time step size must match direction of time.')
102 this%start_time = start_time
103 this%end_time = end_time
108 this%tlag = start_time
117 this%t = this%start_time
119 this%tlag = this%start_time
127 character(len=LOG_SIZE) :: log_buf
128 character(len=64) :: log_fmt
129 real(kind=
dp) :: t_prog
130 integer :: time_digits, time_width, pad_width
132 t_prog = 100.0_dp * (this%t - this%start_time) / &
133 (this%end_time - this%start_time)
135 time_digits = precision(this%t)
136 time_width = time_digits + 8
137 pad_width =
max(1,
log_size - (34 + time_width) - 1)
139 write(log_fmt,
'(A,I0,A,I0,A,I0,A,I0,A)') &
140 '(A7,1X,I10,1X,A4,ES', time_width,
'.', time_digits,
',', &
141 pad_width,
'X,A2,F6.2,A3)'
142 write(log_buf, log_fmt)
'Step = ', this%tstep,
't = ', this%t, &
160 real(kind=
dp) :: span, tol
162 span = abs(this%end_time - this%start_time)
163 tol = this%tolerance()
165 is_done = sign(1.0_dp, this%end_time - this%start_time) * &
166 (this%t - this%start_time) .ge. span - tol &
167 .and. this%tstep .gt. 0
183 tol = 1.0e-9_dp * abs(this%end_time - this%start_time)
184 tol = min(tol, 1.0e-2_dp * abs(this%dt))
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Utilities for retrieving parameters from the case files.
integer, parameter, public neko_log_quiet
Always.
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.
Module with things related to the simulation time.
subroutine time_state_status(this)
Write status banner.
pure real(kind=dp) function time_state_tolerance(this)
Tolerance for comparing the current time to a fixed time, such as the end time of the simulation or a...
subroutine time_state_init_from_json(this, params)
Initialize time state from JSON.
pure logical function time_state_is_done(this)
Check if the simulation is done.
subroutine time_state_init_from_components(this, start_time, end_time, dt)
Initialize time state.
subroutine time_state_reset(this)
Reset time state.
A struct that contains all info about the time, expand as needed.