31 double precision :: time0, time_in
32 logical,
save :: part_file_exists=.false.
128 call read_particles_snapshot(part_file_exists)
132 call handle_particles()
133 call finish_gridvars()
134 call time_spent_on_particles()
145 call mpistop(
"non-mpi conversion only uses 1 cpu")
191 print*,
'-------------------------------------------------------------------------------'
192 write(*,
'(a,f17.3,a)')
' Startup phase took : ',mpi_wtime()-time0,
' sec'
193 print*,
'-------------------------------------------------------------------------------'
204 time0=mpi_wtime()-time0
205 print*,
'-------------------------------------------------------------------------------'
206 write(*,
'(a,f17.3,a,f17.3,a)')
' Finished AMRVAC in : ',time0,
' sec', dble(
npe)*time0/3.6d3,
' core hour'
207 print*,
'-------------------------------------------------------------------------------'
225 double precision :: time_last_print, time_write0, time_write, time_before_advance, dt_loop
226 double precision :: tio(3), tgr(3), time_comp, teos
227 integer(kind=8) ncells_update
228 integer :: level, ifile, ncells_block, igrid, iigrid
232 time_last_print = -bigdouble
252 write(*,
'(A,ES9.2,A)')
' Start integrating, print status every ', &
254 write(*,
'(A4,A10,A12,A12,A12,A14)')
' #',
'it',
'time',
'dt',
'wc-time(s)',
'active_grids'
274 status=
'unknown',position=
'append',action=
'write')
278 status=
'replace',action=
'write')
279 write(
timing_unit,
'(a)')
'# MAIN: it t nleafs setdt advance sts' &
280 //
' eos_hydro eos_tc regrid save process adv-sts'
287 time_before_advance=mpi_wtime()
318 write(*,
'(A4,I10,ES12.4,ES12.4,ES12.4,I14)')
" #", &
327 do iigrid=1,igridstail; igrid=igrids(iigrid);
336 time_write0=mpi_wtime()
338 time_write=time_write+mpi_wtime()-time_write0
349 if(
mype==0)
write(*,
'(a,i7,a,i7,a,es12.4)')
' save a snapshot No.',&
353 call mpi_file_delete(
'savenow',mpi_info_null,
ierrmpi)
376 if(
mype==0)
write(*,*)
"Error: small value encountered, run crash."
413 write(
timing_unit,
'(a,i8,1x,es12.5,1x,i6,1x,9(f10.4,1x))') &
429 dt_loop=mpi_wtime()-time_before_advance
433 call write_particle_output()
434 call finish_gridvars()
445 write(*,
'(a,f12.3,a)')
' Total timeloop took : ',
timeloop,
' sec'
446 write(*,
'(a,f12.3,a)')
' Time spent on AMR : ',
timegr_tot,
' sec'
448 write(*,
'(a,f12.3,a)')
' Time spent on IO in loop : ',
timeio_tot,
' sec'
450 write(*,
'(a,f12.3,a)')
' Time spent on ghost cells : ',
time_bc,
' sec'
452 if(eos%eos_type /=
'FI')
then
453 write(*,
'(a,f12.3,a)')
' Time spent on eos : ',teos,
' sec'
454 write(*,
'(a,f12.2,a)')
' Percentage: ',100.0*teos/
timeloop,
' %'
458 write(*,
'(a,f12.3,a)')
' - cons/prim conversion : ',
timeeos_conv,
' sec'
461 if(rt_sc_active)
then
462 write(*,
'(a,f12.3,a)')
' Time spent on RT (SC) : ',
time_rt,
' sec'
465 write(*,
'(a,f12.3,a)')
' Time spent on computing : ',time_comp,
' sec'
466 write(*,
'(a,f12.2,a)')
' Percentage: ',100.0*time_comp/
timeloop,
' %'
468 write(*,
'(a,f12.3,a)')
' - reconstruction : ',
time_wb_recon,
' sec'
470 write(*,
'(a,f12.3,a)')
' - WB inverse + to cons. : ',
time_wb_inverse,
' sec'
472 write(*,
'(a,es12.3 )')
' Cells updated / proc / sec : ',dble(ncells_update)*dble(
nstep)/dble(
npe)/
timeloop
485 write(*,
'(a,f12.3,a)')
' Total time spent on IO : ',
timeio_tot,
' sec'
486 write(*,
'(a,f12.3,a)')
' Total timeintegration took : ',mpi_wtime()-
time_in,
' sec'
487 write(*,
'(A4,I10,ES12.3,ES12.3,ES12.3)')
" #", &
492 call time_spent_on_rays
505 logical function timetosave(ifile)
537 end function timetosave
541 logical function fixgrid()
program amrvac
AMRVAC solves a set of hyperbolic equations using adaptive mesh refinement.
subroutine timeintegration()
eos_init is called prior to physics module
Module containing all the time stepping schemes.
subroutine, public process_advanced(iit, qt)
process_advanced is user entry in time loop, just after advance allows to modify solution,...
subroutine, public advance(iit)
Advance all the grids over one time step, including all sources.
subroutine, public process(iit, qt)
process is a user entry in time loop, before output and advance allows to modify solution,...
subroutine, public resettree
reset AMR and (de)allocate boundary flux storage at level changes
subroutine, public resettree_convert
Force the tree to desired level(s) from level_io(_min/_max) used for conversion to vtk output.
subroutine, public settree
Build up AMR.
Module to coarsen and refine grids for AMR.
subroutine, public amr_rebalance
Cost-weighted rebalance without refine/coarsen. For static/uniform grids (refine_max_level=1) amr_coa...
subroutine, public comm_start
Initialize the MPI environment.
subroutine, public comm_finalize
Finalize (or shutdown) the MPI environment.
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
subroutine generate_plotfile
subroutine init_convert()
subroutine, public setdt()
setdt - set dt for all levels between levmin and levmax. dtpar>0 --> use fixed dtpar for all level dt...
Equation of state for AMRVAC, handled through a single eos_container object.
subroutine, public eos_init()
Phase 'create' (before units are known): allocate the EoS object, read its &eos_list parameters,...
subroutine, public prepare_eos_w_fields(psx)
subroutine, public eos_finalise()
Phase 'commit' (after units are known): finalise the dispatch for the loaded physics – wire the metho...
Module for escape probability radiative cooling modification.
subroutine, public escape_prob_compute_colmass()
Compute column mass from the corona toward the footpoints and scatter to wextra. Called once per time...
Module for flux conservation near refinement boundaries.
subroutine, public allocatebflux
Module with basic grid data structures.
update ghost cells of all blocks including physical boundaries
subroutine getbc(time, qdt, psb, nwstart, nwbc)
do update ghost cells of all blocks including physical boundaries
procedure(update_eos_bc_sub), pointer update_eos_4_bc
This module contains definitions of global parameters and variables and some generic functions/subrou...
double precision, dimension(nfile) tsavelast
type(state), pointer block
Block pointer for using one block and its previous state.
integer nstep
How many sub-steps the time integrator takes.
integer it_max
Stop the simulation after this many time steps have been taken.
logical reset_it
If true, reset iteration count to 0.
integer ixghi
Upper index of grid block arrays.
logical, dimension(nfile) save_file
whether or not to save an output file
logical resume_previous_run
If true, restart a previous run from the latest snapshot.
double precision global_time
The global simulation time.
integer, dimension(nsavehi, nfile) itsave
Save output of type N on iterations itsave(:, N).
double precision time_max
End time for the simulation.
double precision time_init
Start time for the simulation.
logical firstprocess
If true, call initonegrid_usr upon restarting.
integer snapshotini
Resume from the snapshot with this index.
integer it
Number of time steps taken.
integer it_init
initial iteration count
integer ditregrid
Reconstruct the AMR grid once every ditregrid iteration(s).
character(len=std_len) convert_type
Which format to use when converting.
integer itfixgrid
Fix the AMR grid after this many time steps.
integer, parameter nlevelshi
The maximum number of levels in the grid refinement.
logical phys_escape_prob
Use escape probability for radiative cooling modification.
logical use_particles
Use particles module or not.
integer icomm
The MPI communicator.
logical reset_time
If true, reset iteration count and global_time to original values, and start writing snapshots at ind...
integer mype
The rank of the current MPI task.
integer, dimension(1:nfile) n_saves
Number of saved files of each type.
double precision, dimension(nfile) tsavestart
Start of read out (not counting specified read outs).
integer, dimension(nfile) ditsave
Repeatedly save output of type N when ditsave(N) time steps have passed.
double precision dt
global time step
double precision wall_time_max
Ending wall time (in hours) for the simulation.
integer ierrmpi
A global MPI error return code.
logical autoconvert
If true, already convert to output format during the run.
double precision, dimension(:), allocatable, parameter d
integer slowsteps
If > 1, then in the first slowsteps-1 time steps dt is reduced by a factor .
integer snapshotnext
IO: snapshot and collapsed views output numbers/labels.
integer npe
The number of MPI tasks.
integer, dimension(nfile) itsavelast
double precision time_between_print
to monitor timeintegration loop at given wall-clock time intervals
integer, parameter unitterm
Unit for standard output.
logical lb_automatic
Cost-weighted automatic load balancer toggle (off by default). When .true., the SFC partitioner cuts ...
double precision, dimension(nfile) dtsave
Repeatedly save output of type N when dtsave(N) simulation time has passed.
integer lb_interval
Rebalance every lb_interval cycles when lb_automatic is on.
logical time_advance
do time evolving
character(len=std_len) restart_from_file
If not 'unavailable', resume from snapshot with this base file name.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer, parameter filelog_
Constant indicating log output.
integer, parameter fileout_
Constant indicating regular output.
double precision time_bc
accumulated wall-clock time spent on boundary conditions
double precision tfixgrid
Fix the AMR grid after this time.
integer nghostcells
Number of ghost cells surrounding a grid.
character(len= *), parameter undefined
double precision, dimension(nsavehi, nfile) tsave
Save output of type N on times tsave(:, N).
logical convert
If true and restart_from_file is given, convert snapshots to other file formats.
logical reset_grid
If true, rebuild the AMR grid upon restarting.
logical crash
Save a snapshot before crash a run met unphysical values.
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
logical use_multigrid
Use multigrid (only available in 2D and 3D).
character(len=std_len) base_filename
Base file name for simulation output, which will be followed by a number.
integer refine_max_level
Maximal number of AMR levels.
integer, parameter nfile
Number of output methods.
logical pass_wall_time
If true, wall time is up, modify snapshotnext for later overwrite.
logical final_dt_exit
Force timeloop exit when final dt < dtmin.
integer, dimension(nfile) isaveit
integer, dimension(nfile) isavet
integer log_fh
MPI file handle for logfile.
subroutine, public improve_initial_condition()
improve initial condition after initialization
subroutine, public initlevelone
Generate and initialize all grids at the coarsest level (level one).
subroutine, public modify_ic
modify initial condition
This module handles the initialization of various components of amrvac.
subroutine, public initialize_amrvac()
Initialize amrvac: read par files and initialize variables.
Module to couple the octree-mg library to AMRVAC. This file uses the VACPP preprocessor,...
type(mg_t) mg
Data structure containing the multigrid tree.
subroutine mg_setup_multigrid()
Setup multigrid for usage.
Module containing all the particle routines.
subroutine particles_create()
Create initial particles.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_check_params), pointer phys_bind_eos_to_source
procedure(sub_wb_transform), pointer phys_wb_transform
procedure(sub_special_advance), pointer phys_special_advance
Public face of the short-characteristics (SC) radiative transfer and its coupling to the (M)HD.
subroutine, public selectgrids
double precision tw_eos_hydro_prev
double precision tw_sts_prev
double precision time_wb_inverse
double precision tw_process
double precision tw_advance
double precision tw_regrid
integer timing_log_interval
Write timing log every N iterations (default 10).
double precision time_sts
double precision timegr_tot
double precision timeio_tot
double precision tw_eos_tc
double precision tw_eos_hydro
double precision time_wb_recon
double precision timelast
double precision timeeos_update
integer, parameter timing_unit
subroutine timers_reset()
Zero the category timers of the time loop, so that the summary covers the loop only.
double precision tw_setdt
logical write_timing_log
Enable writing of detailed timing breakdown log (set via savelist).
double precision timeeos_pthermal
subroutine timer_open(t0)
Open a timing window, whose length leaves out the EoS and ghost-cell time spent inside it,...
double precision timeloop
double precision timeloop0
double precision function time_eos()
All EoS time so far; windows that enclose EoS calls subtract its change.
double precision timeeos_conv
double precision time_wb_transform
double precision function timer_close(t0)
Wall time since timer_open, less the EoS and ghost-cell time spent in between.
double precision timeeos_csound
double precision tw_eos_tc_prev
logical timing_log_opened
double precision timeeos_tfromei
subroutine, public initialize_trac_after_settree
Module with all the methods that users can customize in AMRVAC.
procedure(process_grid), pointer usr_process_grid
procedure(process_adv_grid), pointer usr_process_adv_grid
procedure(sub_modify_io), pointer usr_modify_output
procedure(p_no_args), pointer usr_before_main_loop
procedure(process_global), pointer usr_process_global
procedure(process_adv_global), pointer usr_process_adv_global
This is a template for a new user problem of mhd.
subroutine usr_init()
This routine should set user methods, and activate the physics module.