D.3.1 Initialize_Base_Structure Procedure

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

  subroutine Initialize_Base_Structure (Structure, Length_Vector, Locus, &
                                        status)

    ! Use associations.

    use Caesar_Flags_Module, only: initialized_flag

    ! Input variables.

    type(integer,1) :: Length_Vector                 ! Length for each PE.
    type(character,*), intent(in), optional :: Locus ! Distributed location.

    ! Output variables.

    ! Base_Structure to be initialized.
    type(Base_Structure_type), intent(out) :: Structure 
    type(Status_type), intent(out), optional :: status  ! Exit status.

    ! Internal variables.

    type(Status_type) :: allocate_status ! Allocation Status.

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

    ! Verify requirements.

    VERIFY(SIZE(Length_Vector)==NPEs,5)   ! Length_Vector is the right size.
    VERIFY(Valid_State(Length_Vector),5)  ! Length_Vector is valid.

    ! Allocations and initializations.

    call Initialize (allocate_status)
    call Initialize (Structure%Length_Vector, NPEs, allocate_status)
    if (PRESENT(status)) then
      WARN_IF(Error(allocate_status), 5)
      status = allocate_status
    else
      VERIFY(Normal(allocate_status), 5)
    end if
    call Finalize (allocate_status)

    ! Set up internals.

    if (PRESENT(Locus)) Structure%Locus = Locus
    Structure%Length_Vector = Length_Vector
    Structure%Length_Total = SUM(Length_Vector)
    Structure%Length_PE = Length_Vector(this_PE)
    Structure%Last_PE = SUM(Length_Vector(1:this_PE))
    Structure%First_PE = Structure%Last_PE - Structure%Length_PE + 1
    Structure%Range_PE = (/ Structure%First_PE, Structure%Last_PE /)

    ! Set initialization flag.

    Structure%Initialized = initialized_flag

    ! Verify guarantees.

    VERIFY(Valid_State(Structure),5)  ! Structure is now valid.

    return
  end subroutine Initialize_Base_Structure



Michael L. Hall