98 subroutine intfil(val,mi,mj,time,flaguse,nrowst,ncolst,ilo,ihi,jlo,jhi,level,nvar,naux,msrc)
100 use amr_module, only: possk, mxnest, iregsz, jregsz, nghost, outunit, alloc
101 use amr_module, only: node, lstart, store1, store2, levelptr, timemult,gridnbor
102 use amr_module, only: rnode, ndilo, ndihi, ndjlo, ndjhi, nextfree
104 use amr_module, only: liststart, listofgrids, bndlist, numgrids
109 integer,
intent(in) :: mi, mj, nrowst, ncolst, ilo, ihi, jlo, jhi, level, nvar, naux,msrc
110 real(kind=8),
intent(in) :: time
113 integer(kind=1),
intent(in out) :: flaguse(ilo:ihi, jlo:jhi)
114 real(kind=8),
intent(in out) :: val(nvar,mi,mj)
117 integer :: imlo, jmlo, imhi, jmhi, nx, ny, mitot, mjtot
118 integer :: ixlo, ixhi, jxlo, jxhi, locold, locnew, nextspot
119 integer :: icount, bndnum, bndloc, levst
120 integer :: ivar, i, j, mptr, mstart, loc, numg
121 real(kind=8) :: dt, alphac, alphai
122 logical :: t_interpolate
124 integer :: patch_rect(4)
126 real(kind=8),
parameter :: t_epsilon = 1.0d-4
129 character(len=*),
parameter :: missing_error = &
130 "(' time wanted ',e15.7,' not available from grid ',i4,'level',i4)"
131 character(len=*),
parameter :: time_error = &
132 "(' trying to interpolate from previous time values ',/," // &
133 "' for a patch with corners ilo,ihi,jlo,jhi:'" // &
135 "' from source grid ',i4,' at level ',i4,/," // &
136 "' time wanted ',e24.16,' source time is ',e24.16,/," // &
137 "' alphai, t_epsilon ',2e24.16)"
139 patch_rect = [ilo,ihi,jlo,jhi]
153 if (msrc .eq. -1)
then
154 numg = numgrids(level)
155 levst = liststart(level)
157 bndloc = node(bndlistst,msrc)
158 bndnum = node(bndlistnum,msrc)
159 nextspot = node(bndlistst, msrc)
165 if (msrc .eq. -1)
then
166 mptr = listofgrids(levst+icount-1)
168 mptr = bndlist(nextspot,gridnbor)
172 imlo = node(ndilo, mptr)
173 jmlo = node(ndjlo, mptr)
174 imhi = node(ndihi, mptr)
175 jmhi = node(ndjhi, mptr)
177 nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
178 ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
180 mitot = nx + 2 * nghost
181 mjtot = ny + 2 * nghost
183 ixlo = max(imlo,patch_rect(1))
184 ixhi = min(imhi,patch_rect(2))
185 jxlo = max(jmlo,patch_rect(3))
186 jxhi = min(jmhi,patch_rect(4))
190 if (ixlo <= ixhi .and. jxlo <= jxhi)
then
194 alphac = (rnode(timemult,mptr) - time)/dt
195 alphai = 1.d0 - alphac
197 if ((alphai < -t_epsilon) .or. (alphai > 1.d0 + t_epsilon))
then
198 write(outunit,missing_error) time, mptr, level
199 print missing_error, time, mptr, level
200 write(outunit,
'(A,E24.16)')
'Line 80', dt
201 write(outunit,time_error) patch_rect,mptr,level,time,rnode(timemult,mptr),alphai,t_epsilon
202 print time_error, patch_rect,mptr,level,time,rnode(timemult,mptr),alphai,t_epsilon
203 call
outtre(mstart,.false.,nvar,naux)
208 t_interpolate = .false.
209 if (abs(alphai - 1.d0) < t_epsilon)
then
211 loc = node(store1,mptr)
212 else if (dabs(alphai) .lt. t_epsilon)
then
213 loc = node(store2,mptr)
214 if (level == mxnest)
then
215 write(outunit,
'(A,E24.16)')
'Line 95', dt
216 write(outunit,time_error) patch_rect,mptr,level,time, &
217 rnode(timemult,mptr),alphai,t_epsilon
218 write(*,time_error) patch_rect,mptr,level,time, &
219 rnode(timemult,mptr),alphai,t_epsilon
223 locold = node(store2,mptr)
224 locnew = node(store1,mptr)
225 t_interpolate = .true.
228 if (level == mxnest)
then
229 write(outunit,
'(A,E24.16)')
'Line 107',dt
230 write(outunit,time_error) patch_rect,mptr,level,time,rnode(timemult,mptr),alphai,t_epsilon
231 print time_error, patch_rect,mptr,level,time,rnode(timemult,mptr),alphai,t_epsilon
237 if (.not. t_interpolate)
then
242 val(ivar,i-patch_rect(1)+nrowst,j-jlo+ncolst) = &
243 alloc(
iadd(ivar,i-imlo+nghost+1,j-jmlo+nghost+1))
253 val(ivar,i-patch_rect(1)+nrowst,j-jlo+ncolst) = &
254 alloc(
iadnew(ivar,i-imlo+nghost+1,j-jmlo+nghost+1))*alphai + &
255 alloc(
iadold(ivar,i-imlo+nghost+1,j-jmlo+nghost+1))*alphac
266 if (msrc .ne. -1)
then
267 nextspot = bndlist(nextspot,nextfree)
275 if (jhi >= jregsz(level))
then
276 flaguse(patch_rect(1):ihi, max(jregsz(level),jlo):jhi) = 1
280 flaguse(patch_rect(1):ihi, jlo:min(-1,ncolst + jhi - jlo )) = 1
283 if (patch_rect(1) < 0)
then
284 flaguse(patch_rect(1):min(-1,nrowst + ihi - patch_rect(1)), jlo:jhi) = 1
287 if (ihi >= iregsz(level))
then
288 flaguse(max(iregsz(level),patch_rect(1)):ihi, jlo:jhi) = 1
293 integer pure function iadd(ivar,i,j)
295 integer,
intent(in) :: ivar, i, j
296 iadd = loc + ivar-1 + nvar*((j-1)*mitot+i-1)
301 integer,
intent(in) :: ivar, i, j
302 iadnew = locnew + ivar-1 + nvar*((j-1)*mitot+i-1)
307 integer,
intent(in) :: ivar, i, j
308 iadold = locold + ivar-1 + nvar*((j-1)*mitot+i-1)
subroutine intfil(val, mi, mj, time, flaguse, nrowst, ncolst, ilo, ihi, jlo, jhi, level, nvar, naux, msrc)
Fill values for a patch at the specified level and location, using values from grids at level level O...
integer pure function iadnew(ivar, i, j)
integer pure function iadd(ivar, i, j)
integer pure function iadold(ivar, i, j)
subroutine outtre(mlev, outgrd, nvar, naux)