DRIVER, PROBLEMS, IO: Initiate problems earlier.

Also store the problem name in the restart snapshot.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2019-01-29 09:59:09 -02:00
parent 2ae8cd14f1
commit 4aa92643ab
4 changed files with 60 additions and 57 deletions

View File

@ -89,6 +89,7 @@ program amun
! default parameters ! default parameters
! !
character(len=64) :: problem = "none"
character(len=32) :: eqsys = "hydrodynamic" character(len=32) :: eqsys = "hydrodynamic"
character(len=32) :: eos = "adiabatic" character(len=32) :: eos = "adiabatic"
integer :: toplev = 1 integer :: toplev = 1
@ -280,13 +281,15 @@ program amun
! the restart snapshot, otherwise, read them from the parameter file ! the restart snapshot, otherwise, read them from the parameter file
! !
if (job_restart) then if (job_restart) then
call read_snapshot_parameter("problem", problem, iret)
call read_snapshot_parameter("eqsys" , eqsys , iret) call read_snapshot_parameter("eqsys" , eqsys , iret)
call read_snapshot_parameter("eos" , eos , iret) call read_snapshot_parameter("eos" , eos , iret)
call read_snapshot_parameter("maxlev", toplev, iret) call read_snapshot_parameter("maxlev" , toplev , iret)
else else
call get_parameter("problem" , problem)
call get_parameter("equation_system" , eqsys ) call get_parameter("equation_system" , eqsys )
call get_parameter("equation_of_state", eos ) call get_parameter("equation_of_state", eos )
call get_parameter("maxlev" , toplev) call get_parameter("maxlev" , toplev )
end if end if
! get the execution termination parameters ! get the execution termination parameters
@ -326,6 +329,16 @@ program amun
! !
call initialize_random(1, 0) call initialize_random(1, 0)
! initialize module USER_PROBLEM
!
call initialize_user_problem(problem, master, iret)
if (iret > 0) go to 340
! initialize module PROBLEMS
!
call initialize_problems(problem, master, iret)
if (iret > 0) go to 320
! initialize module EQUATIONS ! initialize module EQUATIONS
! !
call initialize_equations(eqsys, eos, master, iret) call initialize_equations(eqsys, eos, master, iret)
@ -350,17 +363,6 @@ program amun
! !
if (iret > 0) go to 60 if (iret > 0) go to 60
! print information about the problem
!
if (master) then
write (*,*)
write (*,"(1x,a)" ) "Problem:"
end if
! initialize module USER_PROBLEM
!
call initialize_user_problem(master, iret)
! initialize refinement module and print info ! initialize refinement module and print info
! !
if (master) then if (master) then
@ -422,10 +424,6 @@ program amun
! !
call initialize_boundaries(master, iret) call initialize_boundaries(master, iret)
! initialize module PROBLEMS
!
call initialize_problems(master, iret)
! initialize module SHAPES ! initialize module SHAPES
! !
call initialize_shapes(master, iret) call initialize_shapes(master, iret)
@ -723,10 +721,6 @@ program amun
! !
call finalize_io(iret) call finalize_io(iret)
! finalize module PROBLEMS
!
call finalize_problems(iret)
! finalize module SOURCES ! finalize module SOURCES
! !
call finalize_sources(iret) call finalize_sources(iret)
@ -755,10 +749,6 @@ program amun
! !
call finalize_random() call finalize_random()
! finalize the user problem module
!
call finalize_user_problem(iret)
! finalize module OPERATORS ! finalize module OPERATORS
! !
call finalize_operators(iret) call finalize_operators(iret)
@ -808,6 +798,16 @@ program amun
300 continue 300 continue
call finalize_equations(iret) call finalize_equations(iret)
! finalize module PROBLEMS
!
320 continue
call finalize_problems(iret)
! finalize module USER_PROBLEMS
!
340 continue
call finalize_user_problem(iret)
! stop time accounting for the termination ! stop time accounting for the termination
! !
call stop_timer(itm) call stop_timer(itm)

View File

