2010-10-06 23:03:47 -03:00
|
|
|
!!******************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This file is part of the AMUN source code, a program to perform
|
|
|
|
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
|
|
|
!! adaptive mesh.
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2018-01-04 12:13:09 -02:00
|
|
|
!! Copyright (C) 2008-2018 Grzegorz Kowal <grzegorz@amuncode.org>
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This program is free software: you can redistribute it and/or modify
|
|
|
|
!! it under the terms of the GNU General Public License as published by
|
|
|
|
!! the Free Software Foundation, either version 3 of the License, or
|
|
|
|
!! (at your option) any later version.
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2011-04-29 11:21:30 -03:00
|
|
|
!! This program is distributed in the hope that it will be useful,
|
2008-11-04 13:08:01 -06:00
|
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
!! GNU General Public License for more details.
|
|
|
|
!!
|
|
|
|
!! You should have received a copy of the GNU General Public License
|
2012-07-22 12:30:20 -03:00
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2010-10-06 23:03:47 -03:00
|
|
|
!!******************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! program: AMUN
|
|
|
|
!!
|
2012-07-28 12:24:12 -03:00
|
|
|
!! AMUN is a code to perform numerical simulations in a fluid approximation on
|
|
|
|
!! adaptive mesh for Newtonian and relativistic environments with or without
|
|
|
|
!! magnetic field.
|
|
|
|
!!
|
2012-07-28 13:48:15 -03:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!!******************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2011-04-25 13:44:34 -03:00
|
|
|
program amun
|
2008-11-04 13:08:01 -06:00
|
|
|
|
2012-07-28 12:24:12 -03:00
|
|
|
! include external subroutines used in this module
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2012-07-22 22:47:25 -03:00
|
|
|
use blocks , only : initialize_blocks, finalize_blocks, get_nleafs
|
2015-12-18 06:55:32 -02:00
|
|
|
use blocks , only : build_leaf_list
|
2014-01-02 17:18:42 -02:00
|
|
|
use boundaries , only : initialize_boundaries, finalize_boundaries
|
2014-06-11 23:06:28 -03:00
|
|
|
use boundaries , only : boundary_variables
|
2012-07-28 12:24:12 -03:00
|
|
|
use coordinates , only : initialize_coordinates, finalize_coordinates
|
2013-12-10 20:56:37 -02:00
|
|
|
use equations , only : initialize_equations, finalize_equations
|
2013-12-11 10:59:25 -02:00
|
|
|
use evolution , only : initialize_evolution, finalize_evolution
|
2013-12-11 22:48:48 -02:00
|
|
|
use evolution , only : advance, new_time_step
|
2014-01-08 17:34:15 -02:00
|
|
|
use evolution , only : step, time, dt
|
2017-03-03 18:15:15 -03:00
|
|
|
use gravity , only : initialize_gravity, finalize_gravity
|
2014-01-10 12:42:18 -02:00
|
|
|
use integrals , only : initialize_integrals, finalize_integrals
|
|
|
|
use integrals , only : store_integrals
|
2013-12-11 22:34:29 -02:00
|
|
|
use interpolations, only : initialize_interpolations, finalize_interpolations
|
2017-09-05 09:53:47 -03:00
|
|
|
use io , only : initialize_io, finalize_io
|
2014-01-09 11:22:23 -02:00
|
|
|
use io , only : restart_from_snapshot
|
2014-01-09 09:29:22 -02:00
|
|
|
use io , only : read_restart_snapshot, write_restart_snapshot
|
|
|
|
use io , only : write_snapshot, next_tout
|
2013-12-26 19:51:26 -02:00
|
|
|
use mesh , only : initialize_mesh, finalize_mesh
|
2012-07-27 10:34:19 -03:00
|
|
|
use mesh , only : generate_mesh, store_mesh_stats
|
2013-12-11 17:29:15 -02:00
|
|
|
use mpitools , only : initialize_mpitools, finalize_mpitools
|
|
|
|
use mpitools , only : setup_mpi
|
2012-07-22 19:01:27 -03:00
|
|
|
#ifdef MPI
|
2012-07-22 19:32:21 -03:00
|
|
|
use mpitools , only : bcast_integer_variable
|
2014-01-06 11:37:27 -02:00
|
|
|
use mpitools , only : reduce_maximum_integer, reduce_sum_real_array
|
2012-07-22 19:01:27 -03:00
|
|
|
#endif /* MPI */
|
2012-07-28 12:24:12 -03:00
|
|
|
use mpitools , only : master, nprocs, nproc
|
2014-05-28 18:21:16 -03:00
|
|
|
use operators , only : initialize_operators, finalize_operators
|
2012-07-22 19:32:21 -03:00
|
|
|
use parameters , only : read_parameters, finalize_parameters
|
|
|
|
#ifdef MPI
|
|
|
|
use parameters , only : redistribute_parameters
|
|
|
|
#endif /* MPI */
|
2012-07-28 12:12:35 -03:00
|
|
|
use parameters , only : get_parameter_integer, get_parameter_real &
|
|
|
|
, get_parameter_string
|
2014-02-07 13:57:28 -02:00
|
|
|
use problems , only : initialize_problems, finalize_problems
|
2012-07-22 19:37:58 -03:00
|
|
|
use random , only : initialize_random, finalize_random
|
2013-12-26 17:32:11 -02:00
|
|
|
use refinement , only : initialize_refinement, finalize_refinement
|
2013-12-11 10:16:06 -02:00
|
|
|
use schemes , only : initialize_schemes, finalize_schemes
|
2014-02-07 12:12:27 -02:00
|
|
|
use shapes , only : initialize_shapes, finalize_shapes
|
2014-04-29 18:35:58 -03:00
|
|
|
use sources , only : initialize_sources, finalize_sources
|
2013-12-11 17:18:56 -02:00
|
|
|
use timers , only : initialize_timers, finalize_timers
|
|
|
|
use timers , only : start_timer, stop_timer, set_timer, get_timer
|
|
|
|
use timers , only : get_timer_total, timer_enabled, timer_description
|
2014-01-02 12:48:58 -02:00
|
|
|
use timers , only : get_count, ntimers
|
2017-03-08 11:02:59 -03:00
|
|
|
use user_problem , only : initialize_user_problem, finalize_user_problem
|
2012-07-28 12:24:12 -03:00
|
|
|
|
|
|
|
! module variables are not implicit by default
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2012-07-28 12:24:12 -03:00
|
|
|
implicit none
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! default parameters
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
integer, dimension(3) :: div = 1
|
|
|
|
logical, dimension(3) :: per = .true.
|
2014-04-02 15:25:08 -03:00
|
|
|
integer :: nmax = huge(1), ndat = 1
|
2014-08-04 09:14:53 -03:00
|
|
|
real(kind=8) :: tmax = 0.0d+00, trun = 9.999d+03, tsav = 3.0d+01
|
2014-01-08 18:07:54 -02:00
|
|
|
real(kind=8) :: dtnext = 0.0d+00
|
|
|
|
|
|
|
|
! flag to adjust time precisely to the snapshots
|
|
|
|
!
|
|
|
|
logical , save :: precise_snapshots = .false.
|
|
|
|
character(len=255) :: prec_snap = "off"
|
2012-07-28 12:12:35 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! temporary variables
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
character(len=64) :: lbnd, ubnd
|
2012-07-22 15:46:56 -03:00
|
|
|
|
2012-07-28 12:03:17 -03:00
|
|
|
! the termination and status flags
|
|
|
|
!
|
|
|
|
integer :: iterm, iret
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! timer indices
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
integer :: iin, iev, itm
|
|
|
|
#ifdef PROFILE
|
|
|
|
integer :: ipr, ipi
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
! local snapshot file counters
|
|
|
|
!
|
|
|
|
integer :: nrun = 1
|
|
|
|
|
|
|
|
! iteration and time variables
|
|
|
|
!
|
|
|
|
integer :: i, ed, eh, em, es, ec
|
|
|
|
integer :: nsteps = 1
|
|
|
|
character(len=80) :: fmt, tmp
|
|
|
|
|
2014-08-04 09:14:53 -03:00
|
|
|
real(kind=8) :: tbeg, thrs
|
2012-07-28 13:48:15 -03:00
|
|
|
real(kind=8) :: tm_curr, tm_exec, tm_conv
|
2012-07-22 15:46:56 -03:00
|
|
|
|
2012-07-28 12:24:12 -03:00
|
|
|
#ifdef INTEL
|
|
|
|
! the type of the function SIGNAL should be defined for Intel compiler
|
|
|
|
!
|
|
|
|
integer(kind=4) :: signal
|
|
|
|
#endif /* INTEL */
|
|
|
|
|
2011-05-06 09:51:40 -03:00
|
|
|
#ifdef SIGNALS
|
2011-04-29 00:51:28 -03:00
|
|
|
! references to functions handling signals
|
|
|
|
!
|
2011-06-07 17:29:03 -03:00
|
|
|
#ifdef GNU
|
2011-04-29 00:51:28 -03:00
|
|
|
intrinsic signal
|
2011-06-07 17:29:03 -03:00
|
|
|
#endif /* GNU */
|
2011-04-29 00:51:28 -03:00
|
|
|
external terminate
|
|
|
|
|
|
|
|
! signal definitions
|
|
|
|
!
|
2014-12-24 15:04:24 -02:00
|
|
|
integer, parameter :: SIGERR = -1
|
|
|
|
integer, parameter :: SIGINT = 2, SIGABRT = 6, SIGTERM = 15
|
2011-04-29 00:51:28 -03:00
|
|
|
#endif /* SIGNALS */
|
2012-07-28 12:03:17 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! an array to store execution times
|
|
|
|
!
|
|
|
|
real(kind=8), dimension(ntimers) :: tm
|
|
|
|
|
2012-07-28 12:03:17 -03:00
|
|
|
! common block
|
|
|
|
!
|
|
|
|
common /termination/ iterm
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2008-12-08 21:11:17 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2014-12-24 15:04:24 -02:00
|
|
|
! initialize the termination and return flags
|
2012-07-28 12:24:12 -03:00
|
|
|
!
|
|
|
|
iterm = 0
|
2014-12-24 15:04:24 -02:00
|
|
|
iret = 0
|
2012-07-28 12:24:12 -03:00
|
|
|
|
2013-12-11 17:18:56 -02:00
|
|
|
! initialize module TIMERS
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
|
|
|
call initialize_timers()
|
|
|
|
|
|
|
|
! set timer descriptions
|
|
|
|
!
|
2012-07-28 12:24:12 -03:00
|
|
|
call set_timer('INITIALIZATION', iin)
|
|
|
|
call set_timer('EVOLUTION' , iev)
|
|
|
|
call set_timer('TERMINATION' , itm)
|
2012-07-22 15:46:56 -03:00
|
|
|
|
|
|
|
! start time accounting for the initialization
|
|
|
|
!
|
|
|
|
call start_timer(iin)
|
|
|
|
|
2011-04-29 00:51:28 -03:00
|
|
|
#ifdef SIGNALS
|
2014-12-24 15:04:24 -02:00
|
|
|
! assign function terminate() to handle signals
|
2011-04-29 00:51:28 -03:00
|
|
|
!
|
2011-06-07 17:29:03 -03:00
|
|
|
#ifdef GNU
|
2014-12-24 15:04:24 -02:00
|
|
|
if (signal(SIGINT , terminate) == SIGERR) iret = 1
|
|
|
|
if (signal(SIGABRT, terminate) == SIGERR) iret = 2
|
|
|
|
if (signal(SIGTERM, terminate) == SIGERR) iret = 3
|
2011-06-17 20:21:10 -03:00
|
|
|
#endif /* GNU */
|
2014-12-24 15:04:24 -02:00
|
|
|
#ifdef INTEL
|
|
|
|
if (signal(SIGINT , terminate, -1) == SIGERR) iret = 1
|
|
|
|
if (signal(SIGABRT, terminate, -1) == SIGERR) iret = 2
|
|
|
|
if (signal(SIGTERM, terminate, -1) == SIGERR) iret = 3
|
|
|
|
#endif /* INTEL */
|
|
|
|
|
|
|
|
! in the case of problems with signal handler assignment, quit the program
|
|
|
|
!
|
|
|
|
if (iret > 0) go to 200
|
2011-04-29 00:51:28 -03:00
|
|
|
#endif /* SIGNALS */
|
2011-06-17 20:21:10 -03:00
|
|
|
|
2012-07-28 12:24:12 -03:00
|
|
|
! initialize module MPITOOLS
|
2008-12-22 14:57:31 -06:00
|
|
|
!
|
2012-07-28 12:29:44 -03:00
|
|
|
call initialize_mpitools()
|
2008-12-22 14:57:31 -06:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! print the welcome message
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2012-07-22 19:01:27 -03:00
|
|
|
if (master) then
|
2012-07-28 13:48:15 -03:00
|
|
|
|
2008-12-22 14:57:31 -06:00
|
|
|
write (*,"(1x,78('-'))")
|
2012-07-28 13:48:15 -03:00
|
|
|
write (*,"(1x,18('='),17x,a,17x,19('='))") 'A M U N'
|
2011-03-21 18:24:55 -03:00
|
|
|
write (*,"(1x,16('='),4x,a,4x,16('='))") &
|
2018-01-04 12:13:09 -02:00
|
|
|
'Copyright (C) 2008-2018 Grzegorz Kowal'
|
2012-07-28 13:48:15 -03:00
|
|
|
write (*,"(1x,18('='),9x,a,9x,19('='))") &
|
|
|
|
'under GNU GPLv3 license'
|
2008-12-22 14:57:31 -06:00
|
|
|
write (*,"(1x,78('-'))")
|
2012-07-28 13:48:15 -03:00
|
|
|
|
2010-10-06 23:11:22 -03:00
|
|
|
end if
|
2008-11-04 13:08:01 -06:00
|
|
|
|
2012-07-22 19:32:21 -03:00
|
|
|
! initialize and read parameters from the parameter file
|
|
|
|
!
|
|
|
|
if (master) call read_parameters(iterm)
|
|
|
|
|
|
|
|
#ifdef MPI
|
|
|
|
! broadcast the termination flag
|
|
|
|
!
|
|
|
|
call bcast_integer_variable(iterm, iret)
|
|
|
|
|
|
|
|
! check if the termination flag was broadcaster successfully
|
|
|
|
!
|
2013-12-26 17:32:11 -02:00
|
|
|
if (iterm > 0) go to 100
|
2012-07-22 19:32:21 -03:00
|
|
|
|
|
|
|
! reset the termination flag
|
|
|
|
!
|
|
|
|
iterm = 0
|
|
|
|
|
|
|
|
! redistribute parameters among all processors
|
|
|
|
!
|
|
|
|
call redistribute_parameters(iterm)
|
|
|
|
|
|
|
|
! reduce the termination flag over all processors to check if everything is fine
|
|
|
|
!
|
|
|
|
call reduce_maximum_integer(iterm, iret)
|
|
|
|
#endif /* MPI */
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! check if the termination flag was broadcaster successfully
|
|
|
|
!
|
2013-12-26 17:32:11 -02:00
|
|
|
if (iterm > 0) go to 100
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
! reset the termination flag
|
|
|
|
!
|
|
|
|
iterm = 0
|
|
|
|
|
|
|
|
! check if the domain is periodic
|
|
|
|
!
|
|
|
|
lbnd = "periodic"
|
|
|
|
ubnd = "periodic"
|
|
|
|
call get_parameter_string("xlbndry" , lbnd)
|
|
|
|
call get_parameter_string("xubndry" , ubnd)
|
|
|
|
per(1) = (lbnd == "periodic") .and. (ubnd == "periodic")
|
|
|
|
lbnd = "periodic"
|
|
|
|
ubnd = "periodic"
|
|
|
|
call get_parameter_string("ylbndry" , lbnd)
|
|
|
|
call get_parameter_string("yubndry" , ubnd)
|
|
|
|
per(2) = (lbnd == "periodic") .and. (ubnd == "periodic")
|
2013-12-12 16:09:47 -02:00
|
|
|
#if NDIMS == 3
|
2012-07-28 13:48:15 -03:00
|
|
|
lbnd = "periodic"
|
|
|
|
ubnd = "periodic"
|
|
|
|
call get_parameter_string("zlbndry" , lbnd)
|
|
|
|
call get_parameter_string("zubndry" , ubnd)
|
|
|
|
per(3) = (lbnd == "periodic") .and. (ubnd == "periodic")
|
2013-12-12 16:09:47 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2012-07-28 13:48:15 -03:00
|
|
|
|
2012-07-28 12:12:35 -03:00
|
|
|
! get the execution termination parameters
|
|
|
|
!
|
|
|
|
call get_parameter_integer("nmax" , nmax)
|
|
|
|
call get_parameter_real ("tmax" , tmax)
|
|
|
|
call get_parameter_real ("trun" , trun)
|
|
|
|
call get_parameter_real ("tsav" , tsav)
|
|
|
|
|
2013-12-26 17:54:56 -02:00
|
|
|
! correct the run time by the save time
|
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
trun = trun - tsav / 6.0d+01
|
|
|
|
|
|
|
|
! initialize dtnext
|
|
|
|
!
|
|
|
|
dtnext = 2.0d+00 * tmax
|
|
|
|
|
|
|
|
! get the precise snapshot flag
|
|
|
|
!
|
|
|
|
call get_parameter_string ("precise_snapshots", prec_snap)
|
|
|
|
|
|
|
|
! set the precise snapshot flag
|
|
|
|
!
|
|
|
|
if (prec_snap == "on" ) precise_snapshots = .true.
|
|
|
|
if (prec_snap == "ON" ) precise_snapshots = .true.
|
|
|
|
if (prec_snap == "true") precise_snapshots = .true.
|
|
|
|
if (prec_snap == "TRUE") precise_snapshots = .true.
|
|
|
|
if (prec_snap == "yes" ) precise_snapshots = .true.
|
|
|
|
if (prec_snap == "YES" ) precise_snapshots = .true.
|
2013-12-26 17:54:56 -02:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! get integral calculation interval
|
2011-04-14 00:19:45 +02:00
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
call get_parameter_integer("ndat" , ndat)
|
|
|
|
|
2014-08-09 09:31:52 -03:00
|
|
|
! initialize MPI module and print info
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Parallelization:"
|
|
|
|
write (*,"(4x,a,1x,i6 )" ) "MPI processes =", nprocs
|
|
|
|
end if
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! set up the MPI geometry
|
|
|
|
!
|
|
|
|
call setup_mpi(div(:), per(:), .false.)
|
2011-04-14 00:19:45 +02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! initialize the random number generator
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call initialize_random(nprocs, nproc)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2013-12-11 17:01:22 -02:00
|
|
|
! initialize geometry modules and print info
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Geometry:"
|
|
|
|
end if
|
|
|
|
|
|
|
|
! initialize module COORDINATES
|
|
|
|
!
|
|
|
|
call initialize_coordinates(master, iret)
|
|
|
|
|
|
|
|
! jump to the end if the equations could not be initialized
|
|
|
|
!
|
2013-12-26 17:32:11 -02:00
|
|
|
if (iret > 0) go to 100
|
2013-12-11 17:01:22 -02:00
|
|
|
|
|
|
|
! initialize physics modules and print info
|
|
|
|
!
|
2013-12-11 10:22:51 -02:00
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Physics:"
|
|
|
|
end if
|
|
|
|
|
2013-12-11 00:09:15 -02:00
|
|
|
! initialize module EQUATIONS
|
|
|
|
!
|
|
|
|
call initialize_equations(master, iret)
|
|
|
|
|
|
|
|
! jump to the end if the equations could not be initialized
|
2013-12-26 17:32:11 -02:00
|
|
|
!
|
|
|
|
if (iret > 0) go to 60
|
|
|
|
|
2017-05-11 09:54:12 -03:00
|
|
|
! print information about the problem
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Problem:"
|
|
|
|
end if
|
|
|
|
|
2017-03-08 13:43:26 -03:00
|
|
|
! initialize module USER_PROBLEM
|
|
|
|
!
|
|
|
|
call initialize_user_problem(master, iret)
|
|
|
|
|
2013-12-26 17:32:11 -02:00
|
|
|
! initialize refinement module and print info
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Refinement:"
|
|
|
|
end if
|
|
|
|
|
|
|
|
! jump to the end if the refinement could not be initialized
|
2013-12-11 10:16:06 -02:00
|
|
|
!
|
2013-12-11 10:59:25 -02:00
|
|
|
if (iret > 0) go to 50
|
2013-12-11 10:16:06 -02:00
|
|
|
|
2013-12-26 17:32:11 -02:00
|
|
|
! initialize module REFINEMENT
|
|
|
|
!
|
|
|
|
call initialize_refinement(master, iret)
|
|
|
|
|
2013-12-11 17:01:22 -02:00
|
|
|
! initialize methods modules and print info
|
|
|
|
!
|
2013-12-11 10:22:51 -02:00
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Methods:"
|
|
|
|
end if
|
|
|
|
|
2013-12-11 10:59:25 -02:00
|
|
|
! initialize evolution
|
|
|
|
!
|
|
|
|
call initialize_evolution(master, iret)
|
|
|
|
|
|
|
|
! jump to the end if the schemes could not be initialized
|
|
|
|
!
|
|
|
|
if (iret > 0) go to 40
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
! initialize module SCHEMES
|
|
|
|
!
|
|
|
|
call initialize_schemes(master, iret)
|
|
|
|
|
|
|
|
! jump to the end if the schemes could not be initialized
|
2013-12-11 00:09:15 -02:00
|
|
|
!
|
|
|
|
if (iret > 0) go to 30
|
|
|
|
|
2013-12-11 22:34:29 -02:00
|
|
|
! initialize module INTERPOLATIONS
|
2008-12-07 15:14:18 -06:00
|
|
|
!
|
2013-12-11 22:34:29 -02:00
|
|
|
call initialize_interpolations(master, iret)
|
2011-03-02 15:04:16 -03:00
|
|
|
|
2014-05-28 18:21:16 -03:00
|
|
|
! initialize module OPERATORS
|
|
|
|
!
|
|
|
|
call initialize_operators(master, iret)
|
|
|
|
|
2013-12-11 22:34:29 -02:00
|
|
|
! initialize block module
|
2012-07-27 17:18:24 -03:00
|
|
|
!
|
2014-01-15 10:33:37 -02:00
|
|
|
call initialize_blocks(master, iret)
|
2012-07-27 17:18:24 -03:00
|
|
|
|
2014-01-02 17:18:42 -02:00
|
|
|
! initialize boundaries module and print info
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Boundaries:"
|
|
|
|
end if
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! initialize boundaries
|
2012-07-27 16:46:36 -03:00
|
|
|
!
|
2014-01-02 17:18:42 -02:00
|
|
|
call initialize_boundaries(master, iret)
|
2012-07-27 16:46:36 -03:00
|
|
|
|
2012-07-27 21:13:43 -03:00
|
|
|
! initialize module PROBLEMS
|
|
|
|
!
|
2014-02-07 13:57:28 -02:00
|
|
|
call initialize_problems(master, iret)
|
2012-07-27 21:13:43 -03:00
|
|
|
|
2014-02-07 12:12:27 -02:00
|
|
|
! initialize module SHAPES
|
|
|
|
!
|
|
|
|
call initialize_shapes(master, iret)
|
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! print header for source term information
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
|
|
|
write (*,"(1x,a)" ) "Source terms:"
|
|
|
|
end if
|
|
|
|
|
2017-03-03 18:15:15 -03:00
|
|
|
! initialize module GRAVITY
|
|
|
|
!
|
|
|
|
call initialize_gravity(master, iret)
|
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! initialize module SOURCES
|
|
|
|
!
|
|
|
|
call initialize_sources(master, iret)
|
|
|
|
|
2014-01-08 18:07:54 -02:00
|
|
|
! initialize boundaries module and print info
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
write (*,*)
|
2014-01-30 17:55:41 -02:00
|
|
|
write (*,"(1x,a)" ) "Snapshots:"
|
|
|
|
write (*,"(4x,a22,1x,'=',1x,a)") "precise snapshot times", trim(prec_snap)
|
2014-01-08 18:07:54 -02:00
|
|
|
end if
|
|
|
|
|
2012-08-02 00:35:37 -03:00
|
|
|
! initialize module IO
|
|
|
|
!
|
2014-01-09 11:22:23 -02:00
|
|
|
call initialize_io(master, nrun, iret)
|
2012-08-02 00:35:37 -03:00
|
|
|
|
2011-04-11 16:27:08 +02:00
|
|
|
! check if we initiate new problem or restart previous job
|
|
|
|
!
|
2014-01-09 11:22:23 -02:00
|
|
|
if (restart_from_snapshot()) then
|
|
|
|
|
|
|
|
! increase the run number
|
|
|
|
!
|
|
|
|
nrun = nrun + 1
|
|
|
|
|
|
|
|
! initialize the mesh module
|
|
|
|
!
|
|
|
|
call initialize_mesh(nrun, master, iret)
|
|
|
|
|
2016-11-18 10:04:38 -02:00
|
|
|
! quit if mesh couldn't be initialized
|
|
|
|
!
|
|
|
|
if (iret > 0) go to 10
|
|
|
|
|
2014-01-09 11:22:23 -02:00
|
|
|
! reconstruct the meta and data block structures from a given restart file
|
|
|
|
!
|
2016-11-18 10:12:51 -02:00
|
|
|
call read_restart_snapshot(iterm)
|
2016-11-18 10:04:38 -02:00
|
|
|
|
2016-11-18 10:58:49 -02:00
|
|
|
#ifdef MPI
|
|
|
|
! reduce termination flag over all processors
|
|
|
|
!
|
|
|
|
call reduce_maximum_integer(iterm, iret)
|
|
|
|
#endif /* MPI */
|
|
|
|
|
2016-11-18 10:04:38 -02:00
|
|
|
! quit if there was a problem with reading restart snapshots
|
|
|
|
!
|
2016-11-18 10:12:51 -02:00
|
|
|
if (iterm > 0) go to 10
|
2014-01-09 11:22:23 -02:00
|
|
|
|
2015-12-18 06:55:32 -02:00
|
|
|
! update the list of leafs
|
|
|
|
!
|
|
|
|
call build_leaf_list()
|
|
|
|
|
2014-01-09 11:22:23 -02:00
|
|
|
else
|
2011-04-11 16:27:08 +02:00
|
|
|
|
2011-04-28 12:04:22 -03:00
|
|
|
! initialize the mesh module
|
|
|
|
!
|
2013-12-26 19:51:26 -02:00
|
|
|
call initialize_mesh(nrun, master, iret)
|
2011-04-28 12:04:22 -03:00
|
|
|
|
2016-11-18 10:04:38 -02:00
|
|
|
! quit if mesh couldn't be initialized
|
|
|
|
!
|
|
|
|
if (iret > 0) go to 10
|
|
|
|
|
2011-04-27 22:35:38 -03:00
|
|
|
! generate the initial mesh, refine that mesh to the desired level according to
|
|
|
|
! the initialized problem
|
2011-04-11 16:27:08 +02:00
|
|
|
!
|
2013-12-23 16:44:56 -02:00
|
|
|
call generate_mesh()
|
2011-04-11 16:27:08 +02:00
|
|
|
|
2014-06-11 23:06:28 -03:00
|
|
|
! update boundaries
|
|
|
|
!
|
2017-03-07 16:02:01 -03:00
|
|
|
call boundary_variables(0.0d+00, dtnext)
|
2014-06-11 23:06:28 -03:00
|
|
|
|
2013-12-11 22:48:48 -02:00
|
|
|
! calculate new timestep
|
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
call new_time_step(dtnext)
|
2013-12-11 22:48:48 -02:00
|
|
|
|
2014-01-10 12:42:18 -02:00
|
|
|
end if
|
|
|
|
|
2014-01-08 17:08:08 -02:00
|
|
|
! initialize the integrals module
|
|
|
|
!
|
2014-01-10 12:42:18 -02:00
|
|
|
call initialize_integrals(master, nrun, iret)
|
2014-01-08 17:08:08 -02:00
|
|
|
|
2014-01-10 12:42:18 -02:00
|
|
|
! check if the module was successfully initialized
|
|
|
|
!
|
|
|
|
if (iret > 0) go to 10
|
2011-03-02 15:52:33 -03:00
|
|
|
|
2014-01-09 12:50:05 -02:00
|
|
|
! store mesh statistics
|
|
|
|
!
|
|
|
|
call store_mesh_stats(step, time)
|
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
#ifdef MPI
|
|
|
|
! reduce termination flag over all processors
|
|
|
|
!
|
|
|
|
call reduce_maximum_integer(iterm, iret)
|
|
|
|
#endif /* MPI */
|
|
|
|
|
|
|
|
! check if the problem was successfully initialized or restarted
|
|
|
|
!
|
|
|
|
if (iterm > 0) go to 10
|
|
|
|
|
|
|
|
! store integrals and data to a file
|
|
|
|
!
|
2014-01-09 11:22:23 -02:00
|
|
|
if (.not. restart_from_snapshot()) then
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
call store_integrals()
|
2014-01-09 09:29:22 -02:00
|
|
|
call write_snapshot()
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
#ifdef MPI
|
|
|
|
! reduce termination flag over all processors
|
|
|
|
!
|
|
|
|
call reduce_maximum_integer(iterm, iret)
|
|
|
|
#endif /* MPI */
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
! if the initial data were not successfully writen, exit the program
|
|
|
|
!
|
|
|
|
if (iterm > 0) go to 10
|
|
|
|
|
|
|
|
! reset the termination flag
|
|
|
|
!
|
|
|
|
iterm = 0
|
2012-08-02 15:09:44 -03:00
|
|
|
iret = 0
|
2012-07-28 13:48:15 -03:00
|
|
|
|
2012-07-22 15:46:56 -03:00
|
|
|
! stop time accounting for the initialization
|
2011-05-02 23:43:58 -03:00
|
|
|
!
|
2012-07-22 15:46:56 -03:00
|
|
|
call stop_timer(iin)
|
|
|
|
|
|
|
|
! start time accounting for the evolution
|
|
|
|
!
|
|
|
|
call start_timer(iev)
|
2011-05-02 23:43:58 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! get current time in seconds
|
|
|
|
!
|
|
|
|
if (master) &
|
2014-01-08 17:34:15 -02:00
|
|
|
tbeg = time
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
! print progress info on master processor
|
2008-12-07 15:14:18 -06:00
|
|
|
!
|
2012-07-22 19:01:27 -03:00
|
|
|
if (master) then
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
! initialize estimated remaining time of calculations
|
|
|
|
!
|
|
|
|
ed = 9999
|
|
|
|
eh = 23
|
|
|
|
em = 59
|
|
|
|
es = 59
|
|
|
|
|
|
|
|
! print progress info
|
|
|
|
!
|
|
|
|
write(*,*)
|
2011-03-10 15:22:10 -03:00
|
|
|
write(*,"(1x,a)" ) "Evolving the system:"
|
2011-02-28 16:04:38 -03:00
|
|
|
write(*,'(4x,a4,5x,a4,11x,a2,12x,a6,7x,a3)') 'step', 'time', 'dt' &
|
|
|
|
, 'blocks', 'ETA'
|
2018-01-05 11:15:35 -02:00
|
|
|
#ifdef INTEL
|
2011-02-28 16:04:38 -03:00
|
|
|
write(*,'(i8,2(1x,1pe14.6),2x,i8,2x,1i4.1,"d",1i2.2,"h",1i2.2,"m"' // &
|
2011-06-17 20:05:15 -03:00
|
|
|
',1i2.2,"s",15x,a1,$)') &
|
2014-01-08 17:34:15 -02:00
|
|
|
step, time, dt, get_nleafs(), ed, eh, em, es, char(13)
|
2018-01-05 11:15:35 -02:00
|
|
|
#else /* INTEL */
|
2011-06-07 17:29:03 -03:00
|
|
|
write(*,'(i8,2(1x,1pe14.6),2x,i8,2x,1i4.1,"d",1i2.2,"h",1i2.2,"m"' // &
|
2011-06-17 20:05:15 -03:00
|
|
|
',1i2.2,"s",15x,a1)',advance="no") &
|
2014-01-08 17:34:15 -02:00
|
|
|
step, time, dt, get_nleafs(), ed, eh, em, es, char(13)
|
2018-01-05 11:15:35 -02:00
|
|
|
#endif /* INTEL */
|
2008-12-07 15:14:18 -06:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
end if
|
2011-05-06 09:51:40 -03:00
|
|
|
|
2008-12-07 15:14:18 -06:00
|
|
|
! main loop
|
|
|
|
!
|
2014-01-08 17:34:15 -02:00
|
|
|
do while((nsteps <= nmax) .and. (time < tmax) .and. (iterm == 0))
|
2008-12-07 15:14:18 -06:00
|
|
|
|
2014-01-08 18:07:54 -02:00
|
|
|
! get the next snapshot time
|
|
|
|
!
|
|
|
|
if (precise_snapshots) dtnext = next_tout() - time
|
|
|
|
|
2013-12-11 22:48:48 -02:00
|
|
|
! performe one step evolution
|
2008-12-09 14:51:33 -06:00
|
|
|
!
|
2014-01-08 18:07:54 -02:00
|
|
|
call advance(dtnext)
|
2010-12-08 18:11:15 -02:00
|
|
|
|
2008-12-07 15:14:18 -06:00
|
|
|
! advance the iteration number and time
|
|
|
|
!
|
2014-01-08 17:34:15 -02:00
|
|
|
time = time + dt
|
|
|
|
step = step + 1
|
|
|
|
nsteps = nsteps + 1
|
2008-12-07 15:14:18 -06:00
|
|
|
|
2014-08-04 11:08:32 -03:00
|
|
|
! get current time in seconds
|
|
|
|
!
|
|
|
|
tm_curr = get_timer_total()
|
|
|
|
|
|
|
|
! compute elapsed time
|
|
|
|
!
|
|
|
|
thrs = tm_curr / 3.6d+03
|
|
|
|
|
2011-04-28 12:04:22 -03:00
|
|
|
! store mesh statistics
|
|
|
|
!
|
2014-01-08 17:34:15 -02:00
|
|
|
call store_mesh_stats(step, time)
|
2011-04-28 12:04:22 -03:00
|
|
|
|
2011-03-02 15:52:33 -03:00
|
|
|
! store integrals
|
|
|
|
!
|
|
|
|
call store_integrals()
|
|
|
|
|
2014-01-09 12:13:26 -02:00
|
|
|
! write down the restart snapshot
|
|
|
|
!
|
|
|
|
call write_restart_snapshot(thrs, nrun, iret)
|
|
|
|
|
2008-12-09 12:42:10 -06:00
|
|
|
! store data
|
|
|
|
!
|
2014-01-09 09:29:22 -02:00
|
|
|
call write_snapshot()
|
2008-12-09 12:42:10 -06:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! check if the time exceeds execution time limit
|
|
|
|
!
|
2013-12-26 17:54:56 -02:00
|
|
|
if (thrs > trun) iterm = 100
|
2012-07-28 13:48:15 -03:00
|
|
|
|
|
|
|
! print progress info to console
|
|
|
|
!
|
|
|
|
if (master) then
|
|
|
|
|
|
|
|
! calculate days, hours, seconds
|
|
|
|
!
|
2014-08-04 09:54:49 -03:00
|
|
|
ec = int(tm_curr * (tmax - time) / max(1.0d-08, time - tbeg), kind = 4)
|
2012-07-28 13:48:15 -03:00
|
|
|
es = max(0, int(mod(ec, 60)))
|
|
|
|
em = int(mod(ec / 60, 60))
|
|
|
|
eh = int(ec / 3600)
|
|
|
|
ed = int(eh / 24)
|
|
|
|
eh = int(mod(eh, 24))
|
|
|
|
ed = min(9999,ed)
|
|
|
|
|
2018-01-05 11:15:35 -02:00
|
|
|
#ifdef INTEL
|
2011-06-13 16:58:39 -03:00
|
|
|
write(*,'(i8,2(1x,1pe14.6),2x,i8,2x,1i4.1,"d",1i2.2,"h",1i2.2,"m"' // &
|
|
|
|
',1i2.2,"s",15x,a1,$)') &
|
2014-01-08 17:34:15 -02:00
|
|
|
step, time, dt, get_nleafs(), ed, eh, em, es, char(13)
|
2018-01-05 11:15:35 -02:00
|
|
|
#else /* INTEL */
|
2011-02-28 16:04:38 -03:00
|
|
|
write(*,'(i8,2(1x,1pe14.6),2x,i8,2x,1i4.1,"d",1i2.2,"h",1i2.2,"m"' // &
|
2011-06-10 18:13:23 -03:00
|
|
|
',1i2.2,"s",15x,a1)',advance="no") &
|
2014-01-08 17:34:15 -02:00
|
|
|
step, time, dt, get_nleafs(), ed, eh, em, es, char(13)
|
2018-01-05 11:15:35 -02:00
|
|
|
#endif /* INTEL */
|
2011-06-07 14:34:54 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
end if
|
2011-06-07 14:34:54 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! prepare iterm
|
2011-06-18 10:16:45 -03:00
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
iterm = max(iterm, iret)
|
2011-06-07 14:34:54 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
#ifdef MPI
|
2011-04-29 00:51:28 -03:00
|
|
|
! reduce termination flag over all processors
|
|
|
|
!
|
2012-07-22 19:01:27 -03:00
|
|
|
call reduce_maximum_integer(iterm, iret)
|
2012-07-28 13:48:15 -03:00
|
|
|
#endif /* MPI */
|
|
|
|
|
2008-12-07 15:14:18 -06:00
|
|
|
end do
|
|
|
|
|
2011-02-27 22:39:56 -03:00
|
|
|
! add one empty line
|
|
|
|
!
|
2012-07-22 19:01:27 -03:00
|
|
|
if (master) write(*,*)
|
2011-02-27 22:39:56 -03:00
|
|
|
|
2012-07-22 15:46:56 -03:00
|
|
|
! stop time accounting for the evolution
|
2011-04-14 16:16:58 +02:00
|
|
|
!
|
2012-07-22 15:46:56 -03:00
|
|
|
call stop_timer(iev)
|
|
|
|
|
2014-01-09 12:13:26 -02:00
|
|
|
! write down the restart snapshot
|
2011-05-02 23:43:58 -03:00
|
|
|
!
|
2014-01-09 12:13:26 -02:00
|
|
|
call write_restart_snapshot(1.0d+16, nrun, iret)
|
2011-05-02 23:43:58 -03:00
|
|
|
|
2012-07-28 13:48:15 -03:00
|
|
|
! a label to go to if there are any problems, but since all modules have been
|
|
|
|
! initialized, we have to finalize them first
|
|
|
|
!
|
|
|
|
10 continue
|
|
|
|
|
2016-11-18 10:09:22 -02:00
|
|
|
! start time accounting for the termination
|
|
|
|
!
|
|
|
|
call start_timer(itm)
|
|
|
|
|
2014-01-10 12:42:18 -02:00
|
|
|
! finalize integrals module
|
2011-03-02 15:52:33 -03:00
|
|
|
!
|
2014-01-10 12:42:18 -02:00
|
|
|
call finalize_integrals()
|
2011-03-02 15:52:33 -03:00
|
|
|
|
2017-09-05 09:53:47 -03:00
|
|
|
! finalize I/O module
|
|
|
|
!
|
|
|
|
call finalize_io(iret)
|
|
|
|
|
2014-02-07 13:57:28 -02:00
|
|
|
! finalize module PROBLEMS
|
|
|
|
!
|
|
|
|
call finalize_problems(iret)
|
|
|
|
|
2014-04-29 18:35:58 -03:00
|
|
|
! finalize module SOURCES
|
|
|
|
!
|
|
|
|
call finalize_sources(iret)
|
|
|
|
|
2017-03-03 18:15:15 -03:00
|
|
|
! finalize module GRAVITY
|
|
|
|
!
|
|
|
|
call finalize_gravity(iret)
|
|
|
|
|
2014-02-07 12:12:27 -02:00
|
|
|
! finalize module SHAPES
|
|
|
|
!
|
|
|
|
call finalize_shapes(iret)
|
|
|
|
|
2013-12-26 19:51:26 -02:00
|
|
|
! finalize the mesh module
|
2011-03-02 15:04:16 -03:00
|
|
|
!
|
2013-12-26 19:51:26 -02:00
|
|
|
call finalize_mesh(iret)
|
2010-12-08 12:21:41 -02:00
|
|
|
|
2014-01-02 17:18:42 -02:00
|
|
|
! finalize boundary module
|
|
|
|
!
|
|
|
|
call finalize_boundaries(iret)
|
|
|
|
|
2012-07-22 22:47:25 -03:00
|
|
|
! deallocate block structure
|
|
|
|
!
|
2014-01-15 10:33:37 -02:00
|
|
|
call finalize_blocks(iret)
|
2012-07-22 22:47:25 -03:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! finalize the random number generator
|
|
|
|
!
|
|
|
|
call finalize_random()
|
|
|
|
|
2017-03-08 11:02:59 -03:00
|
|
|
! finalize the user problem module
|
|
|
|
!
|
|
|
|
call finalize_user_problem(iret)
|
|
|
|
|
2012-07-22 15:46:56 -03:00
|
|
|
! stop time accounting for the termination
|
|
|
|
!
|
|
|
|
call stop_timer(itm)
|
|
|
|
|
2008-12-07 14:06:04 -06:00
|
|
|
! get total time
|
|
|
|
!
|
2012-07-22 15:46:56 -03:00
|
|
|
tm(1) = get_timer_total()
|
|
|
|
|
|
|
|
! get subtasks timers
|
|
|
|
!
|
|
|
|
do i = 2, ntimers
|
|
|
|
tm(i) = get_timer(i)
|
|
|
|
end do
|
|
|
|
|
2014-01-06 11:37:27 -02:00
|
|
|
#ifdef MPI
|
|
|
|
! sum up timers from all processes
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
call reduce_sum_real_array(ntimers, tm(:), iret)
|
|
|
|
#endif /* MPI */
|
2012-07-22 15:46:56 -03:00
|
|
|
|
2014-01-06 11:37:27 -02:00
|
|
|
! print timings only on master processor
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
if (master) then
|
2012-07-22 15:46:56 -03:00
|
|
|
|
|
|
|
! calculate the conversion factor
|
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
tm_conv = 1.0d+02 / tm(1)
|
2012-07-22 15:46:56 -03:00
|
|
|
|
2014-01-06 11:37:27 -02:00
|
|
|
! print one empty line
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
write (*,'(a)') ''
|
2012-07-22 15:46:56 -03:00
|
|
|
|
|
|
|
! print the execution times
|
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
write (tmp,"(a)") "(2x,a32,1x,':',3x,1f16.3,' secs = ',f6.2,' %')"
|
2012-07-22 15:46:56 -03:00
|
|
|
|
|
|
|
write (*,'(1x,a)') 'EXECUTION TIMINGS'
|
|
|
|
do i = 2, ntimers
|
2015-01-08 19:49:46 -02:00
|
|
|
if (timer_enabled(i)) then
|
|
|
|
if (get_count(i) > 0) then
|
|
|
|
write (*,tmp) timer_description(i), tm(i), tm_conv * tm(i)
|
|
|
|
end if ! timer counter > 0
|
|
|
|
end if ! enabled
|
2012-07-22 15:46:56 -03:00
|
|
|
end do
|
|
|
|
|
2014-01-06 11:37:27 -02:00
|
|
|
! print the execution times
|
2012-07-22 15:46:56 -03:00
|
|
|
!
|
2014-01-06 11:37:27 -02:00
|
|
|
write (tmp,"(a)") "(1x,a14,20x,':',3x,1f16.3,' secs = ',f6.2,' %')"
|
|
|
|
write (*,tmp) 'TOTAL CPU TIME', tm(1) , 1.0d+02
|
|
|
|
write (*,tmp) 'TIME PER STEP ', tm(1) / nsteps, 1.0d+02 / nsteps
|
2012-07-22 15:46:56 -03:00
|
|
|
#ifdef MPI
|
2014-01-06 11:37:27 -02:00
|
|
|
write (*,tmp) 'TIME PER CPU ', tm(1) / nprocs, 1.0d+02 / nprocs
|
2012-07-22 15:46:56 -03:00
|
|
|
#endif /* MPI */
|
|
|
|
|
2014-01-06 13:40:11 -02:00
|
|
|
! get the execution time
|
|
|
|
!
|
|
|
|
tm_exec = get_timer_total()
|
|
|
|
|
2014-01-06 11:37:27 -02:00
|
|
|
! convert the execution time to days, hours, minutes, and seconds and print it
|
|
|
|
!
|
|
|
|
tm(1) = tm_exec / 8.64d+04
|
2014-01-06 13:40:11 -02:00
|
|
|
tm(2) = mod(tm_exec / 3.6d+03, 2.4d+01)
|
2014-01-06 11:37:27 -02:00
|
|
|
tm(3) = mod(tm_exec / 6.0d+01, 6.0d+01)
|
|
|
|
tm(4) = mod(tm_exec, 6.0d+01)
|
|
|
|
tm(5) = nint((tm_exec - floor(tm_exec)) * 1.0d+03)
|
|
|
|
write (tmp,"(a)") "(1x,a14,20x,':',3x,i14,'d'" // &
|
|
|
|
",i3.2,'h',i3.2,'m',i3.2,'.',i3.3,'s')"
|
|
|
|
write (*,tmp) 'EXECUTION TIME', int(tm(1:5))
|
2012-07-22 15:46:56 -03:00
|
|
|
|
|
|
|
end if
|
2008-12-07 14:06:04 -06:00
|
|
|
|
2014-05-28 18:21:16 -03:00
|
|
|
! finalize module OPERATORS
|
|
|
|
!
|
|
|
|
call finalize_operators(iret)
|
|
|
|
|
2013-12-26 17:32:11 -02:00
|
|
|
! finalize module INTERPOLATIONS
|
|
|
|
!
|
|
|
|
call finalize_interpolations(iret)
|
|
|
|
|
|
|
|
! finalize module SCHEMES
|
|
|
|
!
|
|
|
|
call finalize_schemes(iret)
|
|
|
|
|
|
|
|
! jump point
|
|
|
|
!
|
|
|
|
30 continue
|
|
|
|
|
|
|
|
! finalize module EVOLUTION
|
|
|
|
!
|
|
|
|
call finalize_evolution(iret)
|
|
|
|
|
|
|
|
! jump point
|
|
|
|
!
|
|
|
|
40 continue
|
|
|
|
|
|
|
|
! finalize module REFINEMENT
|
|
|
|
!
|
|
|
|
call finalize_refinement(iret)
|
|
|
|
|
|
|
|
! jump point
|
|
|
|
!
|
|
|
|
50 continue
|
|
|
|
|
|
|
|
! finalize module EQUATIONS
|
|
|
|
!
|
|
|
|
call finalize_equations(iret)
|
|
|
|
|
|
|
|
! jump point
|
|
|
|
!
|
|
|
|
60 continue
|
|
|
|
|
|
|
|
! finalize module COORDINATES
|
|
|
|
!
|
|
|
|
call finalize_coordinates(iret)
|
|
|
|
|
2012-07-22 19:32:21 -03:00
|
|
|
! a label to go to if there are any problems
|
2011-04-29 00:51:28 -03:00
|
|
|
!
|
2013-12-26 17:32:11 -02:00
|
|
|
100 continue
|
2012-07-22 19:32:21 -03:00
|
|
|
|
2012-07-22 19:01:27 -03:00
|
|
|
if (master) then
|
2012-07-22 19:32:21 -03:00
|
|
|
|
|
|
|
! print info about termination due to a signal
|
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
if (iterm >= 1 .and. iterm <= 32) then
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,'(a)') ''
|
|
|
|
write (*,"(1x,a,i2)") "Terminating program after receiving a" // &
|
|
|
|
" termination signal no. ", iterm
|
|
|
|
write (*,"(1x,a)") "Restart files have been successfully written."
|
|
|
|
end if
|
2012-07-28 13:48:15 -03:00
|
|
|
if (iterm == 100) then
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,'(a)') ''
|
|
|
|
write (*,"(1x,a)") "Terminating program after exceeding the" // &
|
2011-06-07 17:29:03 -03:00
|
|
|
" execution time."
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,"(1x,a)") "Restart files have been successfully written."
|
|
|
|
end if
|
2016-11-18 10:12:51 -02:00
|
|
|
if (iterm >= 101 .and. iterm < 120) then
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,'(a)') ''
|
|
|
|
write (*,"(1x,a)") "The initial conditions for the selected problem" // &
|
|
|
|
" could not be set."
|
|
|
|
write (*,"(1x,a)") "Program has been terminated."
|
2011-06-07 17:29:03 -03:00
|
|
|
end if
|
2012-07-28 13:48:15 -03:00
|
|
|
if (iterm >= 120 .and. iterm < 125) then
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,'(a)') ''
|
|
|
|
write (*,"(1x,a)") "Problem with restarting job from restart snapshots."
|
|
|
|
write (*,"(1x,a)") "Program has been terminated."
|
|
|
|
end if
|
2012-07-28 13:48:15 -03:00
|
|
|
if (iterm >= 125 .and. iterm < 130) then
|
2012-07-22 19:32:21 -03:00
|
|
|
write (*,'(a)') ''
|
|
|
|
write (*,"(1x,a)") "Problem with storing snapshots."
|
|
|
|
write (*,"(1x,a)") "Program has been terminated."
|
2011-04-29 00:51:28 -03:00
|
|
|
end if
|
2011-06-07 01:05:42 -03:00
|
|
|
|
2012-07-22 19:32:21 -03:00
|
|
|
! print one empty line
|
2011-06-07 01:05:42 -03:00
|
|
|
!
|
2012-07-22 15:46:56 -03:00
|
|
|
write (*,'(a)') ''
|
2011-06-07 01:05:42 -03:00
|
|
|
|
2010-10-06 23:11:22 -03:00
|
|
|
end if
|
2008-12-22 14:57:31 -06:00
|
|
|
|
2013-12-11 17:29:15 -02:00
|
|
|
! finalize modules PARAMETERS
|
2012-07-22 19:32:21 -03:00
|
|
|
!
|
|
|
|
call finalize_parameters()
|
|
|
|
|
2012-07-28 12:29:44 -03:00
|
|
|
! finalize module MPITOOLS
|
2008-12-22 14:57:31 -06:00
|
|
|
!
|
2012-07-28 12:29:44 -03:00
|
|
|
call finalize_mpitools()
|
2008-12-07 14:06:04 -06:00
|
|
|
|
2014-12-24 15:04:24 -02:00
|
|
|
#ifdef SIGNALS
|
|
|
|
! a label to go to in the case of signal handler problems
|
|
|
|
!
|
|
|
|
200 continue
|
|
|
|
#endif /* SIGNALS */
|
|
|
|
|
2013-12-11 17:18:56 -02:00
|
|
|
! finalize module TIMERS
|
|
|
|
!
|
|
|
|
call finalize_timers()
|
|
|
|
|
2008-12-08 21:11:17 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
|
|
|
end program
|
2012-07-28 12:24:12 -03:00
|
|
|
|
2011-04-29 00:51:28 -03:00
|
|
|
#ifdef SIGNALS
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-28 13:48:15 -03:00
|
|
|
! function TERMINATE:
|
|
|
|
! ------------------
|
|
|
|
!
|
|
|
|
! Function sets variable iterm after receiving a signal.
|
|
|
|
!
|
2011-04-29 00:51:28 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2011-06-07 17:29:03 -03:00
|
|
|
integer(kind=4) function terminate(sig_num)
|
2011-04-29 00:51:28 -03:00
|
|
|
|
2011-06-07 16:46:09 -03:00
|
|
|
implicit none
|
2011-04-29 00:51:28 -03:00
|
|
|
|
2011-06-07 17:29:03 -03:00
|
|
|
! input arguments
|
|
|
|
!
|
|
|
|
integer(kind=4), intent(in) :: sig_num
|
2012-07-28 12:03:17 -03:00
|
|
|
integer :: iterm
|
|
|
|
|
|
|
|
! common block
|
|
|
|
!
|
|
|
|
common /termination/ iterm
|
2011-06-07 17:29:03 -03:00
|
|
|
|
2011-04-29 00:51:28 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2011-06-07 17:29:03 -03:00
|
|
|
#ifdef INTEL
|
|
|
|
iterm = sig_num
|
2011-06-17 20:21:10 -03:00
|
|
|
#else /* INTEL */
|
|
|
|
iterm = 15
|
2011-06-07 17:29:03 -03:00
|
|
|
#endif /* INTEL */
|
|
|
|
terminate = 1
|
2011-04-29 00:51:28 -03:00
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end
|
|
|
|
#endif /* SIGNALS */
|
|
|
|
|
|
|
|
!===============================================================================
|
|
|
|
!
|