D.5.1 Initialize_Assembled_Vector Procedure

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

  subroutine Initialize_Assembled_Vector (AV, Structure, Dimensionality, &
                                          Name, status, dim1, dim2, dim3)

    ! Use associations.

    use Caesar_Flags_Module, only: initialized_flag

    ! Input variables.

    type(Base_Structure_type), target :: Structure            ! Base structure.
    type(character,*), intent(in), optional :: Name           ! Variable name.
    type(integer), intent(in) :: Dimensionality   ! Dimensionality for this AV.
    type(integer), intent(in), optional :: dim1, dim2, dim3   ! Dimensions.

    ! Output variables.

    ! Assembled_Vector to be initialized.
    type(Assembled_Vector_type), intent(out) :: AV 
    type(Status_type), intent(out), optional :: status  ! Exit status.

    ! Internal variables.

    type(Status_type), dimension(2) :: allocate_status ! Allocation Status.
    type(Status_type) :: consolidated_status           ! Consolidated Status.
    type(integer) :: Length_PE                         ! Length on this PE.

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

    ! Verify requirements.

    VERIFY(Valid_State(Structure),5)              ! Structure is valid.
    VERIFY(Dimensionality .InInterval. (/1,4/),5) ! Dimensionality is in range.
    VERIFY(PRESENT(dim1) .or. Dimensionality == 1,5) ! Proper dimensions exist.
    VERIFY(PRESENT(dim2) .or. Dimensionality <= 2,5) ! Proper dimensions exist.
    VERIFY(PRESENT(dim3) .or. Dimensionality <= 3,5) ! Proper dimensions exist.

    ! Set up structure pointer.

    AV%Structure => Structure

    ! Allocations and initializations.

    call Initialize (allocate_status)
    call Initialize (consolidated_status)

    Length_PE = Length_Total(Structure)
    if (this_is_not_IO_PE) Length_PE = 0

    call Initialize (AV%Dimensions, Dimensionality, allocate_status(1))
    AV%Dimensions(Dimensionality) = Length_PE

    select case (Dimensionality)
    case (1)
      call Initialize (AV%Values1, Length_PE, allocate_status(2))
    case (2)
      call Initialize (AV%Values2, dim1, Length_PE, allocate_status(2))
      AV%Dimensions(1) = dim1
    case (3)
      call Initialize (AV%Values3, dim1, dim2, Length_PE, allocate_status(2))
      AV%Dimensions(1) = dim1
      AV%Dimensions(2) = dim2
    case (4)
      call Initialize (AV%Values4, dim1, dim2, dim3, Length_PE, &
                       allocate_status(2))
      AV%Dimensions(1) = dim1
      AV%Dimensions(2) = dim2
      AV%Dimensions(3) = dim3
    !case (-1)
    !  call Initialize (AV%ValuesRR, Length_Total(Structure), &
    !                   allocate_status)
    !  AV%NValues_Total = F(Length_Total(Structure))
    end select
    AV%NValues_Total = PRODUCT(AV%Dimensions)

    consolidated_status = allocate_status
    if (PRESENT(status)) then
      WARN_IF(Error(consolidated_status), 5)
      status = consolidated_status
    else
      VERIFY(Normal(consolidated_status), 5)
    end if
    call Finalize (consolidated_status)
    call Finalize (allocate_status)

    ! Set up internals.

    if (PRESENT(Name)) AV%Name = Name
    AV%Dimensionality = Dimensionality
    AV%Version = 0

    ! Set initialization flag.

    AV%Initialized = initialized_flag

    ! Verify guarantees.

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

    return
  end subroutine Initialize_Assembled_Vector



Michael L. Hall