2D AMRCLAW
check.f
Go to the documentation of this file.
1 c
2 c ---------------------------------------------------------
3 c
4  subroutine check(nsteps,time,nvar,naux)
5 c
6 c :::::::::::::::::::::: CHECK ::::::::::::::::::::::::::::::::;
7 c check point routine - can only call at end of coarse grid cycle
8 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
9 
10  use amr_module
11  use gauges_module, only: num_gauges
13 
14  implicit double precision (a-h,o-z)
15  integer tchkunit
16  parameter(tchkunit = 13)
17  character chkname*13
18  character tchkname*13
19 
20  write(6,601) time,nsteps
21  601 format('Creating checkpoint file at t = ',e16.9,' nsteps = ',i5)
22 c
23  if (checkpt_style < 0) then
24 
25 c # Alternate between two sets of files, overwriting the oldest
26 c # one, so that files do not accumulate with frequent checkpoints.
27 c
28 c # Note that logical check_a is stored in amr_module, initialized
29 c # in amr2 and perhaps reset properly in restrt.
30 
31  if (check_a) then
32  chkname = 'fort.chkaaaaa'
33  tchkname = 'fort.tckaaaaa'
34  else
35  chkname = 'fort.chkbbbbb'
36  tchkname = 'fort.tckbbbbb'
37  endif
38  check_a = .not. check_a ! to use other file next time
39 
40  else
41 
42 c # make a new checkpoint file for this time
43 c ### make the file name showing the time step
44 c
45  chkname = 'fort.chkxxxxx'
46  tchkname = 'fort.tckxxxxx'
47  nstp = nsteps
48  do 20 ipos = 13, 9, -1
49  idigit = mod(nstp,10)
50  chkname(ipos:ipos) = char(ichar('0') + idigit)
51  tchkname(ipos:ipos) = char(ichar('0') + idigit)
52  nstp = nstp / 10
53  20 continue
54  endif
55 
56  open(unit=tchkunit,file=tchkname,status='unknown',
57  . form='formatted')
58  open(unit=chkunit,file=chkname,status='unknown',
59  . form='unformatted')
60 c
61 c ### dump the data
62 c
63  write(chkunit) lenmax,lendim,memsize
64  write(chkunit) (alloc(i),i=1,lendim)
65  write(chkunit) hxposs,hyposs,possk,icheck
66  write(chkunit) lfree,lenf
67  write(chkunit) rnode,node,lstart,newstl,listsp,tol,
68  1 ibuff,mstart,ndfree,ndfree_bnd,lfine,iorder,mxnest,
69  2 intratx,intraty,kratio,iregsz,jregsz,
70  2 iregst,jregst,iregend,jregend,
71  3 numgrids,kcheck,nsteps,
72  3 time,matlabu
73  write(chkunit) avenumgrids, iregridcount,
74  1 evol,rvol,rvoll,lentot,tmass0,cflmax,
75  2 tvoll,tvollcpu,timetick,timetickcpu,
76  3 timestepgrid,timestepgridcpu,
77  4 timebound,timeboundcpu,
78  5 timeregridding,timeregriddingcpu,
79  6 timevalout,timevaloutcpu
80 c
81  close(chkunit)
82 
83 c # flush open running output files fort.amr, fort.gauge, fort.debug
84 c # so if code dies it will at least have output up to this checkpoint time
85 
86  flush(outunit) ! defined in amr_module.f90
87  flush(dbugunit) ! defined in amr_module.f90
88 c flush(OUTGAUGEUNIT) ! defined in gauges_module.f90
89  do ii = 1, num_gauges
91  end do
92 
93 c # write the time stamp file last so it's not updated until data is
94 c # all dumped, in case of crash mid-dump.
95  write(tchkunit,*) 'Checkpoint file at time t = ',time
96  write(tchkunit,*) 'alloc size memsize = ',memsize
97  write(tchkunit,*) 'Number of steps taken = ',nsteps
98  close(tchkunit)
99 c
100  return
101  end
subroutine check(nsteps, time, nvar, naux)
Definition: check.f:4
subroutine print_gauges_and_reset_nextloc(gauge_num)