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** # **The AMUN Code**
## Copyright (C) 2008-2021 Grzegorz Kowal ## 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 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 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 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 :: step, time, dt, dth, dte, dtp, cfl, glm_alpha, registers
public :: atol, rtol, mrej, niterations, nrejections, errs, errtol public :: atol, rtol, mrej, niterations, nrejections, errs, errtol
public :: error_control
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! !

View File

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