D.6.3 Valid_State_Distributed_Vector Procedure

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

  function Valid_State_Distributed_Vector (DV) result(Valid)

    ! Input variables.

    ! Variable to be checked.
    type(Distributed_Vector_type), intent(in) :: DV 

    ! Output variables.

    type(logical) :: Valid       ! Logical state.

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

    ! Start out true.

    Valid = .true.

    ! Check for association of pointered internals.

    Valid = Valid .and. ASSOCIATED(DV%Structure)
    Valid = Valid .and. ASSOCIATED(DV%Dimensions)
    if (.not.Valid) return

    ! Check for validity of internals.

    Valid = Valid .and. Initialized(DV)
    Valid = Valid .and. Valid_State(DV%Dimensionality)
    Valid = Valid .and. Valid_State(DV%Dimensions)
    Valid = Valid .and. Valid_State(DV%NValues_PE)
    Valid = Valid .and. Valid_State(DV%NValues_Total)
    Valid = Valid .and. Valid_State(DV%NValues_Vector)
    Valid = Valid .and. Valid_State(DV%Name)
    Valid = Valid .and. Valid_State(DV%Structure)
    select case (DV%Dimensionality)
    case (1)
      Valid = Valid .and. Valid_State(DV%Values1)
    case (2)
      Valid = Valid .and. Valid_State(DV%Values2)
    case (3)
      Valid = Valid .and. Valid_State(DV%Values3)
    case (4)
      Valid = Valid .and. Valid_State(DV%Values4)
    !case (-1)
    !  Valid = Valid .and. Valid_State(DV%ValuesRR)
    end select
    Valid = Valid .and. Valid_State(DV%Version)
    if (.not.Valid) return

    ! Checks on the validity of DV.

    select case (DV%Dimensionality)
    case (1)
      Valid = Valid .and. DV%NValues_PE == SIZE(DV%Values1)
      Valid = Valid .and. ALL(DV%Dimensions(1:1) == SHAPE(DV%Values1))
    case (2)                         
      Valid = Valid .and. DV%NValues_PE == SIZE(DV%Values2)
      Valid = Valid .and. ALL(DV%Dimensions(1:2) == SHAPE(DV%Values2))
    case (3)                         
      Valid = Valid .and. DV%NValues_PE == SIZE(DV%Values3)
      Valid = Valid .and. ALL(DV%Dimensions(1:3) == SHAPE(DV%Values3))
    case (4)                         
      Valid = Valid .and. DV%NValues_PE == SIZE(DV%Values4)
      Valid = Valid .and. ALL(DV%Dimensions(1:4) == SHAPE(DV%Values4))
    !case (-1)
    !  Valid = Valid .and. DV%NValues_PE == SIZE(DV%ValuesRR)
    end select

    Valid = Valid .and. DV%NValues_PE == DV%NValues_Vector(this_PE)

    return
  end function Valid_State_Distributed_Vector



Michael L. Hall