D.4.7 Initialize_Shell_Partition Procedure

The main documentation of the Initialize_Shell_Partition Procedure contains additional explanation of this code listing.

  subroutine Initialize_Shell_Partition (NDimensions, Cell_Structure, &
                                         Node_Structure, &
                                         Nodes_of_Cells_Index, Output)

    ! Input variables.

    type(integer) :: NDimensions                  ! Number of dimensions.
    type(logical) :: Output                       ! Output toggle.

    ! Output variables.

    type(Base_Structure_type) :: Cell_Structure   ! Structure for the Cells.
    type(Base_Structure_type) :: Node_Structure   ! Structure for the Nodes.
    type(Data_Index_type) :: Nodes_of_Cells_Index ! Data Index object.

    ! Internal variables.

    type(integer,3) :: c                      ! Shell Partition numbers.
    type(integer) :: cell                     ! Loop counter.
    type(integer) :: cell_PE                  ! Cell # on this PE.
    type(integer) :: i, j, k                  ! Structured mesh indices.
    type(integer,1) :: i_of_c, j_of_c, k_of_c ! Inverse Shell Partition 
                                              ! numbers.
    type(integer,1) :: Length_Vector          ! Lengths for each PE.
    type(character,name_length) :: Locus      ! Locus name.
    type(integer) :: NCells_PE                ! Number of cells on this PE.
    type(integer) :: NNodes_per_Side          ! Number of nodes of one edge.
    type(integer) :: NNodes_per_Cell          ! Local # of nodes per cell.
    type(integer) :: NNodes_Total             ! Number of nodes in the whole 
                                              ! mesh.
    type(integer,2) :: Nodes_of_Cells_Array   ! Index array.
    type(Status_type) :: status               ! Status variable.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Initialize temporaries.

    call Initialize (status)
    call Initialize (Locus)
    call Initialize (Length_Vector, NPEs)
    NNodes_per_Side = NPEs + 1
    call Initialize (c, NNodes_per_Side, NNodes_per_Side, NNodes_per_Side)

    ! NDimensions-dependent Initializations.

    NNodes_Total = NNodes_per_Side**NDimensions
    call Initialize (i_of_c, NNodes_Total)
    call Initialize (j_of_c, NNodes_Total)
    call Initialize (k_of_c, NNodes_Total)
  
    ! Set up cell structure (Shell Partitioning).
  
    Locus = 'Cells'
    Length_Vector = (/ (i**NDimensions - (i-1)**NDimensions, i = 1, NPEs) /)
    call Initialize (Cell_Structure, Length_Vector, Locus, status)
  
    ! Set up node structure (Shell Partitioning plus extra layer of nodes).
  
    Locus = 'Nodes'
    Length_Vector(NPEs) = Length_Vector(NPEs) + &
                          (NPEs+1)**NDimensions - NPEs**NDimensions
    call Initialize (Node_Structure, Length_Vector, Locus, status)
  
    ! Generate Shell Partitioning numbers.
  
    call Generate_Shell_Partition (c, i_of_c, j_of_c, k_of_c, NDimensions, &
                                   NNodes_per_Side, Output)
  
    ! Set up Nodes_of_Cells array.
  
    NCells_PE = Length_PE(Cell_Structure)
    NNodes_per_Cell = 2**NDimensions
    call Initialize (Nodes_of_Cells_Array, NCells_PE, NNodes_per_Cell)
    do cell = First_PE(Cell_Structure), Last_PE(Cell_Structure)
      i = i_of_c(cell)
      j = j_of_c(cell)
      k = k_of_c(cell)
      cell_PE = cell - First_PE(Cell_Structure) + 1
      Nodes_of_Cells_Array(cell_PE,1) = c(i,j,k)
      Nodes_of_Cells_Array(cell_PE,2) = c(i+1,j,k)
      if (NDimensions >= 2) then
        Nodes_of_Cells_Array(cell_PE,3) = c(i,j+1,k)
        Nodes_of_Cells_Array(cell_PE,4) = c(i+1,j+1,k)
        if (NDimensions == 3) then
          Nodes_of_Cells_Array(cell_PE,5) = c(i,j,k+1)
          Nodes_of_Cells_Array(cell_PE,6) = c(i+1,j,k+1)
          Nodes_of_Cells_Array(cell_PE,7) = c(i,j+1,k+1)
          Nodes_of_Cells_Array(cell_PE,8) = c(i+1,j+1,k+1)
        end if
      end if
    end do
  
    ! Set up Nodes_of_Cells data index.
  
    call Initialize (Nodes_of_Cells_Index, Node_Structure, Cell_Structure, &
                     Many_of_One_Array=Nodes_of_Cells_Array, status=status)

    ! Finalize temporaries.

    call Finalize (Length_Vector)
    call Finalize (c)
    call Finalize (Locus)
    call Finalize (status)

    ! Finalize NDimensions-dependent data structures.
  
    call Finalize (i_of_c)
    call Finalize (j_of_c)
    call Finalize (k_of_c)
    call Finalize (Nodes_of_Cells_Array)

  end subroutine Initialize_Shell_Partition



Michael L. Hall