35 use mpi_f08,
only : mpi_wtime
64 type(
case_t),
intent(inout) :: c
66 character(len=LOG_SIZE) :: log_buf
68 character(len=:),
allocatable :: restart_file
71 call c%params%get(
'case.restart_file', restart_file, found)
72 if (found .and. len_trim(restart_file) .gt. 0)
then
78 call neko_log%section(
'Starting simulation')
79 write(log_buf,
'(A, E15.7,A,E15.7,A)') &
80 'T : [', c%time%t,
', ', c%time%end_time,
']'
82 if (.not. dt_controller%is_variable_dt)
then
83 write(log_buf,
'(A, E15.7)')
'dt : ', c%time%dt
85 write(log_buf,
'(A, E15.7)')
'CFL : ', dt_controller%cfl_trg
88 if (dt_controller%exact_output_time)
then
89 call neko_log%message(
'dt is fitted to the output times')
93 call neko_log%section(
'Preprocessing')
94 call c%user%initialize(c%time)
98 if (dt_controller%is_variable_dt)
then
99 c%time%dt = dt_controller%first_dt(c%time, &
100 c%fluid%compute_cfl(c%time%dt))
102 call c%output_controller%execute(c%time)
111 type(
case_t),
intent(inout) :: c
112 logical :: output_at_end
116 output_at_end, .true.)
117 call c%output_controller%execute(c%time, output_at_end)
119 if (.not. (output_at_end) .and. .not. c%time%is_done())
then
124 call c%user%finalize(c%time)
126 call neko_log%end_section(
'Normal end.')
132 type(
case_t),
intent(inout) :: c
134 real(kind=
dp),
optional,
intent(in) :: tstep_loop_start_time
135 real(kind=
dp) :: start_time, end_time, tstep_start_time
136 real(kind=
dp) :: cfl, dt_previous
137 character(len=LOG_SIZE) :: log_buf
141 start_time = mpi_wtime()
142 tstep_start_time = start_time
145 dt_previous = c%time%dt
146 cfl = c%fluid%compute_cfl(c%time%dt)
147 call dt_controller%set_dt(c%time, cfl)
150 if (dt_controller%exact_output_time)
then
151 call dt_controller%land(c%time, &
152 min(c%output_controller%time_to_next(c%time), &
157 if (c%time%dt .ne. dt_previous) cfl = c%fluid%compute_cfl(c%time%dt)
164 call neko_log%section(
'Preprocessing')
166 write(log_buf,
"(A,F8.4,2x,A,1P,E14.7)")
'CFL:', cfl,
'dt:', c%time%dt
170 call c%user%preprocess(c%time)
176 start_time = mpi_wtime()
177 call c%fluid%step(c%time, dt_controller)
178 end_time = mpi_wtime()
179 write(log_buf,
'(A,3X,E15.7)')
'Fluid step time (s):', end_time - start_time
183 if (
allocated(c%scalars))
then
184 start_time = mpi_wtime()
186 call c%scalars%step(c%time, c%fluid%ext_bdf, dt_controller)
187 end_time = mpi_wtime()
188 write(log_buf,
'(A,6X,E15.7)')
'Scalar step time:', end_time - start_time
193 call neko_log%section(
'Postprocessing')
199 call c%user%compute(c%time)
202 call c%output_controller%execute(c%time)
207 end_time = mpi_wtime()
208 call neko_log%section(
'Step summary')
209 write(log_buf,
'(A20,I8,A6,E15.7)') &
210 'Total time for step ', c%time%tstep,
' (s): ', &
211 end_time-tstep_start_time
214 if (
present(tstep_loop_start_time))
then
215 write(log_buf,
'(A34,E15.7)') &
216 'Total elapsed time (s): ', &
217 end_time - tstep_loop_start_time
234 time%tlag(i) = time%tlag(i-1)
235 time%dtlag(i) = time%dtlag(i-1)
238 time%dtlag(1) = time%dt
239 time%tlag(1) = time%t
241 if (
allocated(ext_bdf))
then
242 if (ext_bdf%ndiff .eq. 0)
then
243 time%dtlag(2) = time%dt
244 time%tlag(2) = time%t
247 call ext_bdf%set_coeffs(
real(time%dtlag, kind=
rp))
250 time%tstep = time%tstep + 1
251 time%t = time%t + time%dt
257 type(
case_t),
intent(inout) :: C
258 type(
file_t) :: chkpf, previous_meshf
259 character(len=LOG_SIZE) :: log_buf
260 character(len=:),
allocatable :: restart_file
261 character(len=:),
allocatable :: restart_mesh_file
263 logical :: found, check_cont
266 call json_get(c%params,
'case.restart_file', restart_file)
268 restart_mesh_file,
"")
270 if (restart_mesh_file .ne.
"")
then
271 call previous_meshf%init(trim(restart_mesh_file))
272 call previous_meshf%read(c%chkp%previous_mesh)
275 c%chkp%mesh2mesh_tol, 1e-6_dp)
278 call neko_log%section(
'Restarting from checkpoint')
279 write(log_buf,
'(A,A)')
'File : ', trim(restart_file)
282 call chkpf%init(trim(restart_file))
283 call chkpf%read(c%chkp)
288 call c%chkp%previous_mesh%free()
290 write(log_buf,
'(A,E15.7)')
'Time : ', c%time%t
298 type(
case_t),
intent(inout) :: C
299 type(
chkp_t),
intent(inout) :: chkp
300 character(len=LOG_SIZE) :: log_buf
304 call chkp%set_time_state(c%time)
305 do i = 1,
size(c%time%dtlag)
306 call c%fluid%ext_bdf%set_coeffs(
real(c%time%dtlag, kind=
rp))
310 call c%fluid%restart(chkp)
311 if (
allocated(c%scalars))
call c%scalars%restart(chkp)
314 call c%output_controller%set_counter(c%time)
323 type(
case_t),
intent(inout) :: C
324 real(kind=
dp),
intent(inout) :: t
326 character(len=:),
allocatable :: chkp_format
327 character(len=LOG_SIZE) :: log_buf
328 character(len=10) :: format_str
333 call c%chkp%sync_host()
334 if (chkp_format .eq.
'hdf5')
then
339 call chkpf%init(c%output_directory //
'joblimit' // trim(format_str))
340 write(log_buf,
'(A)')
'! saving checkpoint >>>'
343 call chkpf%write(c%chkp, t)
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.
Defines a simulation case.
Defines format-independent checkpoint registration and restart state.
Module for file I/O operations.
logical function, public jobctrl_time_limit()
Check if the job's time limit has been reached.
Utilities for retrieving parameters from the case files.
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.
subroutine, public profiler_start
Start profiling.
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.
subroutine, public profiler_stop
Stop profiling.
Contains the simcomp_executor_t type.
type(simcomp_executor_t), target, public neko_simcomps
Global variable for the simulation component driver.
subroutine, public simulation_step(c, dt_controller, tstep_loop_start_time)
Compute a single time-step of a case.
subroutine simulation_settime(time, ext_bdf)
subroutine, public simulation_finalize(c)
Finalize a simulation of a case.
subroutine case_restart_from_checkpoint(c, chkp)
Restart a case C from a given checkpoint.
subroutine, public simulation_init(c, dt_controller)
Initialise a simulation of a case.
subroutine simulation_joblimit_chkp(c, t)
Write a checkpoint at joblimit.
subroutine case_restart_from_parameters(c)
Restart a case C from a given checkpoint.
Compound scheme for the advection and diffusion operators in a transport equation.
Module with things related to the simulation time.
Implements type time_step_controller.
Collection of live simulation data registered for checkpointing.
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
A struct that contains all info about the time, expand as needed.
Provides a tool to set time step dt.