DRIVER: Reorganize the initialization/finalization of modules.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2019-01-29 18:13:24 -02:00
parent 099d077ab9
commit 6c23e9af19

View File

@ -215,7 +215,7 @@ program amun
! !
if (iret > 0) then if (iret > 0) then
call stop_timer(iin) call stop_timer(iin)
go to 500 go to 400
end if end if
! print the welcome message ! print the welcome message
@ -256,7 +256,7 @@ program amun
if (master) then if (master) then
write(error_unit,"('[AMUN::program]: ', a)") "Problem reading parameters!" write(error_unit,"('[AMUN::program]: ', a)") "Problem reading parameters!"
end if end if
go to 400 go to 300
end if end if
#ifdef MPI #ifdef MPI
@ -275,14 +275,14 @@ program amun
write(error_unit,"('[AMUN::program]: ', a)") & write(error_unit,"('[AMUN::program]: ', a)") &
"Problem broadcasting parameters!" "Problem broadcasting parameters!"
end if end if
go to 400 go to 300
end if end if
#endif /* MPI */ #endif /* MPI */
! initialize IO to handle restart snapshots if necessary ! initialize IO to handle restart snapshots if necessary
! !
call initialize_io(master, iret) call initialize_io(master, iret)
if (iret > 0) go to 380 if (iret > 0) go to 200
! get the run number ! get the run number
! !
@ -364,55 +364,42 @@ program amun
! initialize the remaining modules ! initialize the remaining modules
! !
call initialize_random(1, 0) call initialize_random(1, 0)
if (iret > 0) go to 190
call initialize_equations(eqsys, eos, master, iret) call initialize_equations(eqsys, eos, master, iret)
if (iret > 0) go to 360 if (iret > 0) go to 180
call initialize_coordinates(ncells, nghosts, toplev, bdims, xmin, xmax, & call initialize_coordinates(ncells, nghosts, toplev, bdims, xmin, xmax, &
ymin, ymax, zmin, zmax, master, iret) ymin, ymax, zmin, zmax, master, iret)
if (iret > 0) go to 340 if (iret > 0) go to 170
call initialize_blocks((/ nv, nv, im, jm, km /), master, iret) call initialize_blocks((/ nv, nv, im, jm, km /), master, iret)
if (iret > 0) go to 320
call initialize_operators(master, iret)
if (iret > 0) go to 300
call initialize_sources(master, iret)
if (iret > 0) go to 280
call initialize_user_problem(problem, master, iret)
if (iret > 0) go to 260
call initialize_problems(problem, master, iret)
if (iret > 0) go to 240
call initialize_domains(problem, master, iret)
if (iret > 0) go to 220
call initialize_refinement(master, iret)
if (iret > 0) go to 200
! initialize module GRAVITY
!
call initialize_gravity(master, iret)
if (iret > 0) go to 260
! initialize boundaries
!
call initialize_boundaries(master, iret)
if (iret > 0) go to 200
! initialize module SHAPES
!
call initialize_shapes(master, iret)
if (iret > 0) go to 160 if (iret > 0) go to 160
call initialize_operators(master, iret)
! initialize evolution if (iret > 0) go to 150
! call initialize_sources(master, iret)
call initialize_evolution(master, iret)
if (iret > 0) go to 140 if (iret > 0) go to 140
call initialize_user_problem(problem, master, iret)
! initialize module SCHEMES if (iret > 0) go to 130
! call initialize_problems(problem, master, iret)
call initialize_schemes(master, iret)
if (iret > 0) go to 120 if (iret > 0) go to 120
call initialize_domains(problem, master, iret)
! initialize module INTERPOLATIONS if (iret > 0) go to 110
! call initialize_boundaries(master, iret)
call initialize_interpolations(master, iret)
if (iret > 0) go to 100 if (iret > 0) go to 100
call initialize_refinement(master, iret)
if (iret > 0) go to 90
call initialize_mesh(nrun, master, iret)
if (iret > 0) go to 80
call initialize_shapes(master, iret)
if (iret > 0) go to 70
call initialize_gravity(master, iret)
if (iret > 0) go to 60
call initialize_interpolations(master, iret)
if (iret > 0) go to 50
call initialize_schemes(master, iret)
if (iret > 0) go to 40
call initialize_evolution(master, iret)
if (iret > 0) go to 30
call initialize_integrals(master, nrun, iret)
if (iret > 0) go to 20
! print module information ! print module information
! !
@ -430,11 +417,6 @@ program amun
! !
if (restart_from_snapshot()) then if (restart_from_snapshot()) then
! initialize the mesh module
!
call initialize_mesh(nrun, master, iret)
if (iret > 0) go to 40
! reconstruct the meta and data block structures from a given restart file ! reconstruct the meta and data block structures from a given restart file
! !
call read_restart_snapshot(iterm) call read_restart_snapshot(iterm)
@ -447,7 +429,7 @@ program amun
! quit if there was a problem with reading restart snapshots ! quit if there was a problem with reading restart snapshots
! !
if (iterm > 0) go to 40 if (iterm > 0) go to 10
! update the list of leafs ! update the list of leafs
! !
@ -455,11 +437,6 @@ program amun
else else
! initialize the mesh module
!
call initialize_mesh(nrun, master, iret)
if (iret > 0) go to 40
! generate the initial mesh, refine that mesh to the desired level according to ! generate the initial mesh, refine that mesh to the desired level according to
! the initialized problem ! the initialized problem
! !
@ -475,11 +452,6 @@ program amun
end if end if
! initialize the integrals module
!
call initialize_integrals(master, nrun, iret)
if (iret > 0) go to 20
! store mesh statistics ! store mesh statistics
! !
call store_mesh_stats(step, time) call store_mesh_stats(step, time)
@ -671,66 +643,45 @@ program amun
! !
call start_timer(itm) call start_timer(itm)
! finalize integrals module ! finalize modules
! !
20 continue 20 continue
call finalize_integrals() call finalize_integrals()
30 continue
! finalize the mesh module
!
40 continue
call finalize_mesh(iret)
! finalize module INTERPOLATIONS
!
100 continue
call finalize_interpolations(iret)
! finalize module SCHEMES
!
120 continue
call finalize_schemes(iret)
! finalize module EVOLUTION
!
140 continue
call finalize_evolution(iret) call finalize_evolution(iret)
40 continue
! finalize module SHAPES call finalize_schemes(iret)
! 50 continue
160 continue call finalize_interpolations(iret)
call finalize_shapes(iret) 60 continue
! finalize module BOUNDARIES
!
call finalize_boundaries(iret)
! finalize module GRAVITY
!
call finalize_gravity(iret) call finalize_gravity(iret)
70 continue
! finalize modules call finalize_shapes(iret)
! 80 continue
200 continue call finalize_mesh(iret)
90 continue
call finalize_refinement(iret) call finalize_refinement(iret)
220 continue 100 continue
call finalize_boundaries(iret)
110 continue
call finalize_domains(iret) call finalize_domains(iret)
240 continue 120 continue
call finalize_problems(iret) call finalize_problems(iret)
260 continue 130 continue
call finalize_user_problem(iret) call finalize_user_problem(iret)
280 continue 140 continue
call finalize_sources(iret) call finalize_sources(iret)
300 continue 150 continue
call finalize_operators(iret) call finalize_operators(iret)
320 continue 160 continue
call finalize_blocks(iret) call finalize_blocks(iret)
340 continue 170 continue
call finalize_coordinates(iret) call finalize_coordinates(iret)
360 continue 180 continue
call finalize_equations(iret) call finalize_equations(iret)
190 continue
call finalize_random() call finalize_random()
380 continue 200 continue
call finalize_io(iret) call finalize_io(iret)
! stop time accounting for the termination ! stop time accounting for the termination
@ -806,12 +757,12 @@ program amun
! finalize modules PARAMETERS ! finalize modules PARAMETERS
! !
400 continue 300 continue
call finalize_parameters() call finalize_parameters()
! finalize module MPITOOLS ! finalize module MPITOOLS
! !
500 continue 400 continue
call finalize_mpitools() call finalize_mpitools()
! finalize module TIMERS ! finalize module TIMERS