2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 21:00:50 -06:00
|
|
|
!!
|
2008-11-11 16:12:26 -06:00
|
|
|
!! module: blocks - handling block storage
|
2008-11-04 21:00:50 -06:00
|
|
|
!!
|
|
|
|
!! Copyright (C) 2008 Grzegorz Kowal <kowal@astro.wisc.edu>
|
|
|
|
!!
|
2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 21:00:50 -06:00
|
|
|
!!
|
|
|
|
!! This file is part of Godunov-AMR.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR is free software; you can redistribute it and/or modify
|
|
|
|
!! it under the terms of the GNU General Public License as published by
|
|
|
|
!! the Free Software Foundation; either version 3 of the License, or
|
|
|
|
!! (at your option) any later version.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR is distributed in the hope that it will be useful,
|
|
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
!! GNU General Public License for more details.
|
|
|
|
!!
|
|
|
|
!! You should have received a copy of the GNU General Public License
|
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
!!
|
2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 21:00:50 -06:00
|
|
|
!!
|
|
|
|
!
|
|
|
|
module blocks
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! parameters
|
|
|
|
!
|
2008-12-08 15:31:35 -06:00
|
|
|
integer(kind=4), parameter :: ndims = NDIMS
|
2008-11-04 21:00:50 -06:00
|
|
|
integer(kind=4), parameter :: nchild = 2**ndims
|
2008-12-13 21:05:51 -06:00
|
|
|
integer(kind=4), parameter :: idn = 1, imx = 2, imy = 3, imz = 4 &
|
|
|
|
, ivx = 2, ivy = 3, ivz = 4
|
2008-12-08 15:31:35 -06:00
|
|
|
#ifdef HYDRO
|
|
|
|
#ifdef ISO
|
|
|
|
integer(kind=4), parameter :: nvars = 4
|
|
|
|
#endif /* ISO */
|
|
|
|
#ifdef ADI
|
2008-12-13 21:05:51 -06:00
|
|
|
integer(kind=4), parameter :: ien = 5, ipr = 5
|
2008-12-08 15:36:58 -06:00
|
|
|
integer(kind=4), parameter :: nvars = 5
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* ADI */
|
|
|
|
#endif /* HYDRO */
|
2008-12-08 13:59:57 -06:00
|
|
|
#ifdef MHD
|
|
|
|
#ifdef ISO
|
|
|
|
integer(kind=4), parameter :: ibx = 5, iby = 6, ibz = 7
|
2008-12-08 15:36:58 -06:00
|
|
|
integer(kind=4), parameter :: nvars = 7
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* ISO */
|
|
|
|
#ifdef ADI
|
2008-12-08 15:36:58 -06:00
|
|
|
integer(kind=4), parameter :: ien = 5, ibx = 6, iby = 7, ibz = 8
|
2008-12-08 13:59:57 -06:00
|
|
|
integer(kind=4), parameter :: nvars = 8
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* ADI */
|
2008-12-08 13:59:57 -06:00
|
|
|
#endif /* MHD */
|
2008-12-18 23:47:58 -06:00
|
|
|
integer(kind=4), parameter :: maxid = 1000000
|
2008-11-04 21:00:50 -06:00
|
|
|
|
|
|
|
! define block type
|
|
|
|
!
|
2008-12-18 22:51:08 -06:00
|
|
|
type blockptr
|
|
|
|
type(block), pointer :: ptr
|
|
|
|
end type blockptr
|
2008-12-05 14:13:21 -06:00
|
|
|
|
2008-12-19 00:19:44 -06:00
|
|
|
type blockref
|
2008-12-19 17:24:36 -06:00
|
|
|
integer(kind=4) :: cpu, id
|
2008-12-19 00:19:44 -06:00
|
|
|
end type blockref
|
|
|
|
|
2008-11-04 21:00:50 -06:00
|
|
|
type block
|
2008-12-19 00:19:44 -06:00
|
|
|
type(block), pointer :: next, prev
|
2008-12-19 17:24:36 -06:00
|
|
|
type(blockref) :: parent, child(nchild), neigh(ndims,2,2)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-19 00:02:05 -06:00
|
|
|
logical :: leaf
|
2008-12-19 16:36:07 -06:00
|
|
|
integer(kind=4) :: cpu, id, level
|
2008-12-19 00:19:44 -06:00
|
|
|
|
2008-12-19 00:02:05 -06:00
|
|
|
character :: config
|
2008-12-06 20:11:36 -06:00
|
|
|
integer(kind=4) :: refine
|
2009-01-02 20:18:57 -06:00
|
|
|
integer(kind=4) :: pos(ndims)
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-11-04 21:00:50 -06:00
|
|
|
|
|
|
|
real :: xmin, xmax, ymin, ymax, zmin, zmax
|
|
|
|
|
2008-12-08 12:14:13 -06:00
|
|
|
real, dimension(:,:,:,:), allocatable :: u
|
2008-12-16 13:40:34 -06:00
|
|
|
real, dimension(:,:,:) , allocatable :: c
|
2008-11-04 21:00:50 -06:00
|
|
|
end type block
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! array of ID to pointer conversion
|
|
|
|
!
|
|
|
|
type(blockptr), dimension(:), allocatable, save :: idtoptr
|
|
|
|
|
2008-11-04 21:00:50 -06:00
|
|
|
! stored pointers
|
|
|
|
!
|
2008-12-07 12:56:00 -06:00
|
|
|
type(block), pointer, save :: plist, plast
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-11-11 16:12:26 -06:00
|
|
|
! stored last id (should always increase)
|
|
|
|
!
|
|
|
|
integer(kind=4) , save :: last_id
|
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
! store number of allocated blocks and leafs
|
2008-12-19 16:36:07 -06:00
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
integer(kind=4) , save :: nblocks, nleafs
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2008-11-04 21:00:50 -06:00
|
|
|
contains
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! init_blocks: subroutine initializes the block variables
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
subroutine init_blocks()
|
2008-11-07 00:10:09 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
use error, only : print_warning
|
2008-11-07 00:10:09 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2008-12-05 15:13:16 -06:00
|
|
|
! local variables
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
integer(kind=4) :: p
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! first check if block list is empty
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
if (associated(plist)) &
|
|
|
|
call print_warning("blocks::init_blocks", "Block list already associated!")
|
2008-11-07 00:10:09 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! nullify all pointers
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
nullify(plist)
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
! reset number of blocks and leafs
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
nblocks = 0
|
2009-05-18 22:46:19 +02:00
|
|
|
nleafs = 0
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! reset ID
|
2008-12-05 14:24:01 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
last_id = 0
|
2008-12-05 14:24:01 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! allocate space for ID to pointer array
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
allocate(idtoptr(maxid))
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! nullify all pointers in ID to pointer array
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
do p = 1, maxid
|
|
|
|
nullify(idtoptr(p)%ptr)
|
2008-12-05 15:13:16 -06:00
|
|
|
end do
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end subroutine init_blocks
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! clear_blocks: subroutine clears the block variables
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
subroutine clear_blocks
|
2008-11-07 00:10:09 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! pointers
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
type(block), pointer :: pblock
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! untill the list is free, iterate over all chunks and deallocate blocks
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
pblock => plist
|
|
|
|
do while(associated(pblock))
|
2008-12-13 15:08:18 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! deallocate and nullify the current block
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
call deallocate_block(pblock)
|
2008-12-18 23:47:58 -06:00
|
|
|
|
2008-12-28 13:09:14 -06:00
|
|
|
pblock => plist
|
2008-12-18 23:47:58 -06:00
|
|
|
end do
|
|
|
|
|
|
|
|
! deallocate ID to pointer conversion array
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
deallocate(idtoptr)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end subroutine clear_blocks
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! list_allocated: function returns true if the block list is allocated,
|
|
|
|
! otherwise it returns false
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
function list_allocated
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
logical :: list_allocated
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
list_allocated = associated(plist)
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
return
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end function list_allocated
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! increase_id: function increases the last ID by 1 and returns it
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
function increase_id
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! return variable
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
integer(kind=4) :: increase_id
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! increase ID by 1
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
last_id = last_id + 1
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! return ID
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
increase_id = last_id
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
return
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end function increase_id
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-19 16:36:07 -06:00
|
|
|
! get_pointer: function returns a pointer to the block with requested ID
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
function get_pointer(id)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input argument
|
|
|
|
!
|
|
|
|
integer(kind=4) :: id
|
|
|
|
|
|
|
|
! return variable
|
|
|
|
!
|
|
|
|
type(block), pointer :: get_pointer
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
nullify(get_pointer)
|
|
|
|
|
|
|
|
if (id .ge. 1 .and. id .le. maxid) &
|
|
|
|
get_pointer => idtoptr(id)%ptr
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end function get_pointer
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! allocate_block: subroutine allocates space for one block and returns the
|
|
|
|
! pointer to this block
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-05 15:13:16 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
subroutine allocate_block(pblock)
|
2008-12-05 15:13:16 -06:00
|
|
|
|
2008-12-28 13:09:14 -06:00
|
|
|
use config , only : im, jm, km
|
|
|
|
use mpitools, only : ncpu
|
2008-12-05 15:13:16 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
implicit none
|
2008-12-05 15:13:16 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! output arguments
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
type(block), pointer, intent(out) :: pblock
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! local variables
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
integer :: i, j, k
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! allocate block structure
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
allocate(pblock)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! set unique ID
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
pblock%id = increase_id() ! TODO: replace with get_free_id() which return the first free id
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! set configuration and leaf flags
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
pblock%config = 'N' ! TODO: replace with an integer number
|
2008-12-19 00:02:05 -06:00
|
|
|
pblock%leaf = .false.
|
2008-12-18 23:47:58 -06:00
|
|
|
|
2008-12-28 13:09:14 -06:00
|
|
|
! set the cpu of current block
|
|
|
|
!
|
|
|
|
pblock%cpu = ncpu
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! initialize the refinement flag
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
pblock%refine = 0
|
|
|
|
|
|
|
|
! nullify pointers
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%prev)
|
2008-12-19 00:19:44 -06:00
|
|
|
|
|
|
|
! reset parent block
|
|
|
|
!
|
|
|
|
pblock%parent%cpu = -1
|
|
|
|
pblock%parent%id = -1
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! reset neighbors
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-19 16:36:07 -06:00
|
|
|
pblock%neigh(:,:,:)%cpu = -1
|
|
|
|
pblock%neigh(:,:,:)%id = -1
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! allocate space for variables
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
allocate(pblock%u(nvars,im,jm,km))
|
|
|
|
allocate(pblock%c(im,jm,km))
|
2008-11-07 00:10:09 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! set the correspponding pointer in the ID to pointer array to the current block
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
idtoptr(pblock%id)%ptr => pblock
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-19 16:36:07 -06:00
|
|
|
! increase the number of allocated blocks
|
|
|
|
!
|
|
|
|
nblocks = nblocks + 1
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-05 22:16:24 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end subroutine allocate_block
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! deallocate_block: subroutine deallocates space ocuppied by a given block
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
subroutine deallocate_block(pblock)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! input arguments
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
type(block), pointer, intent(inout) :: pblock
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
if (associated(pblock)) then
|
|
|
|
|
|
|
|
! if this is the first block in the list, update the plist pointer
|
|
|
|
!
|
|
|
|
if (pblock%id .eq. plist%id) &
|
|
|
|
plist => pblock%next
|
|
|
|
|
|
|
|
! update the pointer of previous and next blocks
|
|
|
|
!
|
|
|
|
if (associated(pblock%prev)) &
|
|
|
|
pblock%prev%next => pblock%next
|
|
|
|
|
|
|
|
if (associated(pblock%next)) &
|
|
|
|
pblock%next%prev => pblock%prev
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! deallocate variables
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
deallocate(pblock%u)
|
|
|
|
deallocate(pblock%c)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! nullify pointers
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%prev)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! nullify the corresponding pointer in the ID to pointer array
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
nullify(idtoptr(pblock%id)%ptr)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! free and nullify the block
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
deallocate(pblock)
|
|
|
|
nullify(pblock)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-19 16:36:07 -06:00
|
|
|
! decrease the number of allocated blocks
|
|
|
|
!
|
2008-12-28 13:09:14 -06:00
|
|
|
nblocks = nblocks - 1
|
|
|
|
endif
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-05 22:16:24 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end subroutine deallocate_block
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! append_block: subroutine allocates space for one block and appends it to
|
|
|
|
! the list
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
subroutine append_block(pblock)
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! output arguments
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
type(block), pointer, intent(out) :: pblock
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
! allocate block
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
call allocate_block(pblock)
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
! add to the list
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
if (list_allocated()) then
|
|
|
|
pblock%prev => plast
|
|
|
|
nullify(pblock%next)
|
|
|
|
plast%next => pblock
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
plast => pblock
|
|
|
|
else
|
|
|
|
plist => pblock
|
|
|
|
plast => pblock
|
|
|
|
nullify(pblock%prev)
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
end subroutine append_block
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
|
|
|
! refine_block: subroutine refines selected block
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
|
|
|
subroutine refine_block(pblock)
|
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
use error , only : print_error
|
|
|
|
#ifdef MPI
|
|
|
|
use mpitools, only : ncpu
|
|
|
|
#endif /* MPI */
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input parameters
|
|
|
|
!
|
|
|
|
type(block), pointer, intent(inout) :: pblock
|
|
|
|
|
|
|
|
! pointers
|
|
|
|
!
|
2008-12-06 20:11:36 -06:00
|
|
|
type(block), pointer :: pb, pbl, pbr, ptl, ptr, pneigh
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
|
|
|
! check if pointer is associated
|
|
|
|
!
|
|
|
|
if (associated(pblock)) then
|
|
|
|
|
|
|
|
! create 4 blocks
|
|
|
|
!
|
|
|
|
call allocate_block(pbl)
|
2008-12-06 20:11:36 -06:00
|
|
|
call allocate_block(pbr)
|
2008-12-05 14:04:12 -06:00
|
|
|
call allocate_block(ptl)
|
|
|
|
call allocate_block(ptr)
|
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
! unset the refinement and leaf flags for the parent block
|
|
|
|
!
|
|
|
|
pblock%refine = 0
|
|
|
|
pblock%leaf = .false.
|
|
|
|
|
|
|
|
! set leaf flags
|
|
|
|
!
|
|
|
|
pbl%leaf = .true.
|
|
|
|
pbr%leaf = .true.
|
|
|
|
ptl%leaf = .true.
|
|
|
|
ptr%leaf = .true.
|
|
|
|
|
|
|
|
! increase the number of leafs
|
|
|
|
!
|
|
|
|
nleafs = nleafs + 3
|
|
|
|
|
2008-12-05 14:04:12 -06:00
|
|
|
! set parent
|
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
pbl%parent%cpu = pblock%cpu
|
|
|
|
pbr%parent%cpu = pblock%cpu
|
|
|
|
ptl%parent%cpu = pblock%cpu
|
|
|
|
ptr%parent%cpu = pblock%cpu
|
|
|
|
#endif /* MPI */
|
|
|
|
pbl%parent%id = pblock%id
|
|
|
|
pbr%parent%id = pblock%id
|
|
|
|
ptl%parent%id = pblock%id
|
|
|
|
ptr%parent%id = pblock%id
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2008-12-05 14:22:02 -06:00
|
|
|
! set level
|
|
|
|
!
|
|
|
|
pbl%level = pblock%level + 1
|
2009-05-18 22:46:19 +02:00
|
|
|
pbr%level = pblock%level + 1
|
|
|
|
ptl%level = pblock%level + 1
|
|
|
|
ptr%level = pblock%level + 1
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-01-02 20:18:57 -06:00
|
|
|
! set positions
|
|
|
|
!
|
|
|
|
pbl%pos(1) = 1
|
|
|
|
pbl%pos(2) = 1
|
|
|
|
|
|
|
|
pbr%pos(1) = 2
|
|
|
|
pbr%pos(2) = 1
|
|
|
|
|
|
|
|
ptl%pos(1) = 1
|
|
|
|
ptl%pos(2) = 2
|
|
|
|
|
|
|
|
ptr%pos(1) = 2
|
|
|
|
ptr%pos(2) = 2
|
|
|
|
|
2008-12-05 14:04:12 -06:00
|
|
|
! set bounds
|
|
|
|
!
|
|
|
|
pbl%xmin = pblock%xmin
|
2008-12-16 22:34:54 -06:00
|
|
|
pbl%xmax = 0.5 * (pblock%xmax + pblock%xmin)
|
2008-12-05 14:04:12 -06:00
|
|
|
pbl%ymin = pblock%ymin
|
2008-12-16 22:34:54 -06:00
|
|
|
pbl%ymax = 0.5 * (pblock%ymax + pblock%ymin)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
pbr%xmin = pbl%xmax
|
|
|
|
pbr%xmax = pblock%xmax
|
|
|
|
pbr%ymin = pblock%ymin
|
|
|
|
pbr%ymax = pbl%ymax
|
|
|
|
|
|
|
|
ptl%xmin = pblock%xmin
|
|
|
|
ptl%xmax = pbl%xmax
|
|
|
|
ptl%ymin = pbl%ymax
|
|
|
|
ptl%ymax = pblock%ymax
|
|
|
|
|
|
|
|
ptr%xmin = ptl%xmax
|
|
|
|
ptr%xmax = pblock%xmax
|
|
|
|
ptr%ymin = ptl%ymin
|
|
|
|
ptr%ymax = pblock%ymax
|
|
|
|
|
2008-12-19 16:36:07 -06:00
|
|
|
! set neighbors to the refined blocks
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
pbl%neigh(1,2,1)%cpu = ncpu ! BL right -> BR
|
|
|
|
pbl%neigh(1,2,2)%cpu = ncpu
|
|
|
|
pbl%neigh(2,2,1)%cpu = ncpu ! BL top -> TL
|
|
|
|
pbl%neigh(2,2,2)%cpu = ncpu
|
|
|
|
|
|
|
|
pbr%neigh(1,1,1)%cpu = ncpu ! BR left -> BL
|
|
|
|
pbr%neigh(1,1,2)%cpu = ncpu
|
|
|
|
pbr%neigh(2,2,1)%cpu = ncpu ! BR top -> TR
|
|
|
|
pbr%neigh(2,2,2)%cpu = ncpu
|
|
|
|
|
|
|
|
ptl%neigh(1,2,1)%cpu = ncpu ! TL right -> TR
|
|
|
|
ptl%neigh(1,2,2)%cpu = ncpu
|
|
|
|
ptl%neigh(2,1,1)%cpu = ncpu ! TL bottom -> BL
|
|
|
|
ptl%neigh(2,1,2)%cpu = ncpu
|
|
|
|
|
|
|
|
ptr%neigh(1,1,1)%cpu = ncpu ! TR left -> TL
|
|
|
|
ptr%neigh(1,1,2)%cpu = ncpu
|
|
|
|
ptr%neigh(2,1,1)%cpu = ncpu ! TR bottom -> BR
|
|
|
|
ptr%neigh(2,1,2)%cpu = ncpu
|
|
|
|
#endif /* MPI */
|
|
|
|
|
2008-12-19 16:36:07 -06:00
|
|
|
pbl%neigh(1,2,1)%id = pbr%id ! BL right -> BR
|
|
|
|
pbl%neigh(1,2,2)%id = pbr%id
|
|
|
|
pbl%neigh(2,2,1)%id = ptl%id ! BL top -> TL
|
|
|
|
pbl%neigh(2,2,2)%id = ptl%id
|
|
|
|
|
|
|
|
pbr%neigh(1,1,1)%id = pbl%id ! BR left -> BL
|
|
|
|
pbr%neigh(1,1,2)%id = pbl%id
|
|
|
|
pbr%neigh(2,2,1)%id = ptr%id ! BR top -> TR
|
|
|
|
pbr%neigh(2,2,2)%id = ptr%id
|
|
|
|
|
|
|
|
ptl%neigh(1,2,1)%id = ptr%id ! TL right -> TR
|
|
|
|
ptl%neigh(1,2,2)%id = ptr%id
|
|
|
|
ptl%neigh(2,1,1)%id = pbl%id ! TL bottom -> BL
|
|
|
|
ptl%neigh(2,1,2)%id = pbl%id
|
|
|
|
|
|
|
|
ptr%neigh(1,1,1)%id = ptl%id ! TR left -> TL
|
|
|
|
ptr%neigh(1,1,2)%id = ptl%id
|
|
|
|
ptr%neigh(2,1,1)%id = pbr%id ! TR bottom -> BR
|
|
|
|
ptr%neigh(2,1,2)%id = pbr%id
|
|
|
|
|
2008-12-06 20:11:36 -06:00
|
|
|
! set pointer to the neighbors of the parent block
|
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
! left neighbor of BL
|
|
|
|
!
|
|
|
|
if (pblock%neigh(1,1,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,1)%id) ! left lower neighbor
|
|
|
|
! if (.not. pneigh%leaf) &
|
|
|
|
! call print_error("blocks::refine_blocks","The left neighbor of BL is not a leaf!")
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbl%neigh(1,1,1)%cpu = pneigh%cpu
|
|
|
|
pbl%neigh(1,1,2)%cpu = pneigh%cpu
|
|
|
|
pbl%neigh(1,1,1)%id = pneigh%id
|
|
|
|
pbl%neigh(1,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the left neighbor of BL is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,2,1)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(1,2,1)%id = pbl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbl%level) then
|
|
|
|
pneigh%neigh(1,2,1)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(1,2,2)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(1,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pbl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! bottom neighbor of BL
|
|
|
|
!
|
|
|
|
if (pblock%neigh(2,1,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,1)%id) ! bottom left neighbor
|
|
|
|
if (.not. pneigh%leaf) &
|
|
|
|
call print_error("blocks::refine_blocks","The bottom neighbor of BL is not a leaf!")
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbl%neigh(2,1,1)%cpu = pneigh%cpu
|
|
|
|
pbl%neigh(2,1,2)%cpu = pneigh%cpu
|
|
|
|
pbl%neigh(2,1,1)%id = pneigh%id
|
|
|
|
pbl%neigh(2,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the bottom neighbor of BL is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,2,1)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(2,2,1)%id = pbl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbl%level) then
|
|
|
|
pneigh%neigh(2,2,1)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(2,2,2)%cpu = pbl%cpu
|
|
|
|
pneigh%neigh(2,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! bottom neighbor of BR
|
|
|
|
!
|
|
|
|
if (pblock%neigh(2,1,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,2)%id) ! bottom right neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbr%neigh(2,1,1)%cpu = pneigh%cpu
|
|
|
|
pbr%neigh(2,1,2)%cpu = pneigh%cpu
|
|
|
|
pbr%neigh(2,1,1)%id = pneigh%id
|
|
|
|
pbr%neigh(2,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the bottom neighbor of BR is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,2,2)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(2,2,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbr%level) then
|
|
|
|
pneigh%neigh(2,2,1)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(2,2,2)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(2,2,1)%id = pbr%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! right neighbor of BR
|
|
|
|
!
|
|
|
|
if (pblock%neigh(1,2,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,1)%id) ! right lower neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbr%neigh(1,2,1)%cpu = pneigh%cpu
|
|
|
|
pbr%neigh(1,2,2)%cpu = pneigh%cpu
|
|
|
|
pbr%neigh(1,2,1)%id = pneigh%id
|
|
|
|
pbr%neigh(1,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the right neighbor of BR is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,1,1)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(1,1,1)%id = pbr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbr%level) then
|
|
|
|
pneigh%neigh(1,1,1)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(1,1,2)%cpu = pbr%cpu
|
|
|
|
pneigh%neigh(1,1,1)%id = pbr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! right neighbor of TR
|
|
|
|
!
|
|
|
|
if (pblock%neigh(1,2,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,2)%id) ! right upper neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptr%neigh(1,2,1)%cpu = pneigh%cpu
|
|
|
|
ptr%neigh(1,2,2)%cpu = pneigh%cpu
|
|
|
|
ptr%neigh(1,2,1)%id = pneigh%id
|
|
|
|
ptr%neigh(1,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the right neighbor of TR is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,1,2)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(1,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptr%level) then
|
|
|
|
pneigh%neigh(1,1,1)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(1,1,2)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(1,1,1)%id = ptr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! top neighbor of TR
|
|
|
|
!
|
|
|
|
if (pblock%neigh(2,2,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,2)%id) ! top right neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptr%neigh(2,2,1)%cpu = pneigh%cpu
|
|
|
|
ptr%neigh(2,2,2)%cpu = pneigh%cpu
|
|
|
|
ptr%neigh(2,2,1)%id = pneigh%id
|
|
|
|
ptr%neigh(2,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the top neighbor of TR is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,1,2)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(2,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptr%level) then
|
|
|
|
pneigh%neigh(2,1,1)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(2,1,2)%cpu = ptr%cpu
|
|
|
|
pneigh%neigh(2,1,1)%id = ptr%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! top neighbor of TL
|
|
|
|
!
|
|
|
|
if (pblock%neigh(2,2,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,1)%id) ! top left neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptl%neigh(2,2,1)%cpu = pneigh%cpu
|
|
|
|
ptl%neigh(2,2,2)%cpu = pneigh%cpu
|
|
|
|
ptl%neigh(2,2,1)%id = pneigh%id
|
|
|
|
ptl%neigh(2,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the top neighbor of TL is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,1,1)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(2,1,1)%id = ptl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptl%level) then
|
|
|
|
pneigh%neigh(2,1,1)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(2,1,2)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(2,1,1)%id = ptl%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
! left neighbor of TL
|
|
|
|
!
|
|
|
|
if (pblock%neigh(1,1,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,2)%id) ! left upper neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptl%neigh(1,1,1)%cpu = pneigh%cpu
|
|
|
|
ptl%neigh(1,1,2)%cpu = pneigh%cpu
|
|
|
|
ptl%neigh(1,1,1)%id = pneigh%id
|
|
|
|
ptl%neigh(1,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .lt. pblock%level) then
|
|
|
|
call print_error("blocks::refine_blocks","Level of the left neighbor of TL is too low!")
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,2,2)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(1,2,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptl%level) then
|
|
|
|
pneigh%neigh(1,2,1)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(1,2,2)%cpu = ptl%cpu
|
|
|
|
pneigh%neigh(1,2,1)%id = ptl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
#else /* MPI */
|
2008-12-19 16:36:07 -06:00
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,1)%id) ! left lower neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbl%neigh(1,1,1)%id = pneigh%id
|
|
|
|
pbl%neigh(1,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbl%level) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pbl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,2)%id) ! left upper neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptl%neigh(1,1,1)%id = pneigh%id
|
|
|
|
ptl%neigh(1,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptl%level) then
|
|
|
|
pneigh%neigh(1,2,1)%id = ptl%id
|
|
|
|
pneigh%neigh(1,2,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,1)%id) ! right lower neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbr%neigh(1,2,1)%id = pneigh%id
|
|
|
|
pbr%neigh(1,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pbr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbr%level) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pbr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,2)%id) ! right upper neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptr%neigh(1,2,1)%id = pneigh%id
|
|
|
|
ptr%neigh(1,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pbr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptr%level) then
|
|
|
|
pneigh%neigh(1,1,1)%id = ptr%id
|
|
|
|
pneigh%neigh(1,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,1)%id) ! bottom left neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbl%neigh(2,1,1)%id = pneigh%id
|
|
|
|
pbl%neigh(2,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbl%level) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,2)%id) ! bottom right neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pbr%neigh(2,1,1)%id = pneigh%id
|
|
|
|
pbr%neigh(2,1,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pbl%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. pbr%level) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pbr%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pbr%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,1)%id) ! top left neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptl%neigh(2,2,1)%id = pneigh%id
|
|
|
|
ptl%neigh(2,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,1,1)%id = ptl%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptl%level) then
|
|
|
|
pneigh%neigh(2,1,1)%id = ptl%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptl%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,2)%id) ! top right neighbor
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
ptr%neigh(2,2,1)%id = pneigh%id
|
|
|
|
ptr%neigh(2,2,2)%id = pneigh%id
|
|
|
|
|
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(2,1,1)%id = ptl%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
if (pneigh%level .eq. ptr%level) then
|
|
|
|
pneigh%neigh(2,1,1)%id = ptr%id
|
|
|
|
pneigh%neigh(2,1,2)%id = ptr%id
|
|
|
|
endif
|
|
|
|
endif
|
2009-05-18 22:46:19 +02:00
|
|
|
#endif /* MPI */
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2008-12-05 14:04:12 -06:00
|
|
|
! set children
|
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
pblock%child(1)%cpu = pbl%cpu
|
|
|
|
pblock%child(2)%cpu = pbr%cpu
|
|
|
|
pblock%child(3)%cpu = ptl%cpu
|
|
|
|
pblock%child(4)%cpu = ptr%cpu
|
|
|
|
#endif /* MPI */
|
|
|
|
pblock%child(1)%id = pbl%id
|
|
|
|
pblock%child(2)%id = pbr%id
|
|
|
|
pblock%child(3)%id = ptl%id
|
|
|
|
pblock%child(4)%id = ptr%id
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
! depending on the configuration of the parent block
|
|
|
|
!
|
|
|
|
select case(pblock%config)
|
2008-12-06 20:11:36 -06:00
|
|
|
case('z', 'Z')
|
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
|
|
|
pbl%config = 'Z'
|
|
|
|
pbr%config = 'Z'
|
|
|
|
ptl%config = 'Z'
|
|
|
|
ptr%config = 'Z'
|
|
|
|
|
|
|
|
! connect blocks in a chain
|
|
|
|
!
|
|
|
|
pbl%next => pbr
|
|
|
|
pbr%next => ptl
|
|
|
|
ptl%next => ptr
|
|
|
|
|
|
|
|
pbr%prev => pbl
|
|
|
|
ptl%prev => pbr
|
|
|
|
ptr%prev => ptl
|
|
|
|
|
|
|
|
! insert this chain after the parent block
|
|
|
|
!
|
|
|
|
pb => pblock%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => ptr
|
|
|
|
ptr%next => pb
|
|
|
|
else
|
|
|
|
plast => ptr
|
|
|
|
nullify(ptr%next)
|
|
|
|
endif
|
|
|
|
pblock%next => pbl
|
|
|
|
pbl%prev => pblock
|
|
|
|
|
|
|
|
pblock => ptr
|
|
|
|
|
2008-12-05 14:04:12 -06:00
|
|
|
case('n', 'N')
|
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
|
|
|
pbl%config = 'D'
|
|
|
|
ptl%config = 'N'
|
|
|
|
ptr%config = 'N'
|
|
|
|
pbr%config = 'C'
|
|
|
|
|
|
|
|
! connect blocks in a chain
|
|
|
|
!
|
|
|
|
pbl%next => ptl
|
|
|
|
ptl%next => ptr
|
|
|
|
ptr%next => pbr
|
|
|
|
|
|
|
|
ptl%prev => pbl
|
|
|
|
ptr%prev => ptl
|
|
|
|
pbr%prev => ptr
|
|
|
|
|
2008-12-06 20:11:36 -06:00
|
|
|
! insert this chain after the parent the block
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2008-12-06 20:11:36 -06:00
|
|
|
pb => pblock%next
|
2008-12-05 14:04:12 -06:00
|
|
|
if (associated(pb)) then
|
2008-12-06 20:11:36 -06:00
|
|
|
pb%prev => pbr
|
|
|
|
pbr%next => pb
|
2008-12-05 14:04:12 -06:00
|
|
|
endif
|
2008-12-06 20:11:36 -06:00
|
|
|
pbl%prev => pblock
|
|
|
|
pblock%next => pbl
|
|
|
|
|
|
|
|
pblock => pbr
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
case('d', 'D')
|
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
|
|
|
pbl%config = 'N'
|
|
|
|
pbr%config = 'D'
|
|
|
|
ptr%config = 'D'
|
|
|
|
ptl%config = 'U'
|
|
|
|
|
|
|
|
! connect blocks in a chain
|
|
|
|
!
|
|
|
|
pbl%next => pbr
|
|
|
|
pbr%next => ptr
|
|
|
|
ptr%next => ptl
|
|
|
|
|
|
|
|
pbr%prev => pbl
|
|
|
|
ptr%prev => pbr
|
|
|
|
ptl%prev => ptr
|
|
|
|
|
|
|
|
! insert this chain in the block list
|
|
|
|
!
|
2008-12-06 20:11:36 -06:00
|
|
|
pb => pblock%next
|
2008-12-05 14:04:12 -06:00
|
|
|
if (associated(pb)) then
|
2008-12-06 20:11:36 -06:00
|
|
|
pb%prev => ptl
|
|
|
|
ptl%next => pb
|
2008-12-05 14:04:12 -06:00
|
|
|
endif
|
2008-12-06 20:11:36 -06:00
|
|
|
pbl%prev => pblock
|
|
|
|
pblock%next => pbl
|
|
|
|
|
|
|
|
pblock => ptl
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
case('c', 'C')
|
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
|
|
|
ptr%config = 'U'
|
|
|
|
ptl%config = 'C'
|
|
|
|
pbl%config = 'C'
|
|
|
|
pbr%config = 'N'
|
|
|
|
|
|
|
|
! connect blocks in a chain
|
|
|
|
!
|
|
|
|
ptr%next => ptl
|
|
|
|
ptl%next => pbl
|
|
|
|
pbl%next => pbr
|
|
|
|
|
|
|
|
ptl%prev => ptr
|
|
|
|
pbl%prev => ptl
|
|
|
|
pbr%prev => pbl
|
|
|
|
|
|
|
|
! insert this chain in the block list
|
|
|
|
!
|
2008-12-06 20:11:36 -06:00
|
|
|
pb => pblock%next
|
2008-12-05 14:04:12 -06:00
|
|
|
if (associated(pb)) then
|
2008-12-06 20:11:36 -06:00
|
|
|
pb%prev => pbr
|
|
|
|
pbr%next => pb
|
2008-12-05 14:04:12 -06:00
|
|
|
endif
|
2008-12-06 20:11:36 -06:00
|
|
|
ptr%prev => pblock
|
|
|
|
pblock%next => ptr
|
|
|
|
|
|
|
|
pblock => pbr
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
case('u', 'U')
|
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
|
|
|
ptr%config = 'C'
|
|
|
|
pbr%config = 'U'
|
|
|
|
pbl%config = 'U'
|
|
|
|
ptl%config = 'D'
|
|
|
|
|
|
|
|
! connect blocks in a chain
|
|
|
|
!
|
|
|
|
ptr%next => pbr
|
|
|
|
pbr%next => pbl
|
|
|
|
pbl%next => ptl
|
|
|
|
|
|
|
|
pbr%prev => ptr
|
|
|
|
pbl%prev => pbr
|
|
|
|
ptl%prev => pbl
|
|
|
|
|
|
|
|
! insert this chain in the block list
|
|
|
|
!
|
2008-12-06 20:11:36 -06:00
|
|
|
pb => pblock%next
|
2008-12-05 14:04:12 -06:00
|
|
|
if (associated(pb)) then
|
2008-12-06 20:11:36 -06:00
|
|
|
pb%prev => ptl
|
|
|
|
ptl%next => pb
|
2008-12-05 14:04:12 -06:00
|
|
|
endif
|
2008-12-06 20:11:36 -06:00
|
|
|
ptr%prev => pblock
|
|
|
|
pblock%next => ptr
|
|
|
|
|
|
|
|
pblock => ptl
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
! terminate program if the pointer passed by argument is not associated
|
|
|
|
!
|
|
|
|
call print_error("blocks::refine_blocks","Input pointer is not associated! Terminating!")
|
|
|
|
endif
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
|
|
|
end subroutine refine_block
|
2008-12-13 15:08:18 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-13 15:08:18 -06:00
|
|
|
!
|
|
|
|
! derefine_block: subroutine derefines selected block
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-12-13 15:08:18 -06:00
|
|
|
!
|
|
|
|
subroutine derefine_block(pblock)
|
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
use mpitools, only : ncpu
|
|
|
|
#endif /* MPI */
|
|
|
|
|
2008-12-13 15:08:18 -06:00
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input parameters
|
|
|
|
!
|
|
|
|
type(block), pointer, intent(inout) :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: p
|
|
|
|
|
|
|
|
! pointers
|
|
|
|
!
|
|
|
|
type(block), pointer :: pb, pbl, pbr, ptl, ptr, pneigh
|
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-13 15:08:18 -06:00
|
|
|
!
|
|
|
|
! prepare pointers to children
|
|
|
|
!
|
2008-12-19 17:24:36 -06:00
|
|
|
pbl => get_pointer(pblock%child(1)%id)
|
|
|
|
pbr => get_pointer(pblock%child(2)%id)
|
|
|
|
ptl => get_pointer(pblock%child(3)%id)
|
|
|
|
ptr => get_pointer(pblock%child(4)%id)
|
2008-12-13 15:08:18 -06:00
|
|
|
|
|
|
|
! prepare neighbors
|
|
|
|
!
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
pblock%neigh(1,1,1)%cpu = pbl%neigh(1,1,1)%cpu
|
|
|
|
pblock%neigh(1,1,2)%cpu = ptl%neigh(1,1,2)%cpu
|
|
|
|
pblock%neigh(1,2,1)%cpu = pbr%neigh(1,2,1)%cpu
|
|
|
|
pblock%neigh(1,2,2)%cpu = ptr%neigh(1,2,2)%cpu
|
|
|
|
pblock%neigh(2,1,1)%cpu = pbl%neigh(2,1,1)%cpu
|
|
|
|
pblock%neigh(2,1,2)%cpu = pbr%neigh(2,1,2)%cpu
|
|
|
|
pblock%neigh(2,2,1)%cpu = ptl%neigh(2,2,1)%cpu
|
|
|
|
pblock%neigh(2,2,2)%cpu = ptr%neigh(2,2,2)%cpu
|
|
|
|
#endif /* MPI */
|
2008-12-19 16:36:07 -06:00
|
|
|
pblock%neigh(1,1,1)%id = pbl%neigh(1,1,1)%id
|
|
|
|
pblock%neigh(1,1,2)%id = ptl%neigh(1,1,2)%id
|
|
|
|
pblock%neigh(1,2,1)%id = pbr%neigh(1,2,1)%id
|
|
|
|
pblock%neigh(1,2,2)%id = ptr%neigh(1,2,2)%id
|
|
|
|
pblock%neigh(2,1,1)%id = pbl%neigh(2,1,1)%id
|
|
|
|
pblock%neigh(2,1,2)%id = pbr%neigh(2,1,2)%id
|
|
|
|
pblock%neigh(2,2,1)%id = ptl%neigh(2,2,1)%id
|
|
|
|
pblock%neigh(2,2,2)%id = ptr%neigh(2,2,2)%id
|
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
#ifdef MPI
|
|
|
|
if (pblock%neigh(1,1,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(1,1,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(1,2,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(1,2,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(2,1,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(2,1,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(2,2,1)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (pblock%neigh(2,2,2)%cpu .eq. ncpu) then
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
#else /* MPI */
|
2008-12-19 16:36:07 -06:00
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,1,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(1,2,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(1,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(1,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,1,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,2,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,2,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,1)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,1,2)%id = pblock%id
|
|
|
|
endif
|
|
|
|
|
|
|
|
pneigh => get_pointer(pblock%neigh(2,2,2)%id)
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%neigh(2,1,1)%id = pblock%id
|
|
|
|
pneigh%neigh(2,1,2)%id = pblock%id
|
|
|
|
endif
|
2009-05-18 22:46:19 +02:00
|
|
|
#endif /* MPI */
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2008-12-13 15:08:18 -06:00
|
|
|
! set the leaf flag for children
|
|
|
|
!
|
2008-12-19 00:02:05 -06:00
|
|
|
pblock%leaf = .true.
|
|
|
|
pbl%leaf = .false.
|
|
|
|
pbr%leaf = .false.
|
|
|
|
ptl%leaf = .false.
|
|
|
|
ptr%leaf = .false.
|
2008-12-13 15:08:18 -06:00
|
|
|
|
2009-05-18 22:46:19 +02:00
|
|
|
! decrease the number of leafs
|
|
|
|
!
|
|
|
|
nleafs = nleafs - 3
|
|
|
|
|
2008-12-13 15:08:18 -06:00
|
|
|
! prepare next and prev pointers
|
|
|
|
!
|
|
|
|
select case(pblock%config)
|
|
|
|
case('z', 'Z')
|
|
|
|
pb => ptr%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => pblock
|
|
|
|
pblock%next => pb
|
|
|
|
else
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
|
|
|
case('n', 'N')
|
|
|
|
pb => pbr%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => pblock
|
|
|
|
pblock%next => pb
|
|
|
|
else
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
|
|
|
case('d', 'D')
|
|
|
|
pb => ptl%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => pblock
|
|
|
|
pblock%next => pb
|
|
|
|
else
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
|
|
|
case('c', 'C')
|
|
|
|
pb => pbr%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => pblock
|
|
|
|
pblock%next => pb
|
|
|
|
else
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
|
|
|
case('u', 'U')
|
|
|
|
pb => ptl%next
|
|
|
|
if (associated(pb)) then
|
|
|
|
pb%prev => pblock
|
|
|
|
pblock%next => pb
|
|
|
|
else
|
|
|
|
nullify(pblock%next)
|
|
|
|
endif
|
|
|
|
end select
|
|
|
|
|
|
|
|
pblock%refine = 0
|
|
|
|
pbl%refine = 0
|
|
|
|
pbr%refine = 0
|
|
|
|
ptl%refine = 0
|
|
|
|
ptr%refine = 0
|
|
|
|
|
|
|
|
call deallocate_block(pbl)
|
|
|
|
call deallocate_block(pbr)
|
|
|
|
call deallocate_block(ptl)
|
|
|
|
call deallocate_block(ptr)
|
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-12-13 15:08:18 -06:00
|
|
|
!
|
|
|
|
end subroutine derefine_block
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-18 23:47:58 -06:00
|
|
|
!===============================================================================
|
2008-11-05 22:16:24 -06:00
|
|
|
!
|
2008-11-04 21:00:50 -06:00
|
|
|
end module
|