MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
amrvac.t
Go to the documentation of this file.
1!> AMRVAC solves a set of hyperbolic equations
2!> \f$\vec{u}_t + \nabla_x \cdot \vec{f}(\vec{u}) = \vec{s}\f$
3!> using adaptive mesh refinement.
4program amrvac
5
10 use mod_usr
17 use mod_advance, only: process
19 use mod_convert, only: init_convert
20 use mod_physics
28 use mod_rt_sc_slab, only: rt_sc_solve, rt_sc_active
29
30
31 double precision :: time0, time_in
32 logical,save :: part_file_exists=.false.
33
34
35 call comm_start()
36
37 time0 = mpi_wtime()
38 time_advance = .false.
39 time_bc = zero
40
41 ! read command line arguments first
42 call read_arguments()
43
44 ! init_convert is called before usr_init as user might associate a convert method
45 call init_convert()
46 !> eos_init is called prior to physics module
47 call eos_init()
48 ! the user_init routine should load a physics module
49 call usr_init()
50
51 call eos_finalise() !> finalise the EoS dispatch (tables, pointers) for the loaded physics
52
53 !> The EoS dispatch is now complete. Wire it into the two lower-level modules
54 !> that must call the EoS but cannot depend on mod_eos (hence these pointers).
55 !> Both are set only when there is real work to do and guarded at the call site:
56 !> - the ghost-cell update refreshes Te/ne on boundary cells, which only the
57 !> LTE EoS needs (FI's update_eos is a no-op);
58 !> - the physics layer binds the EoS into its source terms (thermal
59 !> conduction / cooling / radiation fluid objects), set only by physics
60 !> modules that have an EoS hook.
61 if (eos%eos_type == 'LTE') update_eos_4_bc => eos%update_eos
63
64 call initialize_amrvac() !> Grid bounds are set up here (ixG^D_ etc)
65
66 if (restart_from_file /= undefined) then
67 ! restart from previous file or dat file conversion
68 ! get input data from previous AMRVAC run
69
70 ! read in dat file
71 call read_snapshot()
72
73 ! rewrite it=0 snapshot when restart from it=0 state
74 if(it==0.and.itsave(1,2)==0) snapshotnext=snapshotnext-1
75
76 if (reset_time) then
77 ! reset it and global time to original value
78 it = it_init
80 ! reset snapshot number
82 end if
83
84 if (reset_it) then
85 ! reset it to original value
86 it = it_init
87 end if
88
89 ! allow user to read extra data before filling boundary condition
90 if (associated(usr_process_grid) .or. &
91 associated(usr_process_global)) then
93 end if
94
95 ! modify initial condition
96 if (firstprocess) then
97 ! update ghost cells for all need-boundary variables before modification
98 call getbc(global_time,0.d0,ps,iwstart,nwgc)
99 call modify_ic
100 end if
101
102 ! select active grids
103 call selectgrids
104
105 ! update ghost cells for all need-boundary variables
106 call getbc(global_time,0.d0,ps,iwstart,nwgc)
107
108 ! reset AMR grid
109 if (reset_grid) then
110 call settree
111 else
112 ! set up boundary flux conservation arrays
113 if (levmax>levmin) call allocatebflux
114 end if
115
116 ! all blocks refined to the same level for output
117 if(convert .and. level_io>0 .or. level_io_min.ne.1 .or. level_io_max.ne.nlevelshi) &
119
120 {^nooned
121 ! improve initial condition after restart and modification
123 }
124
126
127 if(use_particles) then
128 call read_particles_snapshot(part_file_exists)
129 call init_gridvars()
130 if (.not. part_file_exists) call particles_create()
131 if(convert) then
132 call handle_particles()
133 call finish_gridvars()
134 call time_spent_on_particles()
135 call comm_finalize
136 stop
137 end if
138 end if
139
140 if(convert) then
141 if (npe/=1.and.(.not.(index(convert_type,'mpi')>=1)) &
142 .and. convert_type .ne. 'user' &
143 .and. convert_type .ne. 'magnetic_helicity' &
144 .and. convert_type .ne. 'magnetic_topology') &
145 call mpistop("non-mpi conversion only uses 1 cpu")
146 if(mype==0.and.level_io>0) write(unitterm,*)'reset tree to fixed level=',level_io
147
148 !here requires -1 snapshot
150
151 if(associated(phys_special_advance)) then
152 ! e.g. calculate MF velocity from magnetic field
154 end if
155
157 call comm_finalize
158 stop
159 end if
160
161 else
162
163 ! form and initialize all grids at level one
164 call initlevelone
165
166 ! set up and initialize finer level grids, if needed
167 call settree
168
170
171 ! improve initial condition
173
174 ! select active grids
175 call selectgrids
176
177 if (use_particles) then
178 call init_gridvars()
179 call particles_create()
180 end if
181
182 end if
183
184 ! initialize something base on tree information
186
187 ! Populate the additional w state eos variables (if needed)
188 call prepare_eos_w_fields(ps)
189
190 if (mype==0) then
191 print*,'-------------------------------------------------------------------------------'
192 write(*,'(a,f17.3,a)')' Startup phase took : ',mpi_wtime()-time0,' sec'
193 print*,'-------------------------------------------------------------------------------'
194 end if
195
196 ! an interface to allow user to do special things before the main loop
197 if (associated(usr_before_main_loop)) &
199
200 ! do time integration of all grids on all levels
201 call timeintegration()
202
203 if (mype==0) then
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*,'-------------------------------------------------------------------------------'
208 end if
209
210 call comm_finalize
211
212contains
213
214 subroutine timeintegration()
215 use mod_timing
217 use mod_forest, only: nleafs_active
222 use mod_dt, only: setdt
223
224
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
229 logical :: crashall
230
231 time_in=mpi_wtime()
232 time_last_print = -bigdouble
233
235
236 do ifile=nfile,1,-1
237 if(resume_previous_run) then
238 tsavelast(ifile)=aint((global_time+smalldouble)/dtsave(ifile))*dtsave(ifile)
239 itsavelast(ifile)=it/ditsave(ifile)*ditsave(ifile)
240 else
242 itsavelast(ifile)=it
243 end if
244 end do
245
246 ! the next two are used to keep track of the performance during runtime:
248 timelast=mpi_wtime()
249
250 ! ------ start of integration loop. ------------------
251 if (mype==0) then
252 write(*, '(A,ES9.2,A)') ' Start integrating, print status every ', &
253 time_between_print, ' seconds'
254 write(*, '(A4,A10,A12,A12,A12,A14)') ' #', 'it', 'time', 'dt', 'wc-time(s)', 'active_grids'
255 end if
256
257 timeloop0=mpi_wtime()
258 call timers_reset()
259 time_write=0.d0
260 ncells_block={(ixghi^d-2*nghostcells)*}
261 ncells_update=0
262 dt_loop=0.d0
263
264 time_advance=.true.
265
266 ! Pre-compute column mass before first advance so escape probability
267 ! is active from the very first timestep (avoids IC transient)
269
270 ! Open timing breakdown log if requested via savelist
271 if (write_timing_log .and. .not. timing_log_opened .and. mype==0) then
272 if (global_time > 1.0d-10) then
273 open(timing_unit,file=trim(base_filename)//'timing.log', &
274 status='unknown',position='append',action='write')
275 write(timing_unit,'(a,es12.5)') '# --- restart at t = ', global_time
276 else
277 open(timing_unit,file=trim(base_filename)//'timing.log', &
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'
281 end if
282 timing_log_opened = .true.
283 end if
284
285 time_evol : do
286
287 time_before_advance=mpi_wtime()
288 ! set time step
289 tw_setdt=mpi_wtime()
290 call setdt()
291 tw_setdt=mpi_wtime()-tw_setdt
292
293 ! Optionally call a user method that can modify the grid variables at the
294 ! beginning of a time step
295 tw_process=0.d0
296 if (associated(usr_process_grid) .or. &
297 associated(usr_process_global)) then
298 tw_process=mpi_wtime()
300 call prepare_eos_w_fields(ps)
301 tw_process=mpi_wtime()-tw_process
302 end if
303
304 ! linear SC RT is implemented as a global solve with its heating entering the sources as a constant of every stage
305 call rt_sc_solve()
306
307 ! Check if output needs to be written
308 do ifile=nfile,1,-1
309 save_file(ifile) = timetosave(ifile)
310 end do
311
312 call timer_open(tio)
313 timeio0=tio(1)
314
315 if (timeio0 - time_last_print > time_between_print) then
316 time_last_print = timeio0
317 if (mype == 0) then
318 write(*, '(A4,I10,ES12.4,ES12.4,ES12.4,I14)') " #", &
320 end if
321 end if
322
323 ! output data
324 if (any(save_file)) then
325 if(associated(usr_modify_output)) then
326 ! Users can modify or set variables before output is written
327 do iigrid=1,igridstail; igrid=igrids(iigrid);
328 ^d&dxlevel(^d)=rnode(rpdx^d_,igrid);
329 block=>ps(igrid)
330 call usr_modify_output(ixg^ll,ixm^ll,global_time,ps(igrid)%w,ps(igrid)%x)
331 end do
332 end if
333 time_write=0.d0
334 do ifile=nfile,1,-1
335 if (save_file(ifile)) then
336 time_write0=mpi_wtime()
337 call saveamrfile(ifile)
338 time_write=time_write+mpi_wtime()-time_write0
339 end if
340 end do
341 end if
342
343 ! output a snapshot when user write a file named 'savenow' in the same
344 ! folder as the executable amrvac
345 if (mype==0) inquire(file='savenow',exist=save_now)
346 if (npe>1) call mpi_bcast(save_now,1,mpi_logical,0,icomm,ierrmpi)
347
348 if (save_now) then
349 if(mype==0) write(*,'(a,i7,a,i7,a,es12.4)') ' save a snapshot No.',&
350 snapshotnext,' at it=',it,' global_time=',global_time
351 call saveamrfile(1)
352 call saveamrfile(2)
353 call mpi_file_delete('savenow',mpi_info_null,ierrmpi)
354 end if
357
358 pass_wall_time=mpi_wtime()-time0+dt_loop+4.d0*time_write >=wall_time_max
359
360 ! exit time loop if time is up
361 if (it>=it_max .or. global_time>=time_max .or. pass_wall_time .or. final_dt_exit) exit time_evol
362
363 ! Pre-compute column mass for escape probability cooling modification
365
366 ! solving equations
367 tw_tmp=mpi_wtime()
368 call advance(it)
369 tw_advance=mpi_wtime()-tw_tmp
370
371 ! if met unphysical values, output the last good status and stop the run
372 call mpi_allreduce(crash,crashall,1,mpi_logical,mpi_lor,icomm,ierrmpi)
373 if (crashall) then
374 call saveamrfile(1)
375 call saveamrfile(2)
376 if(mype==0) write(*,*) "Error: small value encountered, run crash."
377 call mpi_abort(icomm, iigrid, ierrmpi)
378 end if
379
380 ! Optionally call a user method that can modify the grid variables at the
381 ! end of a time step: this is for two-way coupling to PIC, e.g.
382 if (associated(usr_process_adv_grid) .or. &
383 associated(usr_process_adv_global)) then
385 call prepare_eos_w_fields(ps)
386 end if
387
388 ! update time variables
389 it = it + 1
391
392 ! update AMR mesh and tree (upstream-style: mod-based regrid)
393 call timer_open(tgr)
394 if (mod(it,ditregrid)==0 .and. refine_max_level>1 .and. .not.(fixgrid())) call resettree
395 ! Static-grid cost rebalance: regrid never fires when refine_max_level==1, so the cost-weighted
396 ! load_balance has no trigger. Fire it every lb_interval cycles (the previously-unused knob).
397 ! (AMR grids get the costed rebalance inside resettree already, so this is static-grid only.)
398 if (lb_automatic .and. refine_max_level==1 .and. it>it_init .and. mod(it,lb_interval)==0) &
399 call amr_rebalance
402
403 ! write main-loop timing to user timing log
411 if (mype==0 .and. timing_log_opened .and. &
412 mod(it, timing_log_interval)==0) then
413 write(timing_unit,'(a,i8,1x,es12.5,1x,i6,1x,9(f10.4,1x))') &
414 ' MAIN ', it, global_time, nleafs_active, &
417 call flush(timing_unit)
418 end if
419
420 if(it>9000000)then
422 itsavelast(:)=0
423 end if
424
425 ! count updated cells
426 ncells_update=ncells_update+ncells_block*nleafs_active
427
428 ! time lapses in one loop
429 dt_loop=mpi_wtime()-time_before_advance
430 end do time_evol
431
432 if(use_particles) then
433 call write_particle_output()
434 call finish_gridvars()
435 end if
436
437 time_advance=.false.
438
439 timeloop=mpi_wtime()-timeloop0
440
441 ! rank 0's times; the categories above "computing" are disjoint and sum to the loop
442 if (mype==0) then
443 teos=time_eos()
445 write(*,'(a,f12.3,a)')' Total timeloop took : ',timeloop,' sec'
446 write(*,'(a,f12.3,a)')' Time spent on AMR : ',timegr_tot,' sec'
447 write(*,'(a,f12.2,a)')' Percentage: ',100.0*timegr_tot/timeloop,' %'
448 write(*,'(a,f12.3,a)')' Time spent on IO in loop : ',timeio_tot,' sec'
449 write(*,'(a,f12.2,a)')' Percentage: ',100.0*timeio_tot/timeloop,' %'
450 write(*,'(a,f12.3,a)')' Time spent on ghost cells : ',time_bc,' sec'
451 write(*,'(a,f12.2,a)')' Percentage: ',100.0*time_bc/timeloop,' %'
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,' %'
455 write(*,'(a,f12.3,a)')' - update_eos : ',timeeos_update,' sec'
456 write(*,'(a,f12.3,a)')' - T_from_eint (TC) : ',timeeos_tfromei,' sec'
457 write(*,'(a,f12.3,a)')' - csound2 : ',timeeos_csound,' sec'
458 write(*,'(a,f12.3,a)')' - cons/prim conversion : ',timeeos_conv,' sec'
459 write(*,'(a,f12.3,a)')' - get_pthermal : ',timeeos_pthermal,' sec'
460 end if
461 if(rt_sc_active) then
462 write(*,'(a,f12.3,a)')' Time spent on RT (SC) : ',time_rt,' sec'
463 write(*,'(a,f12.2,a)')' Percentage: ',100.0*time_rt/timeloop,' %'
464 end if
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,' %'
467 if(associated(phys_wb_transform)) then
468 write(*,'(a,f12.3,a)')' - reconstruction : ',time_wb_recon,' sec'
469 write(*,'(a,f12.3,a)')' - WB transform : ',time_wb_transform,' sec'
470 write(*,'(a,f12.3,a)')' - WB inverse + to cons. : ',time_wb_inverse,' sec'
471 end if
472 write(*,'(a,es12.3 )')' Cells updated / proc / sec : ',dble(ncells_update)*dble(nstep)/dble(npe)/timeloop
473 end if
474
475 ! output end state
476 call timer_open(tio)
477 timeio0=tio(1)
478 do ifile=nfile,1,-1
479 if(itsavelast(ifile)<it) call saveamrfile(ifile)
480 end do
481 if (mype==0) call mpi_file_close(log_fh,ierrmpi)
483
484 if (mype==0) then
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)') " #", &
489 end if
490
491 {#IFDEF RAY
492 call time_spent_on_rays
493 }
494
495 if(use_particles) call time_spent_on_particles
496
497 if (use_multigrid) call mg_timers_show(mg)
498 end subroutine timeintegration
499
500 !> Save times are defined by either tsave(isavet(ifile),ifile) or
501 !> itsave(isaveit(ifile),ifile) or dtsave(ifile) or ditsave(ifile)
502 !> tsavestart(ifile) determines first start time. This only affects
503 !> read out times determined by dtsave(ifiles).
504 !> Other conditions may be included.
505 logical function timetosave(ifile)
507
508 integer:: ifile
509 logical:: oksave
510
511 oksave=.false.
512 if (it==itsave(isaveit(ifile),ifile)) then
513 oksave=.true.
514 isaveit(ifile)=isaveit(ifile)+1
515 end if
516 if (it==itsavelast(ifile)+ditsave(ifile)) oksave=.true.
517
518 if (global_time>=tsave(isavet(ifile),ifile).and.global_time-dt<tsave(isavet(ifile),ifile)) then
519 oksave=.true.
520 isavet(ifile)=isavet(ifile)+1
521 end if
522
523 if(global_time>=tsavestart(ifile)-smalldouble)then
524 if (global_time>=tsavelast(ifile)+dtsave(ifile)-smalldouble)then
525 oksave=.true.
526 n_saves(ifile) = n_saves(ifile) + 1
527 endif
528 endif
529
530 if (oksave) then
531 tsavelast(ifile) =global_time
532 itsavelast(ifile)=it
533 end if
534 timetosave=oksave
535
536 return
537 end function timetosave
538
539 !> Return true if the AMR grid should not be adapted any more. This is
540 !> controlled by tfixgrid or itfixgrid. Other conditions may be included.
541 logical function fixgrid()
543
544 fixgrid= (global_time>=tfixgrid .or. it>=itfixgrid)
545 end function fixgrid
546
547end program amrvac
program amrvac
AMRVAC solves a set of hyperbolic equations using adaptive mesh refinement.
Definition amrvac.t:4
subroutine timeintegration()
eos_init is called prior to physics module
Definition amrvac.t:215
Module containing all the time stepping schemes.
Definition mod_advance.t:2
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.
Definition mod_advance.t:23
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()
Definition mod_convert.t:32
Definition mod_dt.t:1
subroutine, public setdt()
setdt - set dt for all levels between levmin and levmax. dtpar>0 --> use fixed dtpar for all level dt...
Definition mod_dt.t:11
Equation of state for AMRVAC, handled through a single eos_container object.
Definition mod_eos.t:30
subroutine, public eos_init()
Phase 'create' (before units are known): allocate the EoS object, read its &eos_list parameters,...
Definition mod_eos.t:244
subroutine, public prepare_eos_w_fields(psx)
Definition mod_eos.t:404
subroutine, public eos_finalise()
Phase 'commit' (after units are known): finalise the dispatch for the loaded physics – wire the metho...
Definition mod_eos.t:274
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.
Definition mod_forest.t:2
integer nleafs_active
Definition mod_forest.t:78
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.
logical save_now
whether a manually inserted snapshot is saved
Module for reading input and writing output.
subroutine saveamrfile(ifile)
subroutine read_arguments()
Read the command line arguments passed to amrvac.
subroutine read_snapshot
Routine to read in snapshots (.dat files). When it cannot recognize the file version,...
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...
Definition mod_physics.t:4
procedure(sub_check_params), pointer phys_bind_eos_to_source
Definition mod_physics.t:53
procedure(sub_wb_transform), pointer phys_wb_transform
Definition mod_physics.t:57
procedure(sub_special_advance), pointer phys_special_advance
Definition mod_physics.t:75
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
Definition mod_timing.t:27
double precision tw_sts_prev
Definition mod_timing.t:26
double precision time_wb_inverse
Definition mod_timing.t:17
double precision tw_process
Definition mod_timing.t:25
double precision tw_advance
Definition mod_timing.t:23
double precision tw_regrid
Definition mod_timing.t:24
integer timing_log_interval
Write timing log every N iterations (default 10).
Definition mod_timing.t:35
integer ittimelast
Definition mod_timing.t:29
double precision time_sts
Definition mod_timing.t:19
double precision timegr_tot
Definition mod_timing.t:11
double precision tw_save
Definition mod_timing.t:24
double precision timeio_tot
Definition mod_timing.t:10
double precision time_in
Definition mod_timing.t:10
double precision tw_eos_tc
Definition mod_timing.t:28
double precision tw_eos_hydro
Definition mod_timing.t:27
double precision tw_tmp
Definition mod_timing.t:26
double precision tw_sts
Definition mod_timing.t:25
double precision time_wb_recon
Definition mod_timing.t:18
double precision time_rt
Definition mod_timing.t:19
double precision timelast
Definition mod_timing.t:22
double precision timeeos_update
Definition mod_timing.t:12
integer, parameter timing_unit
Definition mod_timing.t:30
subroutine timers_reset()
Zero the category timers of the time loop, so that the summary covers the loop only.
Definition mod_timing.t:80
double precision tw_setdt
Definition mod_timing.t:23
logical write_timing_log
Enable writing of detailed timing breakdown log (set via savelist).
Definition mod_timing.t:33
double precision timeeos_pthermal
Definition mod_timing.t:15
subroutine timer_open(t0)
Open a timing window, whose length leaves out the EoS and ghost-cell time spent inside it,...
Definition mod_timing.t:66
double precision timeio0
Definition mod_timing.t:10
double precision timeloop
Definition mod_timing.t:11
double precision timeloop0
Definition mod_timing.t:11
double precision function time_eos()
All EoS time so far; windows that enclose EoS calls subtract its change.
Definition mod_timing.t:60
double precision timeeos_conv
Definition mod_timing.t:14
double precision time_wb_transform
Definition mod_timing.t:17
double precision function timer_close(t0)
Wall time since timer_open, less the EoS and ghost-cell time spent in between.
Definition mod_timing.t:73
double precision timeeos_csound
Definition mod_timing.t:13
double precision tw_eos_tc_prev
Definition mod_timing.t:28
logical timing_log_opened
Definition mod_timing.t:31
double precision timeeos_tfromei
Definition mod_timing.t:16
subroutine, public initialize_trac_after_settree
Definition mod_trac.t:872
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.