| 1 | !!****if* source/Grid/GridMain/Grid_getBlkPtr
|
|---|
| 2 | !!
|
|---|
| 3 | !! NAME
|
|---|
| 4 | !! Grid_getBlkPtr
|
|---|
| 5 | !!
|
|---|
| 6 | !! SYNOPSIS
|
|---|
| 7 | !!
|
|---|
| 8 | !! Grid_getBlkPtr(integer(IN) :: blockID,
|
|---|
| 9 | !! real(pointer)(:,:,:,:) :: dataPtr,
|
|---|
| 10 | !! integer(IN),optional :: gridDataStruct)
|
|---|
| 11 | !!
|
|---|
| 12 | !! DESCRIPTION
|
|---|
| 13 | !!
|
|---|
| 14 | !! Gets a pointer to a single block of simulation data from the
|
|---|
| 15 | !! specified Grid data structure. The block includes guard cells.
|
|---|
| 16 | !! If the optional argument "gridDataStructure" is not specified,
|
|---|
| 17 | !! it returns a block from cell centered data structure.
|
|---|
| 18 | !!
|
|---|
| 19 | !! When using Paramesh 4 in NO_PERMANENT_GUARDCELLS mode, it is important to
|
|---|
| 20 | !! release the block pointer for a block before getting it for another block.
|
|---|
| 21 | !! For example if pointer to block 1 is not yet released and the user
|
|---|
| 22 | !! tries to get a pointer to block 2, the routine will abort.
|
|---|
| 23 | !!
|
|---|
| 24 | !! ARGUMENTS
|
|---|
| 25 | !!
|
|---|
| 26 | !! blockID : the local blockid
|
|---|
| 27 | !!
|
|---|
| 28 | !! dataPtr : Pointer to the data block
|
|---|
| 29 | !!
|
|---|
| 30 | !! gridDataStruct : optional integer value specifying data structure.
|
|---|
| 31 | !! The options are defined in constants.h and they are :
|
|---|
| 32 | !! CENTER cell centered variables (default)
|
|---|
| 33 | !! FACEX face centered variable on faces along IAXIS
|
|---|
| 34 | !! FACEY face centered variable on faces along JAXIS
|
|---|
| 35 | !! FACEZ face centered variable on faces along IAXIS
|
|---|
| 36 | !! SCRATCH scratch space that can fit cell and face centered variables
|
|---|
| 37 | !! SCRATCH_CTR scratch space for cell centered variables
|
|---|
| 38 | !! SCRATCH_FACEX scratch space facex variables
|
|---|
| 39 | !! SCRATCH_FACEY scratch space facey variables
|
|---|
| 40 | !! SCRATCH_FACEZ scratch space facez variables
|
|---|
| 41 | !!
|
|---|
| 42 | !!
|
|---|
| 43 | !!
|
|---|
| 44 | !! NOTES
|
|---|
| 45 | !!
|
|---|
| 46 | !! Grid_getBlkPtr is an accessor function that passes a pointer
|
|---|
| 47 | !! as an argument and requires an explicit interface for most compilers.
|
|---|
| 48 | !!
|
|---|
| 49 | !! Don't forget to call Grid_releaseBlkPtr when you are finished with it!
|
|---|
| 50 | !!
|
|---|
| 51 | !!***
|
|---|
| 52 |
|
|---|
| 53 | !!REORDER(5): unk, facevar[xyz], scratch_ctr, scratch_facevar[xyz]
|
|---|
| 54 | !!REORDER(4): dataPtr
|
|---|
| 55 | !!FOR FUTURE: Add REORDER for unk, facevar[xyz]1, etc.?
|
|---|
| 56 |
|
|---|
| 57 | #ifdef DEBUG_ALL
|
|---|
| 58 | #define DEBUG_GRID
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | subroutine Grid_getBlkPtr(blockID,dataPtr, gridDataStruct)
|
|---|
| 62 |
|
|---|
| 63 | #include "constants.h"
|
|---|
| 64 | #include "Flash.h"
|
|---|
| 65 |
|
|---|
| 66 | use physicaldata, ONLY : unk, facevarx, facevary, facevarz
|
|---|
| 67 | use Driver_interface, ONLY : Driver_abortFlash
|
|---|
| 68 | use gr_specificData, ONLY : scratch,scratch_ctr,&
|
|---|
| 69 | scratch_facevarx,scratch_facevary,scratch_facevarz
|
|---|
| 70 |
|
|---|
| 71 | implicit none
|
|---|
| 72 | integer, intent(in) :: blockID
|
|---|
| 73 | real, dimension(:,:,:,:), pointer :: dataPtr
|
|---|
| 74 | integer, optional,intent(in) :: gridDataStruct
|
|---|
| 75 |
|
|---|
| 76 | integer :: gds, blkPtrRefCount, lastBlkPtrGotten
|
|---|
| 77 | logical :: validGridDataStruct
|
|---|
| 78 |
|
|---|
| 79 | #ifdef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 80 | integer :: idest, iopt, nlayers, icoord
|
|---|
| 81 | logical :: lcc, lfc, lec, lnc, l_srl_only, ldiag
|
|---|
| 82 | logical,dimension(NUNK_VARS) :: save_ccMask
|
|---|
| 83 | #if NFACE_VARS >0
|
|---|
| 84 | logical, dimension(3,NFACE_VARS) :: save_fcMask
|
|---|
| 85 | #endif
|
|---|
| 86 | #endif
|
|---|
| 87 |
|
|---|
| 88 | #ifdef DEBUG_GRID
|
|---|
| 89 | if(present(gridDataStruct)) then
|
|---|
| 90 | validGridDataStruct = .false.
|
|---|
| 91 | validGridDataStruct= (gridDataStruct == CENTER).or.validGridDataStruct
|
|---|
| 92 | validGridDataStruct= (gridDataStruct == FACEX).or.validGridDataStruct
|
|---|
| 93 | validGridDataStruct= (gridDataStruct == FACEY).or.validGridDataStruct
|
|---|
| 94 | validGridDataStruct= (gridDataStruct == FACEZ).or.validGridDataStruct
|
|---|
| 95 | validGridDataStruct= (gridDataStruct == SCRATCH).or.validGridDataStruct
|
|---|
| 96 | validGridDataStruct= (gridDataStruct == SCRATCH_CTR).or.validGridDataStruct
|
|---|
| 97 | validGridDataStruct= (gridDataStruct == SCRATCH_FACEX).or.validGridDataStruct
|
|---|
| 98 | validGridDataStruct= (gridDataStruct == SCRATCH_FACEY).or.validGridDataStruct
|
|---|
| 99 | validGridDataStruct= (gridDataStruct == SCRATCH_FACEZ).or.validGridDataStruct
|
|---|
| 100 |
|
|---|
| 101 | if(.not.validGridDataStruct) then
|
|---|
| 102 | print *, "Grid_getBlkPtr: gridDataStruct set to improper value"
|
|---|
| 103 | print *, "gridDataStruct must = CENTER,FACEX,FACEY,FACEZ," // &
|
|---|
| 104 | "WORK or SCRATCH (defined in constants.h)"
|
|---|
| 105 | call Driver_abortFlash("gridDataStruct must be one of CENTER,FACEX,FACEY,FACEZ,SCRATCH (see constants.h)")
|
|---|
| 106 | end if
|
|---|
| 107 | end if
|
|---|
| 108 | if((blockid<1).or.(blockid>MAXBLOCKS)) then
|
|---|
| 109 | print *, 'Grid_getBlkPtr: invalid blockid ',blockid
|
|---|
| 110 | call Driver_abortFlash("[Grid_getBlkPtr] invalid blockid ")
|
|---|
| 111 | end if
|
|---|
| 112 | #endif
|
|---|
| 113 |
|
|---|
| 114 | if(present(gridDataStruct)) then
|
|---|
| 115 | gds = gridDataStruct
|
|---|
| 116 | else
|
|---|
| 117 | gds = CENTER
|
|---|
| 118 | end if
|
|---|
| 119 |
|
|---|
| 120 | #ifdef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 121 | if (gds .eq. CENTER .or. gds .eq. FACEX .or. gds .eq. FACEY .or. gds .eq. FACEZ) then
|
|---|
| 122 | idest = 1
|
|---|
| 123 | iopt = 1
|
|---|
| 124 | nlayers = NGUARD
|
|---|
| 125 | if (gds .eq. FACEX .or. gds .eq. FACEY .or. gds .eq. FACEZ) then
|
|---|
| 126 | blkPtrRefCount = gr_blkPtrRefCount_fc
|
|---|
| 127 | lastBlkPtrGotten = gr_lastBlkPtrGotten_fc
|
|---|
| 128 | #if NFACE_VARS>0
|
|---|
| 129 | save_fcMask=gcell_on_fc
|
|---|
| 130 | gcell_on_fc=gr_fcMask
|
|---|
| 131 | #endif
|
|---|
| 132 | lcc = .false.
|
|---|
| 133 | lfc = .true.
|
|---|
| 134 | else
|
|---|
| 135 | blkPtrRefCount = gr_blkPtrRefCount
|
|---|
| 136 | lastBlkPtrGotten = gr_lastBlkPtrGotten
|
|---|
| 137 | save_ccMask=gcell_on_cc
|
|---|
| 138 | gcell_on_cc=gr_ccMask
|
|---|
| 139 | lcc = .true.
|
|---|
| 140 | lfc = .false.
|
|---|
| 141 | end if
|
|---|
| 142 | lec = .false.
|
|---|
| 143 | lnc = .false.
|
|---|
| 144 | l_srl_only = .false.
|
|---|
| 145 | icoord = 0
|
|---|
| 146 | ldiag = .true.
|
|---|
| 147 |
|
|---|
| 148 | if (blkPtrRefCount .ne. 0 ) then
|
|---|
| 149 | if (blockId .ne. lastBlkPtrGotten) then
|
|---|
| 150 | call Driver_abortFlash("Grid_getBlkPtr: you can't get another pointer while one's in use, " // &
|
|---|
| 151 | "unless it's to the block that's in use")
|
|---|
| 152 | end if
|
|---|
| 153 | else
|
|---|
| 154 | blkPtrRefCount = 0
|
|---|
| 155 | lastBlkPtrGotten = blockId
|
|---|
| 156 |
|
|---|
| 157 | call amr_1blk_guardcell(gr_meshMe,iopt,nlayers,blockId,gr_meshMe, &
|
|---|
| 158 | lcc,lfc,lec,lnc, &
|
|---|
| 159 | l_srl_only,icoord,ldiag)
|
|---|
| 160 | end if
|
|---|
| 161 |
|
|---|
| 162 | blkPtrRefCount = blkPtrRefCount + 1
|
|---|
| 163 | if(gds==CENTER) then
|
|---|
| 164 | gcell_on_cc=save_ccMask
|
|---|
| 165 | else
|
|---|
| 166 | #if NFACE_VARS>0
|
|---|
| 167 | gcell_on_fc=save_fcMask
|
|---|
| 168 | #endif
|
|---|
| 169 | end if
|
|---|
| 170 | end if
|
|---|
| 171 | #endif
|
|---|
| 172 | ! end of #ifdef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 173 |
|
|---|
| 174 | select case (gds)
|
|---|
| 175 | #ifndef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 176 | case(CENTER)
|
|---|
| 177 | dataPtr => unk(:,:,:,:,blockid)
|
|---|
| 178 | case(FACEX)
|
|---|
| 179 | dataPtr => facevarx(:,:,:,:,blockid)
|
|---|
| 180 | case(FACEY)
|
|---|
| 181 | dataPtr => facevary(:,:,:,:,blockid)
|
|---|
| 182 | case(FACEZ)
|
|---|
| 183 | dataPtr => facevarz(:,:,:,:,blockid)
|
|---|
| 184 | #else
|
|---|
| 185 | ! #ifndef FL_NON_PERMANENT_GUARDCELLS ...
|
|---|
| 186 | case(CENTER)
|
|---|
| 187 | dataPtr => unk1(:,:,:,:,idest)
|
|---|
| 188 | case(FACEX)
|
|---|
| 189 | dataPtr => facevarx1(:,:,:,:,idest)
|
|---|
| 190 | case(FACEY)
|
|---|
| 191 | dataPtr => facevary1(:,:,:,:,idest)
|
|---|
| 192 | case(FACEZ)
|
|---|
| 193 | dataPtr => facevarz1(:,:,:,:,idest)
|
|---|
| 194 | #endif
|
|---|
| 195 | ! end of #ifdef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 196 | case(SCRATCH)
|
|---|
| 197 | dataPtr => scratch(:,:,:,:,blockid)
|
|---|
| 198 | case(SCRATCH_CTR)
|
|---|
| 199 | dataPtr => scratch_ctr(:,:,:,:,blockid)
|
|---|
| 200 | case(SCRATCH_FACEX)
|
|---|
| 201 | dataPtr => scratch_facevarx(:,:,:,:,blockid)
|
|---|
| 202 | case(SCRATCH_FACEY)
|
|---|
| 203 | dataPtr => scratch_facevary(:,:,:,:,blockid)
|
|---|
| 204 | case(SCRATCH_FACEZ)
|
|---|
| 205 | dataPtr => scratch_facevarz(:,:,:,:,blockid)
|
|---|
| 206 | case DEFAULT
|
|---|
| 207 | print *, 'TRIED TO GET SOMETHING OTHER THAN UNK OR SCRATCH OR FACE[XYZ]. NOT YET.'
|
|---|
| 208 | end select
|
|---|
| 209 |
|
|---|
| 210 | #ifdef FL_NON_PERMANENT_GUARDCELLS
|
|---|
| 211 | if (gds .eq. FACEX .or. gds .eq. FACEY .or. gds .eq. FACEZ) then
|
|---|
| 212 | gr_blkPtrRefCount_fc = blkPtrRefCount
|
|---|
| 213 | gr_lastBlkPtrGotten_fc = lastBlkPtrGotten
|
|---|
| 214 | else if (gds .eq. CENTER) then
|
|---|
| 215 | gr_blkPtrRefCount = blkPtrRefCount
|
|---|
| 216 | gr_lastBlkPtrGotten = lastBlkPtrGotten
|
|---|
| 217 | end if
|
|---|
| 218 | #endif
|
|---|
| 219 |
|
|---|
| 220 | return
|
|---|
| 221 | end subroutine Grid_getBlkPtr
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|