Merge branch 'master' into reconnection

This commit is contained in:
Grzegorz Kowal 2021-11-10 22:51:33 -03:00
commit fd72185248
3 changed files with 62 additions and 79 deletions

View File

@ -2,6 +2,8 @@
# **The AMUN Code**
## Copyright (C) 2008-2021 Grzegorz Kowal
[![Build Status](https://ampere-orbis.nsupdate.info/api/badges/gkowal/amun-code/status.svg)](https://ampere-orbis.nsupdate.info/gkowal/amun-code)
AMUN is a parallel code to perform numerical simulations in fluid approximation
on uniform or non-uniform (adaptive) meshes. The goal in developing this code is
to create a solid framework for simulations with support for number of numerical

View File

@ -131,6 +131,7 @@ module evolution
!
public :: step, time, dt, dth, dte, dtp, cfl, glm_alpha, registers
public :: atol, rtol, mrej, niterations, nrejections, errs, errtol
public :: error_control
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!

View File

@ -106,6 +106,7 @@ module integrals
! import external variables and subroutines
!
use equations , only : pvars, nf
use evolution , only : error_control
use parameters, only : get_parameter
! local variables are not implicit by default
@ -164,7 +165,7 @@ module integrals
select case(trim(append))
case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES")
write(fname, "('integrals.dat')")
inquire(file = fname, exist = flag)
inquire(file=fname, exist=flag)
case default
write(fname, "('integrals_',i2.2,'.dat')") irun
flag = .false.
@ -174,20 +175,19 @@ module integrals
!
if (flag .and. irun > 1) then
#ifdef __INTEL_COMPILER
open(newunit = funit, file = fname, form = 'formatted', status = 'old' &
, position = 'append', buffered = 'yes')
open(newunit=funit, file=fname, form='formatted', status='old', &
position='append', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = funit, file = fname, form = 'formatted', status = 'old' &
, position = 'append')
open(newunit=funit, file=fname, form='formatted', status='old', &
position='append')
#endif /* __INTEL_COMPILER */
write(funit,"('#')")
else
#ifdef __INTEL_COMPILER
open(newunit = funit, file = fname, form = 'formatted' &
, status = 'replace', buffered = 'yes')
open(newunit=funit, file=fname, form='formatted', &
status='replace', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = funit, file = fname, form = 'formatted' &
, status = 'replace')
open(newunit=funit, file=fname, form='formatted', status='replace')
#endif /* __INTEL_COMPILER */
end if
@ -207,7 +207,7 @@ module integrals
select case(trim(append))
case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES")
write(fname, "('statistics.dat')")
inquire(file = fname, exist = flag)
inquire(file=fname, exist=flag)
case default
write(fname, "('statistics_',i2.2,'.dat')") irun
flag = .false.
@ -217,20 +217,19 @@ module integrals
!
if (flag .and. irun > 1) then
#ifdef __INTEL_COMPILER
open(newunit = sunit, file = fname, form = 'formatted', status = 'old' &
, position = 'append', buffered = 'yes')
open(newunit=sunit, file=fname, form='formatted', status='old', &
position='append', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = sunit, file = fname, form = 'formatted', status = 'old' &
, position = 'append')
open(newunit=sunit, file=fname, form='formatted', status='old', &
position='append')
#endif /* __INTEL_COMPILER */
write(sunit,"('#')")
else
#ifdef __INTEL_COMPILER
open(newunit = sunit, file = fname, form = 'formatted' &
, status = 'replace', buffered = 'yes')
open(newunit=sunit, file=fname, form='formatted', &
status='replace', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = sunit, file = fname, form = 'formatted' &
, status = 'replace')
open(newunit=sunit, file=fname, form='formatted', status='replace')
#endif /* __INTEL_COMPILER */
end if
@ -249,49 +248,52 @@ module integrals
! depending on the append parameter, choose the right file initialization for
! the file to store integration errors
!
append = "off"
call get_parameter("errors_append", append)
select case(trim(append))
case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES")
write(fname, "('errors.dat')")
inquire(file = fname, exist = flag)
case default
write(fname, "('errors_',i2.2,'.dat')") irun
flag = .false.
end select
if (error_control) then
append = "off"
call get_parameter("errors_append", append)
select case(trim(append))
case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES")
write(fname, "('errors.dat')")
inquire(file=fname, exist=flag)
case default
write(fname, "('errors_',i2.2,'.dat')") irun
flag = .false.
end select
! check if the file exists; if not, create a new one, otherwise move to the end
!
if (flag .and. irun > 1) then
if (flag .and. irun > 1) then
#ifdef __INTEL_COMPILER
open(newunit = eunit, file = fname, form = 'formatted', status = 'old' &
, position = 'append', buffered = 'yes')
open(newunit=eunit, file=fname, form='formatted', status='old', &
position='append', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = eunit, file = fname, form = 'formatted', status = 'old' &
, position = 'append')
open(newunit=eunit, file=fname, form='formatted', status='old', &
position='append')
#endif /* __INTEL_COMPILER */
write(funit,"('#')")
else
write(funit,"('#')")
else
#ifdef __INTEL_COMPILER
open(newunit = eunit, file = fname, form = 'formatted' &
, status = 'replace', buffered = 'yes')
open(newunit=eunit, file=fname, form='formatted', &
status='replace', buffered='yes')
#else /* __INTEL_COMPILER */
open(newunit = eunit, file = fname, form = 'formatted' &
, status = 'replace')
open(newunit=eunit, file=fname, form='formatted', status='replace')
#endif /* __INTEL_COMPILER */
end if
end if
! write the integral file header
!
write(stmp,"(i9)") nf + 4
efmt = "('#',a8," // trim(adjustl(stmp)) // "(1x,a18))"
write(eunit,efmt) 'step', 'time', 'dt_cfl', 'dt_err', &
'max_err', pvars(1:nf)
write(eunit,"('#')")
write(stmp,"(i9)") nf + 4
efmt = "('#',a8," // trim(adjustl(stmp)) // "(1x,a18))"
write(eunit,efmt) 'step', 'time', 'dt_cfl', 'dt_err', &
'max_err', pvars(1:nf)
write(eunit,"('#')")
! prepare format for errors
!
efmt = "(i9," // trim(adjustl(stmp)) // "(1x,1es18.8e3))"
efmt = "(i9," // trim(adjustl(stmp)) // "(1x,1es18.8e3))"
end if ! error_control
end if ! store
@ -320,24 +322,18 @@ module integrals
!
subroutine finalize_integrals(status)
! local variables are not implicit by default
!
use evolution, only : error_control
implicit none
! subroutine arguments
!
integer, intent(out) :: status
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for module initialization/finalization
!
call start_timer(imi)
#endif /* PROFILE */
! reset the status flag
!
status = 0
! close the integrals and statistics files
@ -345,12 +341,10 @@ module integrals
if (stored) then
close(funit)
close(sunit)
close(eunit)
if (error_control) close(eunit)
end if
#ifdef PROFILE
! stop accounting time for module initialization/finalization
!
call stop_timer(imi)
#endif /* PROFILE */
@ -371,8 +365,6 @@ module integrals
!
subroutine store_integrals()
! import external variables and subroutines
!
use blocks , only : block_meta, block_data, list_data
use coordinates , only : ni => ncells, nb, ne
use coordinates , only : advol, voli
@ -380,6 +372,7 @@ module integrals
use equations , only : ien, imx, imy, imz
use equations , only : magnetized, adiabatic_index, csnd
use equations , only : errors
use evolution , only : error_control
use evolution , only : step, time, dt, dth, dte
use forcing , only : einj, rinj, arms
use helpers , only : flush_and_sync
@ -387,24 +380,14 @@ module integrals
use mpitools , only : reduce_minimum, reduce_maximum, reduce_sum
#endif /* MPI */
! local variables are not implicit by default
!
implicit none
! local variables
!
real(kind=8) :: dvol, dvolh
! local pointers
!
type(block_data), pointer :: pdata
! local parameters
!
integer, parameter :: narr = 16
! local arrays
!
real(kind=8), dimension(narr) :: inarr, avarr, mnarr, mxarr
#if NDIMS == 3
real(kind=8), dimension(ni,ni,ni) :: vel, mag, sqd, tmp
@ -412,11 +395,9 @@ module integrals
real(kind=8), dimension(ni,ni, 1) :: vel, mag, sqd, tmp
#endif /* NDIMS == 3 */
! parameters
!
real(kind=8), parameter :: eps = epsilon(1.0d+00)
real(kind=8), parameter :: big = huge(1.0d+00)
!
!-------------------------------------------------------------------------------
!
! return if the storage interval was not reached
@ -424,8 +405,6 @@ module integrals
if (mod(step, iintd) > 0) return
#ifdef PROFILE
! start accounting time for the integrals storing
!
call start_timer(ims)
#endif /* PROFILE */
@ -650,16 +629,17 @@ module integrals
, avarr(5), mnarr(5), mxarr(5) &
, avarr(6), mnarr(6), mxarr(6) &
, avarr(7), mnarr(7), mxarr(7)
write(eunit,efmt) step, time, dth, dte, maxval(errors(:)), errors(:)
call flush_and_sync(funit)
call flush_and_sync(sunit)
call flush_and_sync(eunit)
if (error_control) then
write(eunit,efmt) step, time, dth, dte, maxval(errors(:)), errors(:)
call flush_and_sync(eunit)
end if
end if
#ifdef PROFILE
! stop accounting time for the integrals storing
!
call stop_timer(ims)
#endif /* PROFILE */