Check that potential grid mnew is completely contained in coarser grids at level lbase (>1) that will stay fixed during this regridding step.
This version tries to do it without using domflags slower but better if cant afford memory over entire domain
23 implicit double precision (a-h, o-z)
25 logical debug/.false./
26 integer ist(3),iend(3),jst(3),jend(3),ishift(3),jshift(3)
27 logical borderx, bordery
30 c index into
alloc from iclo:ichi and jclo:jchi, not 0..leni/j.
31 iadd(i,j) = locm + i - iclo + leni*(j-jclo)
33 c :::::::::::::::::::
basecheck :::::::::::::::::::::::::::
35 c
basecheck -
check that potential grid mnew is completely contained
36 c in coarser grids at level
'lbase' (>1) that will
37 c stay fixed during this regridding step
39 c this version tries to
do it without using domflags
40 c slower but better
if cant afford memory over entire
domain 42 c mcheck is one bigger since for proper nesting, cell must be
43 c at least one away from boundary of a parent grid, unless
45 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
50 borderx = (ilo .eq. 0 .or. ihi .eq.
iregsz(levnew)-1)
51 bordery = (jlo .eq. 0 .or. jhi .eq.
jregsz(levnew)-1)
54 c
if (debug)
write(
outunit,100) mnew,lbase,ilo,ihi,jlo,jhi,levnew
55 c100
format(
"NESTCK2 testing grid ",i5,
" base level ",i5,/,
56 c .
" new grid from ilo:hi: ",2i12,
" to ",2i12,
" at level ",i4)
58 c on to initializing for the given grid and its nest checking
61 do 5 lev = lbase, levnew-1
62 levratx = levratx *
intratx(lev)
63 levraty = levraty *
intraty(lev)
66 c widen by 1 cell(proper nesting),
then project to lbase
67 c this might stick out of
domain, fix later
68 c figure out
size for scratch storage on base grid for testing
73 do lev = levnew-1,lbase,-1
83 c
write(
outunit,111) lev, iclo,ichi,jclo,jchi
84 c111
format(10x,
"at level",i5,
" projected coords ilo:hi:",2i10,
88 c high end of
integer grid index truncates during the divide
89 c
if it were exactly lined up with coarser grid it would
90 c not be properly nested, but since we added one to the index
91 c space, we took care of that already.
93 c
write(
outunit,108) ilo-1,ihi+1,jlo-1,jhi+1
94 c
write(
outunit,109) levratx,levraty
95 c108
format(
" enlarged (by 1) fine grid from ilo:hi:",2i12,
96 c .
" to jlo:hi:", 2i12)
97 c109
format(
" refinement factors to base grid of ", 2i12)
98 c
write(
outunit,101) iclo,ichi,jclo,jchi
99 c101
format(
"coarsened to lbase, grid from iclo:hi: ",2i12,
100 c .
" to jclo:hi:",2i12)
103 if (.not. (
xperdom .and. borderx) .and.
104 . .not. (
yperdom .and. bordery))
then 107 ichi = min(ichi,
iregsz(lbase)-1)
108 jchi = min(jchi,
jregsz(lbase)-1)
112 leni = ichi - iclo + 1
113 lenj = jchi - jclo + 1
114 lenrect = leni * lenj
116 alloc(locm:locm+lenrect-1) = 0.
118 c
if mnew on
domain boundary fix flags so ok.
119 c fix extra border, and first/last
real edge
120 if (ilo .eq. 0 .and. .not.
xperdom)
then 133 if (jlo .eq. 0 .and. .not.
yperdom)
then 153 if ((.not. (
xperdom .and. borderx)) .and.
154 . .not. (
yperdom .and. bordery))
then 155 ixlo = max(iclo,iblo)
156 ixhi = min(ichi,ibhi)
157 jxlo = max(jclo,jblo)
158 jxhi = min(jchi,jbhi)
159 if (.not.((ixlo.le.ixhi) .and. (jxlo.le.jxhi)))
go to 30
168 c periodic case: initialize for potential periodicity
169 c each patch divided into 9 regions(some may be empty)
170 c e.g. i from(ilo,-1), (0,
iregsz(level)-1),(
iregsz(level),ihi)
171 c except using enlarged grid(ilo-1 to ihi+1)
173 call setindices(ist,iend,jst,jend,iclo,ichi,jclo,jchi,
174 . ishift,jshift,lbase)
176 c compare all regions of coarsened patch with one lbase grid at a time
178 i1 = max(iclo,ist(i))
179 i2 = min(ichi, iend(i))
181 j1 = max(jclo, jst(j))
182 j2 = min(jchi, jend(j))
184 if (.not. ((i1 .le. i2) .and. (j1 .le. j2)))
go to 25
186 c patch(possibly periodically wrapped) not empty.
187 c see
if intersects base grid. wrap coords for periodicity
188 i1_shifted = i1 + ishift(i)
189 i2_shifted = i2 + ishift(i)
190 j1_shifted = j1 + jshift(j)
191 j2_shifted = j2 + jshift(j)
193 ixlo = max(i1_shifted,iblo)
194 ixhi = min(i2_shifted,ibhi)
195 jxlo = max(j1_shifted,jblo)
196 jxhi = min(j2_shifted,jbhi)
198 if (.not.((ixlo.le.ixhi) .and. (jxlo.le.jxhi)))
go to 25
199 c mark intersected regions with 1
202 c need to mark nesting of orig coords, not coarsened shifted indices
203 ix_unshifted = (ix - ishift(i))
204 jx_unshifted = (jx - jshift(j))
205 alloc(
iadd(ix_unshifted,jx_unshifted)) = 1.
212 if (mptr .ne. 0)
go to 20
214 c output for debugging
216 c
do 34 jj = jclo, jchi
217 c j = jchi + jclo - jj
224 c
if any zeroes left mnew not nested
234 c
if made it here
then grid is nested
237 99
call reclam(locm, lenrect)
function igetsp(nwords)
Allocate contiguous space of length nword in main storage array alloc.
subroutine reclam(index, nwords)
integer, dimension(maxlv) iregsz
logical function basecheck(mnew, lbase, ilo, ihi, jlo, jhi, nvar, naux, thisBuff)
Check that potential grid mnew is completely contained in coarser grids at level lbase (>1) that will...
integer, parameter ndihi
global i index of right border of this grid
integer, dimension(maxlv) jregsz
integer, dimension(nsize, maxgr) node
integer, parameter nestlevel
AMR level of the grid.
integer pure function iadd(ivar, i, j)
subroutine check(nsteps, time, nvar, naux)
integer, parameter ndilo
global i index of left border of this grid
integer, parameter ndjlo
global j index of lower border of this grid
integer, dimension(maxlv) lstart
integer, dimension(maxlv) intraty
integer, parameter outunit
subroutine setindices(ist, iend, jst, jend, ilo, ihi, jlo, jhi, ishift, jshift, level)
integer, parameter ndjhi
global j index of upper border of this grid
integer, dimension(maxlv) intratx
integer, parameter levelptr
node number (index) of next grid on the same level
subroutine domain(nvar, vtime, nx, ny, naux, start_time)
The module contains the definition of a "node descriptor" as well as other global variables used duri...
real(kind=8), dimension(:), allocatable alloc