DRIVER, EQUATIONS: Separate equation info from initialization.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2019-01-29 15:54:02 -02:00
parent 7a2d694629
commit 2ecdf030d6
2 changed files with 100 additions and 43 deletions

View File

@ -41,6 +41,7 @@ program amun
use boundaries , only : boundary_variables
use coordinates , only : initialize_coordinates, finalize_coordinates
use equations , only : initialize_equations, finalize_equations
use equations , only : print_equations
use evolution , only : initialize_evolution, finalize_evolution
use evolution , only : advance, new_time_step
use evolution , only : step, time, dt
@ -356,6 +357,11 @@ program amun
!
call get_parameter("ndat" , ndat)
! initialize module EQUATIONS
!
call initialize_equations(eqsys, eos, master, iret)
if (iret > 0) go to 360
! initialize the random number generator (passes the number of OpenMP threads
! and the current thread number)
!
@ -371,11 +377,6 @@ program amun
call initialize_problems(problem, master, iret)
if (iret > 0) go to 320
! initialize module EQUATIONS
!
call initialize_equations(eqsys, eos, master, iret)
if (iret > 0) go to 300
! initialize module SOURCES
!
call initialize_sources(master, iret)
@ -432,8 +433,10 @@ program amun
call initialize_operators(master, iret)
if (iret > 0) go to 80
! initialize boundaries module and print info
! print module information
!
call print_equations(master)
if (master) then
write (*,*)
write (*,"(1x,a)" ) "Snapshots:"
@ -751,11 +754,6 @@ program amun
280 continue
call finalize_sources(iret)
! finalize module EQUATIONS
!
300 continue
call finalize_equations(iret)
! finalize module PROBLEMS
!
320 continue
@ -770,6 +768,11 @@ program amun
!
call finalize_random()
! finalize module EQUATIONS
!
360 continue
call finalize_equations(iret)
! finalize I/O module
!
380 continue

View File

@ -133,9 +133,19 @@ module equations
character(len=32), save :: eqsys = "hydrodynamic"
character(len=32), save :: eos = "adiabatic"
! the flag indicating if the set of equations is relativistic
!
logical , save :: relativistic = .false.
! the variable conversion method
!
character(len=32), save :: c2p = "1Dw"
character(len=32), save :: c2p = "1Dw"
! the names of equations and methods
!
character(len=80), save :: name_eqsys = ""
character(len=80), save :: name_eos = ""
character(len=80), save :: name_c2p = ""
! direction indices
!
@ -213,7 +223,7 @@ module equations
! declare public variables and subroutines
!
public :: initialize_equations, finalize_equations
public :: initialize_equations, finalize_equations, print_equations
public :: prim2cons, cons2prim
public :: fluxspeed
public :: maxspeed, reset_maxspeed, get_maxspeed
@ -249,12 +259,14 @@ module equations
!
! Arguments:
!
! system - the equation system
! state - the equation of state
! verbose - a logical flag turning the information printing;
! iret - an integer flag for error return value;
!
!===============================================================================
!
subroutine initialize_equations(teqs, teos, verbose, iret)
subroutine initialize_equations(system, state, verbose, iret)
! include external procedures and variables
!
@ -266,18 +278,14 @@ module equations
! subroutine arguments
!
character(len=32), intent(in) :: teqs, teos
character(len=32), intent(in) :: system, state
logical , intent(in) :: verbose
integer , intent(inout) :: iret
! local variables
!
logical :: relativistic = .false.
integer :: p
character(len=255) :: name_eqsys = ""
character(len=255) :: name_eos = ""
character(len=255) :: name_c2p = ""
character(len=255) :: unphysical_fix = "off"
integer :: p
character(len=32) :: unphysical_fix = "off"
!
!-------------------------------------------------------------------------------
!
@ -298,11 +306,11 @@ module equations
! set the system of equations
!
eqsys = teqs
eqsys = system
! set the equation of state
!
eos = teos
eos = state
! get the primitive variable solver
!
@ -923,26 +931,6 @@ module equations
ngavg = max(1, ngavg)
npavg = max(2, npavg)
! print information about the equation module
!
if (verbose) then
write (*,*)
write (*,"(1x,a)") "Physics:"
write (*,"(4x,a,1x,a)") "equation system =", trim(name_eqsys)
write (*,"(4x,a,1x,a)") "equation of state =", trim(name_eos)
if (relativistic) then
write (*,"(4x,a,1x,a)") "variable conversion =", trim(name_c2p)
end if
write (*,"(4x,a20, 3x,'=',1x,a)") "fix unphysical cells" &
, trim(unphysical_fix)
if (fix_unphysical_cells) then
write (*,"(4x,a20, 3x,'=',1x,i4)") "ngavg ", ngavg
write (*,"(4x,a20, 3x,'=',1x,i4)") "npavg ", npavg
end if
end if
#ifdef PROFILE
! stop accounting time for module initialization/finalization
!
@ -1017,6 +1005,72 @@ module equations
!
!===============================================================================
!
! subroutine PRINT_EQUATIONS:
! --------------------------
!
! Subroutine prints module parameters.
!
! Arguments:
!
! verbose - a logical flag turning the information printing;
!
!===============================================================================
!
subroutine print_equations(verbose)
! include external procedures and variables
!
use parameters, only : get_parameter
! local variables are not implicit by default
!
implicit none
! subroutine arguments
!
logical, intent(in) :: verbose
! local variables
!
character(len=64) :: sfmts, sfmti
!
!-------------------------------------------------------------------------------
!
! print information about the equation module
!
if (verbose) then
write(*,*)
write(*,"(1x,a)") "Physics:"
sfmts = "(4x,a,1x,a)"
write(*,sfmts) "equation system =", trim(name_eqsys)
write(*,sfmts) "equation of state =", trim(name_eos)
sfmti = "(4x,a,1x,i0)"
write(*,sfmti) "number of variables =", nv
write(sfmti,"(a,i0,a)") "(4x,a,", nv, "(1x,a))"
write(*,sfmti) "conservative variables =", cvars
write(*,sfmti) "primitive variables =", pvars
if (relativistic) then
write(*,sfmts) "variable conversion =", trim(name_c2p)
end if
sfmts = "(4x,a20,3x,'=',1x,a)"
if (fix_unphysical_cells) then
write(*,sfmts) "fix unphysical cells", "on"
sfmti = "(4x,a20,3x,'=',1x,i0)"
write(*,sfmti) "ngavg ", ngavg
write(*,sfmti) "npavg ", npavg
else
write(*,sfmts) "fix unphysical cells", "off"
end if
end if
!-------------------------------------------------------------------------------
!
end subroutine print_equations
!
!===============================================================================
!
! subroutine RESET_MAXSPEED:
! -------------------------
!