38 use json_module,
only : json_file
45 real(kind=
rp),
dimension(10) :: tlag = 0.0_rp
46 real(kind=
rp),
dimension(10) :: dtlag = 0.0_rp
47 real(kind=
rp) :: t = 0.0_rp
48 real(kind=
rp) :: dt = 0.0_rp
49 real(kind=
rp) :: start_time = 0.0_rp
50 real(kind=
rp) :: end_time = 0.0_rp
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=
rp) :: time_step
72 real(kind=
rp) :: start_time
73 real(kind=
rp) :: end_time
74 logical :: is_variable
77 call json_get(params,
'end_time', end_time)
79 if (.not. is_variable)
then
80 call json_get(params,
'timestep', time_step)
86 call this%init_from_components(start_time, end_time, time_step)
93 real(kind=
rp),
intent(in) :: start_time
94 real(kind=
rp),
intent(in) :: end_time
95 real(kind=
rp),
intent(in) :: dt
97 if (dt .gt. 0.0_rp .and. start_time .gt. end_time .or. &
98 dt .lt. 0.0_rp .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 type(
chkp_t),
intent(in) :: chkp
130 this%dtlag = chkp%dtlag
131 this%tlag = chkp%tlag
137 character(len=LOG_SIZE) :: log_buf
138 character(len=38) :: log_fmt
139 real(kind=
rp) :: t_prog
141 t_prog = 100.0_rp * (this%t - this%start_time) / &
142 (this%end_time - this%start_time)
144 write(log_fmt,
'(A,I2,A)') &
145 '(A7,1X,I10,1X,A4,E15.7,',
log_size - 50,
'X,A2,F6.2,A3)'
146 write(log_buf, log_fmt)
'Step = ', this%tstep,
't = ', this%t, &
160 is_done = this%t - this%start_time .ge. this%end_time - this%start_time &
161 .and. this%tstep .gt. 0
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Utilities for retrieving parameters from the case files.
integer, parameter, public neko_log_quiet
Always logged.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public rp
Global precision used in computations.
Module with things related to the simulation time.
subroutine time_state_restart(this, chkp)
Restart time state.
subroutine time_state_status(this)
Write status banner.
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.