G.1.2 Duplicate_Mathematic_Vector Procedure

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

  subroutine Duplicate_Mathematic_Vector (MV_duplicate, MV_source, status)

    ! Input variables.

    type(Mathematic_Vector_type), intent(in) :: MV_source

    ! Output variables.

    ! Mathematic_Vector to be initialized.
    type(Mathematic_Vector_type), intent(out) :: MV_duplicate 
    type(Status_type), intent(out), optional :: status  ! Exit status.

    ! Internal variables.

    type(Status_type) :: A_status  ! Actual status.

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

    ! Verify requirements.

    VERIFY(Valid_State(MV_source),5)         ! MV_source is valid.

    ! Allocate MV_duplicate to be like MV_source.

    call Initialize (A_status)
    call Initialize (MV_duplicate, MV_source%Structure, MV_source%Name, &
                     A_status)

    ! Process status variable.

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

    ! Copy internals from source mathematical vector.

    MV_duplicate%Average                  = MV_source%Average
    MV_duplicate%Average_is_Updated       = MV_source%Average_is_Updated
    MV_duplicate%Infinity_Norm            = MV_source%Infinity_Norm
    MV_duplicate%Infinity_Norm_is_Updated = MV_source%Infinity_Norm_is_Updated
    MV_duplicate%Maximum                  = MV_source%Maximum
    MV_duplicate%Maximum_is_Updated       = MV_source%Maximum_is_Updated
    MV_duplicate%Minimum                  = MV_source%Minimum
    MV_duplicate%Minimum_is_Updated       = MV_source%Minimum_is_Updated
    MV_duplicate%One_Norm                 = MV_source%One_Norm
    MV_duplicate%One_Norm_is_Updated      = MV_source%One_Norm_is_Updated
    MV_duplicate%P_Norm                   = MV_source%P_Norm
    MV_duplicate%P_Norm_Exponent          = MV_source%P_Norm_Exponent
    MV_duplicate%P_Norm_is_Updated        = MV_source%P_Norm_is_Updated
    MV_duplicate%Sum                      = MV_source%Sum
    MV_duplicate%Sum_is_Updated           = MV_source%Sum_is_Updated
    MV_duplicate%Two_Norm                 = MV_source%Two_Norm
    MV_duplicate%Two_Norm_is_Updated      = MV_source%Two_Norm_is_Updated 
    MV_duplicate%Values                   = MV_source%Values

    ! Verify guarantees.

    VERIFY(Valid_State(MV_duplicate),5)     ! Mathematic_Vector is now valid.

    return
  end subroutine Duplicate_Mathematic_Vector



Michael L. Hall