The main documentation of the Valid_State_Overlapped_Vector Procedure contains additional explanation of this code listing.
function Valid_State_Overlapped_Vector (OV) result(Valid) ! Input variables. ! Variable to be checked. type(Overlapped_Vector_type), intent(in) :: OV ! Output variables. type(logical) :: Valid ! Logical state. ! Internal variables. type(integer) :: NSlice ! Number of Values in a "slice" of the OV. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Start out true. Valid = .true. ! Check for association of pointered internals. Valid = Valid .and. ASSOCIATED(OV%One_Structure) Valid = Valid .and. ASSOCIATED(OV%Many_Structure) Valid = Valid .and. ASSOCIATED(OV%Dimensions) Valid = Valid .and. ASSOCIATED(OV%DV) Valid = Valid .and. ASSOCIATED(OV%Many_of_One_Index) Valid = Valid .and. ASSOCIATED(OV%Overlap_Index) Valid = Valid .and. ASSOCIATED(OV%Overlap_Trace) if (.not.Valid) return ! Check for validity of internals. Valid = Valid .and. Initialized(OV) Valid = Valid .and. Valid_State(OV%Dimensionality) Valid = Valid .and. Valid_State(OV%Dimensions) Valid = Valid .and. Valid_State(OV%DV) Valid = Valid .and. Valid_State(OV%Many_Structure) Valid = Valid .and. Valid_State(OV%Many_of_One_Index) Valid = Valid .and. Valid_State(OV%Name) Valid = Valid .and. Valid_State(OV%One_Structure) Valid = Valid .and. Valid_State(OV%Overlap_Index) Valid = Valid .and. Valid_State(OV%Overlap_Trace) select case (OV%Dimensionality) case (1) Valid = Valid .and. Valid_State(OV%Overlap_Values1) case (2) Valid = Valid .and. Valid_State(OV%Overlap_Values2) case (3) Valid = Valid .and. Valid_State(OV%Overlap_Values3) case (4) Valid = Valid .and. Valid_State(OV%Overlap_Values4) !case (-1) ! Valid = Valid .and. Valid_State(OV%Overlap_ValuesRR) end select Valid = Valid .and. Valid_State(OV%Version) if (.not.Valid) return ! Checks on the validity of OV. NSlice = PRODUCT(OV%DV%Dimensions(1:OV%Dimensionality-1)) select case (OV%Dimensionality) case (1) Valid = Valid .and. & OV%Many_of_One_Index%NOff_PE * NSlice == SIZE(OV%Overlap_Values1) case (2) Valid = Valid .and. & OV%Many_of_One_Index%NOff_PE * NSlice == SIZE(OV%Overlap_Values2) case (3) Valid = Valid .and. & OV%Many_of_One_Index%NOff_PE * NSlice == SIZE(OV%Overlap_Values3) case (4) Valid = Valid .and. & OV%Many_of_One_Index%NOff_PE * NSlice == SIZE(OV%Overlap_Values4) !case (-1) ! Valid = Valid .and. OV%NValues_PE == SIZE(OV%Overlap_ValuesRR) end select return end function Valid_State_Overlapped_Vector