Skip to content

Commit 112765c

Browse files
committed
clean tester
1 parent e893323 commit 112765c

File tree

1 file changed

+23
-50
lines changed

1 file changed

+23
-50
lines changed

src/tests/tester/foodie_tester.f90

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -255,101 +255,87 @@ subroutine integrate(scheme, integrand_0, Dt, final_time, iterations, stages, is
255255
class(integrator_object), allocatable :: integrator !< The integrator.
256256
type(integrator_runge_kutta_ssp) :: integrator_start !< The (auto) start integrator.
257257
class(integrand_object), allocatable :: integrand !< Integrand.
258-
real(R_P), allocatable :: time(:) !< Time.
259-
real(R_P), allocatable :: Dts(:) !< Time steps.
258+
real(R_P) :: time !< Time.
260259
integer(I_P) :: step !< Time steps counter.
261-
integer(I_P) :: step_offset !< Time steps counter offset for slicing previous data array.
262260

263261
allocate(integrand, mold=integrand_0) ; integrand = integrand_0
264262

265263
call foodie_integrator_factory(scheme=scheme, integrator=integrator, stages=stages, &
266264
tolerance=1e2_R_P, iterations=iterations, autoupdate=.true., U=integrand_0)
267265
if (is_fast) call check_scheme_has_fast_mode(scheme=trim(adjustl(scheme)), integrator=integrator)
268266

269-
if (integrator%is_multistep()) then
270-
call integrator_start%initialize(scheme='runge_kutta_ssp_stages_5_order_4', U=integrand_0)
271-
if (integrator%steps_number()==0) then
272-
step_offset = 1 ! for 0 step-(a convention)-solver offset is 1
273-
else
274-
step_offset = integrator%steps_number() ! for >0 step-solver offset is steps
275-
endif
276-
allocate(Dts(1:step_offset))
277-
Dts = Dt
278-
else
279-
step_offset = 1 ! for 0 step-(a convention)-solver offset is 1
280-
endif
281-
allocate(time(0:step_offset))
267+
if (integrator%is_multistep()) call integrator_start%initialize(scheme='runge_kutta_ssp_stages_5_order_4', U=integrand_0)
282268

283269
step = 0
284270
time = 0._R_P
285271
select type(integrand)
286272
type is(integrand_ladvection)
287-
if (save_results) call integrand%export_tecplot(file_name=output_file_name, t=time(0), scheme=scheme)
273+
if (save_results) call integrand%export_tecplot(file_name=output_file_name, t=time, scheme=scheme)
288274
type is(integrand_oscillation)
289-
if (save_results) call integrand%export_tecplot(file_name=output_file_name, t=time(0), scheme=scheme)
275+
if (save_results) call integrand%export_tecplot(file_name=output_file_name, t=time, scheme=scheme)
290276
endselect
291277

292278
select type(integrator)
293279
class is(integrator_multistage_object)
294280
do
295281
step = step + 1
296282
if (is_fast) then
297-
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time(step_offset))
283+
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time)
298284
else
299-
call integrator%integrate(U=integrand, Dt=Dt, t=time(step_offset))
285+
call integrator%integrate(U=integrand, Dt=Dt, t=time)
300286
endif
301-
call update_previous_times
302-
if ((time(step_offset) >= final_time)) exit
287+
time = time + Dt
288+
if ((time >= final_time)) exit
303289
call integrand_export_tecplot
304290
enddo
305291

306292
class is(integrator_multistep_object)
307293
do
308294
step = step + 1
309295
if (integrator%steps_number() >= step) then
310-
call integrator_start%integrate(U=integrand, Dt=Dt, t=time(step))
296+
call integrator_start%integrate(U=integrand, Dt=Dt, t=time)
311297
integrator%previous(step) = integrand
312-
time(step) = time(step-1) + Dt
298+
time = time + Dt
313299
integrator%Dt(step) = Dt
314-
integrator%t(step) = time(step)
300+
integrator%t(step) = time
315301
else
316302
if (is_fast) then
317-
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time(step_offset))
303+
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time)
318304
else
319-
call integrator%integrate(U=integrand, Dt=Dt, t=time(step_offset))
305+
call integrator%integrate(U=integrand, Dt=Dt, t=time)
320306
endif
321-
call update_previous_times
307+
time = time + Dt
322308
endif
323-
if ((time(step_offset) >= final_time)) exit
309+
if ((time >= final_time)) exit
324310
call integrand_export_tecplot
325311
enddo
326312

327313
! type is(integrator_ms_runge_kutta_ssp)
328314
! do
329315
! step = step + 1
330316
! if (integrator%steps_number() >= step) then
331-
! call integrator_start%integrate(U=integrand, Dt=Dt, t=time(step))
317+
! call integrator_start%integrate(U=integrand, Dt=Dt, t=time)
332318
! previous(step) = integrand
333-
! time(step) = time(step-1) + Dt
319+
! time = time + Dt
334320
! else
335321
! if (is_fast) then
336322
! call integrator%integrate_fast(U=integrand, previous=previous, stage=stage, buffer=buffer, Dt=Dt,t=time)
337323
! else
338324
! call integrator%integrate(U=integrand, previous=previous, stage=stage, Dt=Dt, t=time)
339325
! endif
340-
! call update_previous_times
326+
! time = time + Dt
341327
! endif
342-
! if ((time(step) >= final_time)) exit
328+
! if ((time >= final_time)) exit
343329
! call integrand_export_tecplot
344330
! enddo
345331
endselect
346332

347333
select type(integrand)
348334
type is(integrand_ladvection)
349-
if (save_results) call integrand%export_tecplot(t=time(step_offset), scheme=scheme)
335+
if (save_results) call integrand%export_tecplot(t=time, scheme=scheme)
350336
if (save_results) call integrand%export_tecplot(close_file=.true.)
351337
type is(integrand_oscillation)
352-
if (save_results) call integrand%export_tecplot(t=time(step_offset))
338+
if (save_results) call integrand%export_tecplot(t=time)
353339
if (save_results) call integrand%export_tecplot(close_file=.true.)
354340
endselect
355341
contains
@@ -358,24 +344,11 @@ subroutine integrand_export_tecplot
358344

359345
select type(integrand)
360346
type is(integrand_ladvection)
361-
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time(step_offset), scheme=scheme)
347+
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time, scheme=scheme)
362348
type is(integrand_oscillation)
363-
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time(step_offset))
349+
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time)
364350
endselect
365351
endsubroutine integrand_export_tecplot
366-
367-
subroutine update_previous_times
368-
!< Update previous times.
369-
real(R_P) :: temporary !< Temporary buffer.
370-
integer(I_P) :: p !< Counter.
371-
372-
temporary = time(step_offset)
373-
time(step_offset) = time(step_offset) + Dt
374-
do p=0, step_offset - 2
375-
time(p) = time(p + 1)
376-
enddo
377-
time(step_offset-1) = temporary
378-
endsubroutine update_previous_times
379352
endsubroutine integrate
380353
endmodule foodie_test_object
381354

0 commit comments

Comments
 (0)