2D AMRCLAW
spest2.f
Go to the documentation of this file.
1 c
2 c -------------------------------------------------------------
3 c
4  subroutine spest2 (nvar,naux,lcheck,start_time)
5 c
6  use amr_module
7  implicit double precision (a-h,o-z)
8 
9  integer omp_get_thread_num, omp_get_max_threads
10  integer mythread/0/, maxthreads/1/
11  integer listgrids(numgrids(lcheck))
12 
13 c :::::::::::::::::::::::::: SPEST2 :::::::::::::::::::::::::::::::::::
14 c For all grids at level lcheck:
15 c Call user-supplied routine flag2refine to flag any points where
16 c refinement is desired based on user's criterion.
17 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
18 c
19 !$ maxthreads = omp_get_max_threads()
20  call prepgrids(listgrids,numgrids(lcheck),lcheck)
21 
22 c mptr = lstart(lcheck)
23 c 5 continue
24 !$OMP PARALLEL DO PRIVATE(jg,mptr,nx,ny,mitot,mjtot,locnew,locaux),
25 !$OMP& PRIVATE(time,dx,dy,xleft,ybot,xlow,ylow,locbig),
26 !$OMP& PRIVATE(locold,mbuff,mibuff,mjbuff,locamrflags,i),
27 !$OMP& SHARED(numgrids,listgrids,lcheck,nghost,nvar,naux),
28 !$OMP& SHARED(start_time,possk,flag_gradient,ibuff),
29 !$OMP& SHARED(tolsp,alloc,node,rnode,hxposs,hyposs),
30 !$OMP& DEFAULT(none),
31 !$OMP& SCHEDULE(DYNAMIC,1)
32  do jg = 1, numgrids(lcheck)
33  mptr = listgrids(jg)
34  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
35  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
36  mitot = nx + 2*nghost
37  mjtot = ny + 2*nghost
38  locnew = node(store1,mptr)
39  locaux = node(storeaux,mptr)
40  time = rnode(timemult,mptr)
41  dx = hxposs(lcheck)
42  dy = hyposs(lcheck)
43  xleft = rnode(cornxlo,mptr)
44  ybot = rnode(cornylo,mptr)
45  xlow = xleft - nghost*dx
46  ylow = ybot - nghost*dy
47 c
48  locbig = igetsp(mitot*mjtot*nvar)
49  node(tempptr,mptr) = locbig
50 c # straight copy into scratch array so don't mess up latest soln.
51 
52 c ## at later times want to use newest soln for spatial error flagging
53 c ## at initial time want to use initial conditions (so retain symmetry for example)
54  if (start_time+possk(lcheck) .ne. time) then ! exact equality test here. counting on ieee arith.
55  do 10 i = 1, mitot*mjtot*nvar
56  10 alloc(locbig+i-1) = alloc(locnew+i-1)
57 
58  call bound(time,nvar,nghost,alloc(locbig),mitot,mjtot,mptr,
59  1 alloc(locaux),naux)
60  else ! boundary values already in locold
61  locold = node(store2,mptr)
62  do 11 i = 1, mitot*mjtot*nvar
63  11 alloc(locbig+i-1) = alloc(locold+i-1)
64  endif
65 c
66 c get user flags for refinement, which might be based on spatial gradient,
67 c for example. Use old values of soln at time t before
68 c integration to get accurate boundary gradients
69 c
70  if (flag_gradient) then
71 ! need at least as big as nghost to fit ghost cells. if ibuff is bigger make
72 ! the flagged array bigger so can buffer in place
73  mbuff = max(nghost,ibuff+1)
74  mibuff = nx + 2*mbuff !NOTE THIS NEW DIMENSIONING
75 c !TO ALLOW ROOM FOR BUFFERING IN PLACE
76  mjbuff = ny + 2*mbuff
77  locamrflags = igetsp(mibuff*mjbuff)
78  node(storeflags,mptr) = locamrflags
79 
80  do 20 i = 1, mibuff*mjbuff
81  20 alloc(locamrflags+i-1) = goodpt
82 
83 c # call user-supplied routine to flag any points where
84 c # refinement is desired based on user's criterion.
85 c # Default version compares spatial gradient to tolsp.
86 
87  call flag2refine2(nx,ny,nghost,mbuff,nvar,naux,xleft,ybot,
88  & dx,dy,time,lcheck,tolsp,alloc(locbig),
89  & alloc(locaux),alloc(locamrflags),goodpt,badpt)
90  endif
91 
92  end do
93 c mptr = node(levelptr,mptr)
94 c if (mptr .ne. 0) go to 5
95 c
96  return
97  end
98 
function igetsp(nwords)
Definition: igetsp.f:4
subroutine flag2refine2(mx, my, mbc, mbuff, meqn, maux, xlower, ylower, dx, dy, t, level, tolsp, q, aux, amrflags, DONTFLAG, DOFLAG)
User routine to control flagging of points for refinement.
subroutine prepgrids(listgrids, num, level)
Definition: advanc.f:140
subroutine bound(time, nvar, ng, valbig, mitot, mjtot, mptr, aux, naux)
This routine sets the boundary values for a given grid at level level.
Definition: bound.f90:51
subroutine spest2(nvar, naux, lcheck, start_time)
Definition: spest2.f:4