module fd4_globaldef_mod module fd4_vartab_mod module fd4_mpi_mod module rbtree_int_modTypes:
public type fd4_data_link public type fd4_block_link public type fd4_cell_link public type fd4_r_k_link public type fd4_blockVariables:
integer (kind=i4k), public, parameter, dimension (3,2) :: BLOCK_EMPTY = reshape ((/ 2, 4, 8, 16, 32, 64 /), (/ 3, 2 /))Subroutines and functions:
public subroutine fd4_block_allocate (b, bext, vartab, varinfo, init, build_type, alloc_face, need_empty, err) public subroutine fd4_block_reset (b, vartab, varinfo, init) public subroutine fd4_block_deallocate (b) public subroutine fd4_block_empty (b, vartab, varinfo, idx, st, emptyplanes) private subroutine fd4_block_build_type (b, need_empty, err)
A block is a rectangular subset of the spatial grid. It is the smallest unit for load balancing.
Blocks have an additional field weight which respects their computational weight. Load balancing routines (should) use this weight. The default value of the weight is the number of grid cells of the block.
Preprocessor options:
Author: Matthias Lieber
public type fd4_data_link real (kind=r_k), pointer, dimension (:,:,:,:) :: l => null () end type fd4_data_linkA helper to build an array of pointers to data fields.
public type fd4_block_link type (fd4_block), pointer :: l => null () end type fd4_block_linkA helper to build an array of pointers to blocks.
public type fd4_cell_link real (kind=r_k), pointer, dimension (:) :: l => null () end type fd4_cell_linkA helper to build an array of pointers to cells.
public type fd4_r_k_link real (kind=r_k), pointer :: l => NULL () end type fd4_r_k_linkA helper used to build an array of pointers (not used in fd4_block, but elsewhere)
public type fd4_block integer (kind=i_k), dimension (3) :: pos integer (kind=i_k), dimension (3,2) :: bnd integer (kind=i_k), dimension (3) :: ext type (fd4_block_link), dimension (3,2) :: neigh type (fd4_data_link), pointer, dimension (:,:) :: fields => null () type (fd4_data_link), dimension (0:4) :: sdata integer (kind=i4k), pointer, dimension (:,:) :: empty => null () integer (kind=i4k) :: sempty real (kind=r4k) :: weight integer :: bltype = MPI_DATATYPE_NULL integer (kind=MPI_ADDRESS_KIND) :: bladdr = 0 end type fd4_blockComponents:
pos | position of the block in the block decomposition |
bnd | bounds of the block in global grid coordinates |
ext | extents of the block |
neigh | array of pointers to spatial neighbors of this block |
fields | array of pointers to array sections of sdata, representing the data fields |
sdata | storage arrays for static data fields (allocated at block creation) |
empty | tells which fields and boundaries are empty (< vthres of vartab) |
sempty | summarized empty info (all vars and time steps) of me |
weight | computational weight of the block |
bltype | MPI datatype for this block |
bladdr | address of block%sempty |
The actual data fields are allocated in sdata:
CAUTION: fields contains pointers to non-continuous array sections of sdata(0:3)%l. Be careful to avoid creation of temporary arrays!
TODO:
See also: module fd4_vartab_mod
public subroutine fd4_block_allocate (b, bext, vartab, varinfo, init, build_type, alloc_face, need_empty, err) type (fd4_block), pointer :: b integer (kind=i_k), intent(in), dimension (3) :: bext type (fd4_vartab), intent(in), dimension (:) :: vartab type (fd4_varinfo), intent(in) :: varinfo logical, intent(in) :: init logical, intent(in) :: build_type logical, intent(in) :: alloc_face logical, intent(in) :: need_empty integer (kind=i_k), intent(out) :: err end subroutine fd4_block_allocateParameters:
b | the block to allocate |
bext | spatial extent of the block |
vartab | variable table containing the definitions of fields to allocate |
varinfo | variable table info |
init | init data fields with vnull? |
build_type | built an MPI type for the block? |
alloc_face | allocate face variables? |
need_empty | need block%empty? |
err | error status, 0 on sucess |
The block itself must be allocated! For internal use only. Error checks require level 3.
public subroutine fd4_block_reset (b, vartab, varinfo, init) type (fd4_block), pointer :: b type (fd4_vartab), intent(in), dimension (:) :: vartab type (fd4_varinfo), intent(in) :: varinfo logical, intent(in) :: init end subroutine fd4_block_resetParameters:
b | the block to allocate |
vartab | variable table containing the definitions of fields to allocate |
varinfo | variable table info |
init | if false: do not init data fields (faster) |
public subroutine fd4_block_deallocate (b) type (fd4_block), pointer :: b end subroutine fd4_block_deallocateParameters:
b | the block to deallocate |
Nullifies the block pointer. For internal use only.
public subroutine fd4_block_empty (b, vartab, varinfo, idx, st, emptyplanes) type (fd4_block), pointer :: b type (fd4_vartab), intent(in), dimension (:) :: vartab type (fd4_varinfo), intent(in) :: varinfo integer (kind=i_k), intent(in) :: idx integer (kind=i_k), intent(in) :: st integer (kind=i_k), intent(in), dimension (3) :: emptyplanes end subroutine fd4_block_emptyParameters:
b | the block |
vartab | variable table |
varinfo | variable info |
idx | field index in vartab |
st | time step index |
emptyplanes | number of "null" cell planes required to the phase boundary, i.e. to not create new block |
Fills block component empty of variable idx at time step st. For internal use only.
TODO:
private subroutine fd4_block_build_type (b, need_empty, err) type (fd4_block), pointer :: b logical, intent(in) :: need_empty integer (kind=i_k), intent(out) :: err end subroutine fd4_block_build_typeParameters:
b | the block |
need_empty | need block%empty? |
err | error status: 0...ok |
Build an MPI datatype for the fd4_block components:
The resulting data type is not commited! Don't forget to MPI_Type_free the type after use.
Internal routine.