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
|
2009-09-11 21:52:18 -03:00
|
|
|
integer(kind=4), parameter :: nsides = 2
|
|
|
|
integer(kind=4), parameter :: nfaces = 2**(ndims-1)
|
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
|
|
|
|
2009-09-18 17:43:48 -03:00
|
|
|
!! BLOCK STRUCTURE POINTERS (have to be defined before structures)
|
|
|
|
!!
|
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
|
|
|
|
|
2009-09-09 16:37:28 -03:00
|
|
|
! define pointers to block_meta and block_data structures
|
|
|
|
!
|
|
|
|
type pointer_meta
|
|
|
|
type(block_meta), pointer :: ptr
|
|
|
|
end type pointer_meta
|
|
|
|
|
|
|
|
type pointer_data
|
|
|
|
type(block_data), pointer :: ptr
|
|
|
|
end type pointer_data
|
|
|
|
|
2009-09-18 17:43:48 -03:00
|
|
|
type pointer_info
|
|
|
|
type(block_info), pointer :: ptr
|
|
|
|
end type pointer_info
|
|
|
|
|
|
|
|
!! BLOCK STRUCTURES
|
|
|
|
!
|
2009-09-09 16:37:28 -03:00
|
|
|
! define block_meta structure
|
|
|
|
!
|
|
|
|
type block_meta
|
|
|
|
type(block_meta) , pointer :: prev ! pointer to the previous block
|
|
|
|
type(block_meta) , pointer :: next ! pointer to the next block
|
|
|
|
type(block_meta) , pointer :: parent ! pointer to the parent block
|
|
|
|
type(pointer_meta) :: child(nchild) ! pointers to children
|
|
|
|
type(pointer_meta) :: neigh(ndims,2,2) ! pointers to neighbors
|
|
|
|
|
|
|
|
type(block_data) , pointer :: data ! pointer to the data block
|
|
|
|
|
|
|
|
integer(kind=4) :: id ! block identificator
|
|
|
|
integer(kind=4) :: cpu ! the cpu id of the block
|
|
|
|
integer(kind=4) :: level ! refinement level
|
2009-09-10 17:25:28 -03:00
|
|
|
integer(kind=4) :: config ! configuration flag
|
2009-09-09 16:37:28 -03:00
|
|
|
integer(kind=4) :: refine ! refinement flag:
|
|
|
|
! -1 - derefine
|
|
|
|
! 0 - do nothing
|
|
|
|
! 1 - refine
|
|
|
|
|
|
|
|
logical :: leaf ! leaf flag
|
|
|
|
end type block_meta
|
|
|
|
|
|
|
|
! define block_data structure
|
|
|
|
!
|
|
|
|
type block_data
|
|
|
|
type(block_data), pointer :: prev ! pointer to the previous block
|
|
|
|
type(block_data), pointer :: next ! pointer to the next block
|
|
|
|
|
|
|
|
type(block_meta), pointer :: meta ! pointer to the metadata block
|
|
|
|
|
|
|
|
real :: xmin, xmax ! bounds for the x direction
|
|
|
|
real :: ymin, ymax ! bounds for the y direction
|
|
|
|
real :: zmin, zmax ! bounds for the z direction
|
|
|
|
|
|
|
|
real, dimension(:,:,:,:), allocatable :: u ! variable array
|
|
|
|
real, dimension(:,:,:) , allocatable :: c ! criterion array
|
|
|
|
end type block_data
|
|
|
|
|
2009-09-18 17:43:48 -03:00
|
|
|
! define block_info structure for boundary exchange
|
|
|
|
!
|
|
|
|
type block_info
|
|
|
|
type(block_info) , pointer :: prev ! pointer to the previous block
|
|
|
|
type(block_info) , pointer :: next ! pointer to the next block
|
|
|
|
type(block_meta) , pointer :: block ! pointer to the meta block
|
|
|
|
type(block_meta) , pointer :: neigh ! pointer to the neighbor block
|
2009-09-18 20:34:23 -03:00
|
|
|
integer(kind=4) :: direction ! direction of the neighbor block
|
|
|
|
integer(kind=4) :: side ! side of the neighbor block
|
|
|
|
integer(kind=4) :: face ! face of the neighbor block
|
|
|
|
integer(kind=4) :: level_difference ! the difference of levels
|
2009-09-18 17:43:48 -03:00
|
|
|
end type block_info
|
|
|
|
|
2009-09-09 16:37:28 -03:00
|
|
|
|
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
|
|
|
|
|
2009-09-09 16:37:28 -03:00
|
|
|
! chains of meta blocks and data blocks
|
|
|
|
!
|
2009-09-10 17:25:28 -03:00
|
|
|
type(block_meta), pointer, save :: list_meta, last_meta
|
|
|
|
type(block_data), pointer, save :: list_data, last_data
|
2009-09-09 16:37:28 -03:00
|
|
|
|
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-09-11 21:52:18 -03:00
|
|
|
integer(kind=4) , save :: nblocks, dblocks, 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
|
|
|
!
|
2009-09-10 16:18:59 -03:00
|
|
|
! check if metadata list is empty
|
|
|
|
!
|
|
|
|
if (associated(list_meta)) &
|
|
|
|
call print_warning("blocks::init_blocks", "Block metadata list is already associated!")
|
|
|
|
|
|
|
|
! check if data list is empty
|
|
|
|
!
|
|
|
|
if (associated(list_data)) &
|
|
|
|
call print_warning("blocks::init_blocks", "Block data list is already associated!")
|
|
|
|
|
|
|
|
! nullify all pointers
|
|
|
|
!
|
|
|
|
nullify(list_meta)
|
|
|
|
nullify(list_data)
|
|
|
|
|
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-09-11 21:52:18 -03:00
|
|
|
dblocks = 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
|
|
|
!-------------------------------------------------------------------------------
|
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
|
|
|
!
|
2009-09-10 16:18:59 -03:00
|
|
|
type(block_meta), pointer :: pblock_meta
|
|
|
|
type(block_data), pointer :: pblock_data
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2008-12-18 23:47:58 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-07 00:10:09 -06:00
|
|
|
!
|
2009-09-10 16:18:59 -03:00
|
|
|
! clear all meta blocks
|
|
|
|
!
|
|
|
|
pblock_meta => list_meta
|
|
|
|
do while(associated(pblock_meta))
|
2009-09-13 22:58:55 -03:00
|
|
|
! print *, pblock_meta%level, pblock_meta%id, pblock_meta%neigh(1,1,1)%ptr%id, pblock_meta%neigh(1,2,1)%ptr%id, pblock_meta%neigh(2,1,1)%ptr%id, pblock_meta%neigh(2,2,1)%ptr%id
|
2009-09-10 16:18:59 -03:00
|
|
|
call deallocate_metablock(pblock_meta)
|
|
|
|
pblock_meta => list_meta
|
|
|
|
end do
|
|
|
|
|
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 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
|
|
|
!
|
2009-09-10 17:25:28 -03:00
|
|
|
! allocate_metablock: subroutine allocates space for one meta block and returns
|
|
|
|
! the pointer to this block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine allocate_metablock(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(out) :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate block structure
|
|
|
|
!
|
|
|
|
allocate(pblock)
|
|
|
|
|
|
|
|
! nullify pointers
|
|
|
|
!
|
|
|
|
nullify(pblock%prev)
|
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%parent)
|
|
|
|
nullify(pblock%data)
|
|
|
|
do i = 1, nchild
|
|
|
|
nullify(pblock%child(i)%ptr)
|
|
|
|
end do
|
2009-09-11 21:52:18 -03:00
|
|
|
do k = 1, nfaces
|
|
|
|
do j = 1, nsides
|
2009-09-10 17:25:28 -03:00
|
|
|
do i = 1, ndims
|
|
|
|
nullify(pblock%neigh(i,j,k)%ptr)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! set unique ID
|
|
|
|
!
|
|
|
|
pblock%id = increase_id()
|
|
|
|
|
|
|
|
! unset the CPU number of current block, level, the configuration, refine and
|
|
|
|
! leaf flags
|
|
|
|
!
|
|
|
|
pblock%cpu = -1
|
|
|
|
pblock%level = -1
|
|
|
|
pblock%config = -1
|
|
|
|
pblock%refine = 0
|
|
|
|
pblock%leaf = .false.
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! increase the number of allocated meta blocks
|
|
|
|
!
|
|
|
|
nblocks = nblocks + 1
|
|
|
|
|
2009-09-10 17:25:28 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine allocate_metablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! allocate_datablock: subroutine allocates space for one data block and returns
|
|
|
|
! the pointer to this block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine allocate_datablock(pblock)
|
|
|
|
|
|
|
|
use config, only : im, jm, km
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer, intent(out) :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate block structure
|
|
|
|
!
|
|
|
|
allocate(pblock)
|
|
|
|
|
|
|
|
! nullify pointers
|
|
|
|
!
|
|
|
|
nullify(pblock%prev)
|
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%meta)
|
|
|
|
|
|
|
|
! allocate space for variables
|
|
|
|
!
|
|
|
|
allocate(pblock%u(nvars,im,jm,km))
|
|
|
|
allocate(pblock%c(im,jm,km))
|
|
|
|
|
|
|
|
! initialize bounds of the block
|
|
|
|
!
|
|
|
|
pblock%xmin = 0.0
|
|
|
|
pblock%xmax = 1.0
|
|
|
|
pblock%ymin = 0.0
|
|
|
|
pblock%ymax = 1.0
|
|
|
|
pblock%zmin = 0.0
|
|
|
|
pblock%zmax = 1.0
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! increase the number of allocated meta blocks
|
|
|
|
!
|
|
|
|
dblocks = dblocks + 1
|
|
|
|
|
2009-09-10 17:25:28 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine allocate_datablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
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
|
|
|
!
|
2009-09-10 16:18:59 -03:00
|
|
|
! deallocate_metablock: subroutine deallocates space ocuppied by a given metablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine deallocate_metablock(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
if (associated(pblock)) then
|
|
|
|
|
|
|
|
! if this is the first block in the list, update the plist pointer
|
|
|
|
!
|
|
|
|
if (pblock%id .eq. list_meta%id) &
|
|
|
|
list_meta => 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
|
|
|
|
|
|
|
|
! nullify children
|
|
|
|
!
|
|
|
|
do i = 1, nchild
|
|
|
|
nullify(pblock%child(i)%ptr)
|
|
|
|
end do
|
|
|
|
|
|
|
|
! nullify neighbors
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do k = 1, nfaces
|
|
|
|
do j = 1, nsides
|
2009-09-10 16:18:59 -03:00
|
|
|
do i = 1, ndims
|
|
|
|
nullify(pblock%neigh(i,j,k)%ptr)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! if corresponding data block is allocated, deallocate it too
|
|
|
|
!
|
|
|
|
if (associated(pblock%data)) &
|
|
|
|
call deallocate_datablock(pblock%data)
|
|
|
|
|
2009-09-10 16:18:59 -03:00
|
|
|
! nullify pointers
|
|
|
|
!
|
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%prev)
|
|
|
|
nullify(pblock%data)
|
|
|
|
nullify(pblock%parent)
|
|
|
|
|
|
|
|
! free and nullify the block
|
|
|
|
!
|
|
|
|
deallocate(pblock)
|
|
|
|
nullify(pblock)
|
2009-09-13 22:58:55 -03:00
|
|
|
|
|
|
|
! decrease the number of allocated blocks
|
|
|
|
!
|
|
|
|
nblocks = nblocks - 1
|
|
|
|
|
2009-09-10 16:18:59 -03:00
|
|
|
endif
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine deallocate_metablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! deallocate_datablock: subroutine deallocates space ocuppied by a given datablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine deallocate_datablock(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
if (associated(pblock)) then
|
|
|
|
|
|
|
|
! if this is the first block in the list, update the plist pointer
|
|
|
|
!
|
|
|
|
if (pblock%meta%id .eq. list_data%meta%id) &
|
|
|
|
list_data => 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
|
|
|
|
|
|
|
|
! deallocate variables
|
|
|
|
!
|
|
|
|
deallocate(pblock%u)
|
|
|
|
deallocate(pblock%c)
|
|
|
|
|
|
|
|
! nullify pointers
|
|
|
|
!
|
|
|
|
nullify(pblock%next)
|
|
|
|
nullify(pblock%prev)
|
|
|
|
nullify(pblock%meta)
|
|
|
|
|
|
|
|
! free and nullify the block
|
|
|
|
!
|
|
|
|
deallocate(pblock)
|
|
|
|
nullify(pblock)
|
2009-09-13 22:58:55 -03:00
|
|
|
|
|
|
|
! decrease the number of allocated blocks
|
|
|
|
!
|
|
|
|
dblocks = dblocks - 1
|
|
|
|
|
2009-09-10 16:18:59 -03:00
|
|
|
endif
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine deallocate_datablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
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
|
|
|
!
|
2009-09-10 17:25:28 -03:00
|
|
|
! append_metablock: subroutine allocates space for one meta block and appends it
|
|
|
|
! to the meta block list
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine append_metablock(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(out) :: pblock
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate block
|
|
|
|
!
|
|
|
|
call allocate_metablock(pblock)
|
|
|
|
|
|
|
|
! add to the list
|
|
|
|
!
|
|
|
|
if (associated(list_meta)) then
|
|
|
|
pblock%prev => last_meta
|
|
|
|
last_meta%next => pblock
|
|
|
|
else
|
|
|
|
list_meta => pblock
|
|
|
|
endif
|
|
|
|
|
|
|
|
! set the pointer to the last block in the list
|
|
|
|
!
|
|
|
|
last_meta => pblock
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine append_metablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! append_datablock: subroutine allocates space for one data block and appends it
|
|
|
|
! to the data block list
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine append_datablock(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer, intent(out) :: pblock
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate block
|
|
|
|
!
|
|
|
|
call allocate_datablock(pblock)
|
|
|
|
|
|
|
|
! add to the list
|
|
|
|
!
|
|
|
|
if (associated(list_data)) then
|
|
|
|
pblock%prev => last_data
|
|
|
|
last_data%next => pblock
|
|
|
|
else
|
|
|
|
list_data => pblock
|
|
|
|
endif
|
|
|
|
|
|
|
|
! set the pointer to the last block in the list
|
|
|
|
!
|
|
|
|
last_data => pblock
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine append_datablock
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2009-09-10 17:46:36 -03:00
|
|
|
! associate_blocks: subroutine associates a pair of meta and data blocks
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine associate_blocks(pblock_meta, pblock_data)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock_meta
|
|
|
|
type(block_data), pointer, intent(inout) :: pblock_data
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
pblock_meta%data => pblock_data
|
|
|
|
pblock_data%meta => pblock_meta
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine associate_blocks
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2009-09-10 18:15:30 -03:00
|
|
|
! metablock_setleaf: subroutine sets the leaf flag of data block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine metablock_setleaf(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input/output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set the leaf flag
|
|
|
|
!
|
|
|
|
pblock%leaf = .true.
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! increase the number of leafs
|
|
|
|
!
|
|
|
|
nleafs = nleafs + 1
|
2009-09-10 18:15:30 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine metablock_setleaf
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! metablock_unsetleaf: subroutine unsets the leaf flag of data block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine metablock_unsetleaf(pblock)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input/output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set the leaf flag
|
|
|
|
!
|
|
|
|
pblock%leaf = .false.
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! decrease the number of leafs
|
|
|
|
!
|
|
|
|
nleafs = nleafs - 1
|
2009-09-10 18:15:30 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine metablock_unsetleaf
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! metablock_setconfig: subroutine sets the config flag of data block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine metablock_setconfig(pblock, config)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input/output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
integer(kind=4) , intent(in) :: config
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set the config flag
|
|
|
|
!
|
|
|
|
pblock%config = config
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine metablock_setconfig
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! metablock_setlevel: subroutine sets the level of data block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine metablock_setlevel(pblock, level)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input/output arguments
|
|
|
|
!
|
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
integer(kind=4) , intent(in) :: level
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set the refinement level
|
|
|
|
!
|
|
|
|
pblock%level = level
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine metablock_setlevel
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2009-09-10 17:46:36 -03:00
|
|
|
! datablock_setbounds: subroutine sets the bounds of data block
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine datablock_setbounds(pblock, xmin, xmax, ymin, ymax, zmin, zmax)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! input/output arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2009-09-10 18:15:30 -03:00
|
|
|
real , intent(in) :: xmin, xmax, ymin, ymax, zmin, zmax
|
2009-09-10 17:46:36 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set bounds of the block
|
|
|
|
!
|
|
|
|
pblock%xmin = xmin
|
|
|
|
pblock%xmax = xmax
|
|
|
|
pblock%ymin = ymin
|
|
|
|
pblock%ymax = ymax
|
|
|
|
pblock%zmin = zmin
|
|
|
|
pblock%zmax = zmax
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine datablock_setbounds
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
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
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
subroutine refine_block(pblock, falloc_data)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
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
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_meta), pointer, intent(inout) :: pblock
|
|
|
|
logical , intent(in) :: falloc_data
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
! pointers
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_meta), pointer :: pneigh, pchild, pfirst, plast
|
|
|
|
type(block_data), pointer :: pdata
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
integer, dimension(nchild) :: config, order
|
|
|
|
integer, dimension(ndims,nsides,nfaces) :: set
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: p, i, j, k
|
|
|
|
real :: xln, yln, zln, xmn, xmx, ymn, ymx, zmn, zmx
|
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
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! unset block leaf flag
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
call metablock_unsetleaf(pblock)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! reset refinement flag
|
2009-05-18 22:46:19 +02:00
|
|
|
!
|
|
|
|
pblock%refine = 0
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! iterate over all child blocks
|
2009-05-18 22:46:19 +02:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do p = 1, nchild
|
2009-05-18 22:46:19 +02:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! create child meta and data blocks
|
2009-05-18 22:46:19 +02:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
call allocate_metablock(pblock%child(p)%ptr)
|
2009-05-18 22:46:19 +02:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! set it as a leaf
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
call metablock_setleaf(pblock%child(p)%ptr)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! assign pointer to the parent block
|
2008-12-05 14:22:02 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
pblock%child(p)%ptr%parent => pblock
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! increase the refinement level
|
2009-01-02 20:18:57 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
pblock%child(p)%ptr%level = pblock%level + 1
|
2009-01-02 20:18:57 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! copy the parent cpu number to each child
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
pblock%child(p)%ptr%cpu = pblock%cpu
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! assign neighbors of the child blocks
|
2009-09-13 22:58:55 -03:00
|
|
|
!
|
|
|
|
! interior of the block
|
2009-09-11 21:52:18 -03:00
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
|
|
|
|
! X direction (left side)
|
|
|
|
!
|
|
|
|
pblock%child(2)%ptr%neigh(1,1,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(1,1,p)%ptr => pblock%child(3)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(6)%ptr%neigh(1,1,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(1,1,p)%ptr => pblock%child(7)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(1,1,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(1)%ptr%neigh(1,1,p)%ptr => pblock%child(2)%ptr
|
|
|
|
pblock%child(3)%ptr%neigh(1,1,p)%ptr => pblock%child(4)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(5)%ptr%neigh(1,1,p)%ptr => pblock%child(6)%ptr
|
|
|
|
pblock%child(7)%ptr%neigh(1,1,p)%ptr => pblock%child(8)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! X direction (right side)
|
|
|
|
!
|
|
|
|
pblock%child(1)%ptr%neigh(1,2,p)%ptr => pblock%child(2)%ptr
|
|
|
|
pblock%child(3)%ptr%neigh(1,2,p)%ptr => pblock%child(4)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(5)%ptr%neigh(1,2,p)%ptr => pblock%child(6)%ptr
|
|
|
|
pblock%child(7)%ptr%neigh(1,2,p)%ptr => pblock%child(8)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(1,2,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(2)%ptr%neigh(1,2,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(1,2,p)%ptr => pblock%child(3)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(6)%ptr%neigh(1,2,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(1,2,p)%ptr => pblock%child(7)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! Y direction (left side)
|
|
|
|
!
|
|
|
|
pblock%child(3)%ptr%neigh(2,1,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(2,1,p)%ptr => pblock%child(2)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(7)%ptr%neigh(2,1,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(2,1,p)%ptr => pblock%child(6)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(2,1,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(1)%ptr%neigh(2,1,p)%ptr => pblock%child(3)%ptr
|
|
|
|
pblock%child(2)%ptr%neigh(2,1,p)%ptr => pblock%child(4)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(5)%ptr%neigh(2,1,p)%ptr => pblock%child(7)%ptr
|
|
|
|
pblock%child(6)%ptr%neigh(2,1,p)%ptr => pblock%child(8)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! Y direction (right side)
|
|
|
|
!
|
|
|
|
pblock%child(1)%ptr%neigh(2,2,p)%ptr => pblock%child(3)%ptr
|
|
|
|
pblock%child(2)%ptr%neigh(2,2,p)%ptr => pblock%child(4)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(5)%ptr%neigh(2,2,p)%ptr => pblock%child(7)%ptr
|
|
|
|
pblock%child(6)%ptr%neigh(2,2,p)%ptr => pblock%child(8)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(2,2,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(3)%ptr%neigh(2,2,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(2,2,p)%ptr => pblock%child(2)%ptr
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%child(7)%ptr%neigh(2,2,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(2,2,p)%ptr => pblock%child(6)%ptr
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
#if NDIMS == 3
|
|
|
|
! Z direction (left side)
|
|
|
|
!
|
|
|
|
pblock%child(5)%ptr%neigh(3,1,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(6)%ptr%neigh(3,1,p)%ptr => pblock%child(2)%ptr
|
|
|
|
pblock%child(7)%ptr%neigh(3,1,p)%ptr => pblock%child(3)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(3,1,p)%ptr => pblock%child(4)%ptr
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(3,1,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(1)%ptr%neigh(3,1,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(2)%ptr%neigh(3,1,p)%ptr => pblock%child(6)%ptr
|
|
|
|
pblock%child(3)%ptr%neigh(3,1,p)%ptr => pblock%child(7)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(3,1,p)%ptr => pblock%child(8)%ptr
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
! Z direction (right side)
|
|
|
|
!
|
|
|
|
pblock%child(1)%ptr%neigh(3,2,p)%ptr => pblock%child(5)%ptr
|
|
|
|
pblock%child(2)%ptr%neigh(3,2,p)%ptr => pblock%child(6)%ptr
|
|
|
|
pblock%child(3)%ptr%neigh(3,2,p)%ptr => pblock%child(7)%ptr
|
|
|
|
pblock%child(4)%ptr%neigh(3,2,p)%ptr => pblock%child(8)%ptr
|
2009-09-13 22:58:55 -03:00
|
|
|
pneigh => pblock%neigh(3,2,1)%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .eq. pblock%id) then
|
|
|
|
pblock%child(5)%ptr%neigh(3,2,p)%ptr => pblock%child(1)%ptr
|
|
|
|
pblock%child(6)%ptr%neigh(3,2,p)%ptr => pblock%child(2)%ptr
|
|
|
|
pblock%child(7)%ptr%neigh(3,2,p)%ptr => pblock%child(3)%ptr
|
|
|
|
pblock%child(8)%ptr%neigh(3,2,p)%ptr => pblock%child(4)%ptr
|
|
|
|
endif
|
|
|
|
endif
|
2009-09-11 21:52:18 -03:00
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! prepare set array
|
2008-12-06 20:11:36 -06:00
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
#if NDIMS == 2
|
|
|
|
set(1,1,:) = (/ 1, 3 /)
|
|
|
|
set(1,2,:) = (/ 2, 4 /)
|
|
|
|
set(2,1,:) = (/ 1, 2 /)
|
|
|
|
set(2,2,:) = (/ 3, 4 /)
|
|
|
|
#endif /* NDIMS == 2 */
|
2009-09-11 21:52:18 -03:00
|
|
|
#if NDIMS == 3
|
2009-09-13 22:58:55 -03:00
|
|
|
set(1,1,:) = (/ 1, 3, 5, 7 /)
|
|
|
|
set(1,2,:) = (/ 2, 4, 6, 8 /)
|
|
|
|
set(2,1,:) = (/ 1, 2, 5, 6 /)
|
|
|
|
set(2,2,:) = (/ 3, 4, 7, 8 /)
|
|
|
|
set(3,1,:) = (/ 1, 2, 3, 4 /)
|
|
|
|
set(3,2,:) = (/ 5, 6, 7, 8 /)
|
2009-09-11 21:52:18 -03:00
|
|
|
#endif /* NDIMS == 3 */
|
2009-05-18 22:46:19 +02:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! set pointers to neighbors and update neighbors pointers
|
2009-09-11 21:52:18 -03:00
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
do i = 1, ndims
|
|
|
|
do j = 1, nsides
|
|
|
|
do k = 1, nfaces
|
|
|
|
pneigh => pblock%neigh(i,j,k)%ptr
|
2009-05-18 22:46:19 +02:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
if (associated(pneigh)) then
|
|
|
|
if (pneigh%id .ne. pblock%id) then
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! point to the right neighbor
|
2009-09-11 21:52:18 -03:00
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
do p = 1, nfaces
|
|
|
|
pblock%child(set(i,j,k))%ptr%neigh(i,j,p)%ptr => pneigh
|
|
|
|
end do
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! neighbor level is the same as the refined block
|
2009-09-11 21:52:18 -03:00
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
if (pneigh%level .eq. pblock%level) then
|
|
|
|
pneigh%neigh(i,3-j,k)%ptr => pblock%child(set(i,j,k))%ptr
|
|
|
|
end if
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! neighbor level is the same as the child block
|
2009-09-11 21:52:18 -03:00
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
if (pneigh%level .gt. pblock%level) then
|
|
|
|
do p = 1, nfaces
|
|
|
|
pneigh%neigh(i,3-j,p)%ptr => pblock%child(set(i,j,k))%ptr
|
|
|
|
end do
|
|
|
|
end if
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
end if
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
end if
|
2008-12-19 16:36:07 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
end do
|
2009-09-13 22:58:55 -03:00
|
|
|
end do
|
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! set corresponding configuration of the new blocks
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
|
|
|
select case(pblock%config)
|
2009-09-11 21:52:18 -03:00
|
|
|
case(0) ! 'Z'
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
#if NDIMS == 2
|
|
|
|
config(:) = (/ 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4 /)
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
case(1) ! 'N'
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
#if NDIMS == 2
|
|
|
|
config(:) = (/ 2, 1, 1, 3 /)
|
|
|
|
order (:) = (/ 1, 3, 4, 2 /)
|
|
|
|
#endif /* NDIMS == 2 */
|
2009-09-13 22:58:55 -03:00
|
|
|
#if NDIMS == 3
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
case(2) ! 'D'
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
#if NDIMS == 2
|
|
|
|
config(:) = (/ 1, 2, 2, 4 /)
|
|
|
|
order (:) = (/ 1, 2, 4, 3 /)
|
|
|
|
#endif /* NDIMS == 2 */
|
2009-09-13 22:58:55 -03:00
|
|
|
#if NDIMS == 3
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
case(3) ! 'C'
|
|
|
|
|
|
|
|
#if NDIMS == 2
|
|
|
|
config(:) = (/ 4, 3, 3, 1 /)
|
2009-09-13 22:58:55 -03:00
|
|
|
order (:) = (/ 4, 3, 1, 2 /)
|
2009-09-11 21:52:18 -03:00
|
|
|
#endif /* NDIMS == 2 */
|
2009-09-13 22:58:55 -03:00
|
|
|
#if NDIMS == 3
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
case(4) ! 'U'
|
|
|
|
|
|
|
|
#if NDIMS == 2
|
|
|
|
config(:) = (/ 3, 4, 4, 2 /)
|
2009-09-13 22:58:55 -03:00
|
|
|
order (:) = (/ 4, 2, 1, 3 /)
|
2009-09-11 21:52:18 -03:00
|
|
|
#endif /* NDIMS == 2 */
|
2009-09-13 22:58:55 -03:00
|
|
|
#if NDIMS == 3
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
#if NDIMS == 3
|
|
|
|
case(5)
|
|
|
|
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
|
|
|
|
case(6)
|
|
|
|
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
|
|
|
|
case(7)
|
|
|
|
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
|
|
|
|
case(8)
|
|
|
|
|
|
|
|
config(:) = (/ 0, 0, 0, 0, 0, 0, 0, 0 /)
|
|
|
|
order (:) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
|
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-11 21:52:18 -03:00
|
|
|
|
|
|
|
end select
|
2008-12-05 14:04:12 -06:00
|
|
|
|
|
|
|
! set blocks configurations
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do p = 1, nchild
|
2009-09-13 22:58:55 -03:00
|
|
|
pblock%child(order(p))%ptr%config = config(p)
|
2009-09-11 21:52:18 -03:00
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! connect blocks in chain
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do p = 2, nchild
|
|
|
|
pblock%child(order(p ))%ptr%prev => pblock%child(order(p-1))%ptr
|
|
|
|
pblock%child(order(p-1))%ptr%next => pblock%child(order(p ))%ptr
|
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! insert this chain after the parent block
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
pneigh => pblock%next
|
|
|
|
pfirst => pblock%child(order( 1))%ptr
|
|
|
|
plast => pblock%child(order(nchild))%ptr
|
|
|
|
if (associated(pneigh)) then
|
|
|
|
pneigh%prev => plast
|
|
|
|
plast%next => pneigh
|
|
|
|
else
|
|
|
|
last_meta => plast
|
|
|
|
endif
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
pblock%next => pfirst
|
|
|
|
pfirst%prev => pblock
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! allocate data blocks if necessary
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
if (falloc_data) then
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! calculate the size of new blocks
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
xln = 0.5 * (pblock%data%xmax - pblock%data%xmin)
|
|
|
|
yln = 0.5 * (pblock%data%ymax - pblock%data%ymin)
|
|
|
|
#if NDIMS == 3
|
|
|
|
zln = 0.5 * (pblock%data%zmax - pblock%data%zmin)
|
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
zln = (pblock%data%zmax - pblock%data%zmin)
|
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! iterate over all children and allocate data blocks
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do p = 1, nchild
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! assign a pointer to the current child
|
|
|
|
!
|
2009-09-13 22:58:55 -03:00
|
|
|
pchild => pblock%child(p)%ptr
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! allocate data block
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
call allocate_datablock(pdata)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! calculate block bounds
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
i = mod((p - 1) ,2)
|
|
|
|
j = mod((p - 1) / 2,2)
|
|
|
|
k = mod((p - 1) / 4,2)
|
|
|
|
|
|
|
|
xmn = pblock%data%xmin + xln * i
|
2009-09-13 22:58:55 -03:00
|
|
|
ymn = pblock%data%ymin + yln * j
|
|
|
|
zmn = pblock%data%zmin + zln * k
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
xmx = xmn + xln
|
|
|
|
ymx = ymn + yln
|
|
|
|
zmx = zmn + zln
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! set block bounds
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
call datablock_setbounds(pdata, xmn, xmx, ymn, ymx, zmn, zmx)
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! associate with the meta block
|
|
|
|
!
|
|
|
|
call associate_blocks(pchild, pdata)
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! connect blocks in chain
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
do p = 2, nchild
|
|
|
|
pblock%child(order(p ))%ptr%data%prev => pblock%child(order(p-1))%ptr%data
|
|
|
|
pblock%child(order(p-1))%ptr%data%next => pblock%child(order(p ))%ptr%data
|
|
|
|
end do
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! insert this chain after the parent block
|
2008-12-05 14:04:12 -06:00
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
pdata => pblock%data%next
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
pfirst => pblock%child(order( 1))%ptr
|
|
|
|
plast => pblock%child(order(nchild))%ptr
|
2008-12-05 14:04:12 -06:00
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
if (associated(pdata)) then
|
|
|
|
pdata%prev => plast%data
|
|
|
|
plast%data%next => pdata
|
|
|
|
else
|
|
|
|
last_data => plast%data
|
2008-12-05 14:04:12 -06:00
|
|
|
endif
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
pblock%data%next => pfirst%data
|
|
|
|
pfirst%data%prev => pblock%data
|
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! prolongate data block
|
|
|
|
!
|
|
|
|
! TODO: call subroutine which prolongates data from parent block to children
|
|
|
|
!
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
end if
|
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
! deallocate refined block
|
|
|
|
!
|
|
|
|
! call deallocate_metablock(pblock)
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
! point the current block to the last created one
|
|
|
|
!
|
|
|
|
pblock => plast
|
|
|
|
|
2008-12-05 14:04:12 -06:00
|
|
|
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
|
|
|
|
|
|
|
! 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
|