@ -1640,6 +1640,7 @@ module io
use hdf5 , only : h5gcreate_f, h5gclose_f use hdf5 , only : h5gcreate_f, h5gclose_f
use iso_fortran_env, only : error_unit use iso_fortran_env, only : error_unit
use mpitools , only : nprocs, nproc use mpitools , only : nprocs, nproc
use problems , only : problem_name
use random , only : nseeds, get_seeds use random , only : nseeds, get_seeds
! local variables are not implicit by default ! local variables are not implicit by default
@ -1699,6 +1700,7 @@ module io
! store string attributes ! store string attributes
! !
call write_attribute(gid, 'problem', problem_name )
call write_attribute(gid, 'eqsys' , eqsys ) call write_attribute(gid, 'eqsys' , eqsys )
call write_attribute(gid, 'eos' , eos ) call write_attribute(gid, 'eos' , eos )

View File

@ -47,6 +47,10 @@ module problems
integer, save :: imi, imu integer, save :: imi, imu
#endif /* PROFILE */ #endif /* PROFILE */
! problem name
!
character(len=64), save :: problem_name = "none"
! interfaces for procedure pointers ! interfaces for procedure pointers
! !
abstract interface abstract interface
@ -68,6 +72,7 @@ module problems
! !
public :: initialize_problems, finalize_problems public :: initialize_problems, finalize_problems
public :: setup_problem public :: setup_problem
public :: problem_name
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! !
@ -88,12 +93,13 @@ module problems
! !
! Arguments: ! Arguments:
! !
! problem - the problem name
! verbose - a logical flag turning the information printing; ! verbose - a logical flag turning the information printing;
! iret - an integer flag for error return value; ! iret - an integer flag for error return value;
! !
!=============================================================================== !===============================================================================
! !
subroutine initialize_problems(verbose, iret) subroutine initialize_problems(problem, verbose, iret)
! include external procedures and variables ! include external procedures and variables
! !
@ -106,12 +112,9 @@ module problems
! subroutine arguments ! subroutine arguments
! !
logical, intent(in) :: verbose character(len=64), intent(in) :: problem
integer, intent(inout) :: iret logical , intent(in) :: verbose
integer , intent(inout) :: iret
! local variables
!
character(len=64) :: problem_name = "blast"
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -126,14 +129,14 @@ module problems
call start_timer(imi) call start_timer(imi)
#endif /* PROFILE */ #endif /* PROFILE */
! get the problem name ! set problem name
! !
call get_parameter("problem", problem_name) problem_name = problem
! associate the setup_problem pointer with the respective problem setup ! associate the setup_problem pointer with the respective problem setup
! subroutine ! subroutine
! !
select case(trim(problem_name)) select case(trim(problem))
! general test problems ! general test problems
! !

View File

@ -66,12 +66,13 @@ module user_problem
! !
! Arguments: ! Arguments:
! !
! problem - the problem name
! verbose - a logical flag turning the information printing; ! verbose - a logical flag turning the information printing;
! iret - an integer flag for error return value; ! iret - an integer flag for error return value;
! !
!=============================================================================== !===============================================================================
! !
subroutine initialize_user_problem(verbose, iret) subroutine initialize_user_problem(problem, verbose, iret)
! include external procedures and variables ! include external procedures and variables
! !
@ -83,12 +84,9 @@ module user_problem
! subroutine arguments ! subroutine arguments
! !
logical, intent(in) :: verbose character(len=64), intent(in) :: problem
integer, intent(inout) :: iret logical , intent(in) :: verbose
integer , intent(inout) :: iret
! local variables
!
character(len=64) :: problem_name = "none"
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -107,16 +105,16 @@ module user_problem
call start_timer(imi) call start_timer(imi)
#endif /* PROFILE */ #endif /* PROFILE */
! get the problem name
!
call get_parameter("problem", problem_name)
! print information about the user problem such as problem name, its ! print information about the user problem such as problem name, its
! parameters, etc. ! parameters, etc.
! !
if (verbose) then if (verbose) then
write (*,"(4x,a14, 9x,'=',2x,a)") "problem name ", trim(problem_name) ! print information about the problem
!
write (*,*)
write (*,"(1x,a)") "Problem:"
write (*,"(4x,a12,11x,'=',1x,a)") "problem name", trim(problem)
end if end if