44submodule(simulation_checkpoint) checkpoint_linear
45 use simulation,
only: simulation_step, simulation_restart
46 use file,
only: file_t, file_free
47 use time_step_controller,
only: time_step_controller_t
54 module subroutine checkpoint_save_linear(this, neko_case)
55 class(simulation_checkpoint_t),
intent(inout) :: this
56 class(case_t),
intent(inout) :: neko_case
60 save_disc = modulo(neko_case%time%tstep, this%n_saves_memory) .eq. 0
63 if (save_disc .or. neko_case%time%tstep .le. this%first_valid_timestep)
then
65 call this%chkp_output%set_counter(neko_case%time%tstep)
66 call this%chkp_output%sample(neko_case%time%t)
67 this%n_saves_disc = this%n_saves_disc + 1
69 end subroutine checkpoint_save_linear
75 module subroutine checkpoint_restore_linear(this, neko_case, tstep)
76 class(simulation_checkpoint_t),
intent(inout) :: this
77 class(case_t),
target,
intent(inout) :: neko_case
78 integer,
intent(in) :: tstep
79 type(time_step_controller_t) :: dt_controller
80 real(kind=dp) :: loop_start
81 integer :: j, k, previous_save, next_save
83 type(field_t),
pointer :: u, v, w, p, s
85 loop_start = mpi_wtime()
87 u => neko_case%fluid%u
88 v => neko_case%fluid%v
89 w => neko_case%fluid%w
90 p => neko_case%fluid%p
94 previous_save = tstep - modulo(tstep, this%n_saves_memory)
95 next_save = previous_save + this%n_saves_memory
99 if (tstep .lt. this%first_valid_timestep)
then
100 previous_save = tstep
101 next_save = previous_save + 1
102 else if (previous_save .lt. this%first_valid_timestep)
then
103 previous_save = this%first_valid_timestep
107 if (this%loaded_checkpoint .ne. previous_save)
then
110 call this%chkp_output%set_counter(previous_save)
111 call this%chkp_output%file_%read(neko_case%chkp)
112 call simulation_restart(neko_case, neko_case%chkp)
115 call dt_controller%init(neko_case%params)
116 neko_case%time%tstep = previous_save
117 this%loaded_checkpoint = neko_case%time%tstep
120 do k = previous_save, min(next_save - 1, this%n_timesteps)
123 if (k .ne. previous_save)
then
124 if (neko_case%time%t .ge. neko_case%time%end_time)
exit
125 call simulation_step(neko_case, dt_controller, loop_start)
128 local_idx = modulo(k, this%n_saves_memory) + 1
129 call field_copy(this%p_list(local_idx), p)
130 call field_copy(this%u_list(local_idx), u)
131 call field_copy(this%v_list(local_idx), v)
132 call field_copy(this%w_list(local_idx), w)
133 do i_scalars = 1, this%n_scalars
134 j = (local_idx - 1) * this%n_scalars + i_scalars
135 s => neko_case%scalars%scalar_fields(i_scalars)%s
136 call field_copy(this%s_list(j), s)
142 local_idx = modulo(tstep, this%n_saves_memory) + 1
143 call field_copy(p, this%p_list(local_idx))
144 call field_copy(u, this%u_list(local_idx))
145 call field_copy(v, this%v_list(local_idx))
146 call field_copy(w, this%w_list(local_idx))
147 do i_scalars = 1, this%n_scalars
148 j = (local_idx - 1) * this%n_scalars + i_scalars
149 s => neko_case%scalars%scalar_fields(i_scalars)%s
150 call field_copy(s, this%s_list(j))
154 end subroutine checkpoint_restore_linear
156end submodule checkpoint_linear