D.8.3 Valid_State_Collected_Array Procedure

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

  function Valid_State_Collected_Array (CA) result(Valid)

    ! Input variables.

    ! Variable to be checked.
    type(Collected_Array_type), intent(in) :: CA 

    ! Output variables.

    type(logical) :: Valid       ! Logical state.

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

    ! Start out true.

    Valid = .true.

    ! Check for association of pointered internals.

    Valid = Valid .and. ASSOCIATED(CA%One_Structure)
    Valid = Valid .and. ASSOCIATED(CA%Many_Structure)
    Valid = Valid .and. ASSOCIATED(CA%Dimensions)
    Valid = Valid .and. ASSOCIATED(CA%Many_of_One_Index)
    if (.not.Valid) return

    ! Check for validity of internals.

    Valid = Valid .and. Initialized(CA)
    Valid = Valid .and. Valid_State(CA%A_Dimensionality)
    Valid = Valid .and. Valid_State(CA%Dimensionality)
    Valid = Valid .and. Valid_State(CA%Dimensions)
    Valid = Valid .and. Valid_State(CA%Many_Structure)
    Valid = Valid .and. Valid_State(CA%Many_of_One_Index)
    Valid = Valid .and. Valid_State(CA%Name)
    Valid = Valid .and. Valid_State(CA%One_Structure)
    select case (CA%A_Dimensionality)
    case (1)
      Valid = Valid .and. Valid_State(CA%Values1)
    case (2)
      Valid = Valid .and. Valid_State(CA%Values2)
    case (3)
      Valid = Valid .and. Valid_State(CA%Values3)
    case (4)
      Valid = Valid .and. Valid_State(CA%Values4)
    case (5)
      Valid = Valid .and. Valid_State(CA%Values5)
    !case (-1)
    !  Valid = Valid .and. Valid_State(CA%ValuesRR)
    end select
    Valid = Valid .and. Valid_State(CA%Version)
    if (.not.Valid) return

    ! Checks on the validity of CA.

    Valid = Valid .and. CA%A_Dimensionality == &
            CA%Dimensionality + CA%Many_of_One_Index%Dimensionality - 1
    select case (CA%A_Dimensionality)
    case (1)
      Valid = Valid .and. ALL(CA%Dimensions(1:1) == SHAPE(CA%Values1))
    case (2)
      Valid = Valid .and. ALL(CA%Dimensions(1:2) == SHAPE(CA%Values2))
    case (3)
      Valid = Valid .and. ALL(CA%Dimensions(1:3) == SHAPE(CA%Values3))
    case (4)
      Valid = Valid .and. ALL(CA%Dimensions(1:4) == SHAPE(CA%Values4))
    case (5)
      Valid = Valid .and. ALL(CA%Dimensions(1:5) == SHAPE(CA%Values5))
    !case (-1)
    !  Valid = Valid .and. ALL(CA%Dimensions(1:2) == SHAPE(CA%ValuesRR))
    end select

    return
  end function Valid_State_Collected_Array



Michael L. Hall