The main documentation of the Valid_State_ELL_Matrix Procedure contains additional explanation of this code listing.
function Valid_State_ELL_Matrix (ELLM) result(Valid) ! Use association information. use Caesar_Numbers_Module, only: zero ! Input variables. ! Variable to be checked. type(ELL_Matrix_type), intent(in) :: ELLM ! Output variables. type(logical) :: Valid ! Logical state. ! Internal variables. type(real) :: N, M ! Dimensions of the ELLM. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Start out true. Valid = .true. ! Check for association of pointered internals. Valid = Valid .and. ASSOCIATED(ELLM%Row_Structure) Valid = Valid .and. ASSOCIATED(ELLM%Column_Structure) if (.not.Valid) return ! Check for validity of internals. Valid = Valid .and. Initialized(ELLM) Valid = Valid .and. Valid_State(ELLM%Average) Valid = Valid .and. Valid_State(ELLM%Average_is_Updated) Valid = Valid .and. Valid_State(ELLM%Column_Structure) Valid = Valid .and. Valid_State(ELLM%Frobenius_Norm) Valid = Valid .and. Valid_State(ELLM%Frobenius_Norm_is_Updated) Valid = Valid .and. Valid_State(ELLM%Infinity_Norm) Valid = Valid .and. Valid_State(ELLM%Infinity_Norm_is_Updated) Valid = Valid .and. Valid_State(ELLM%Max_Nonzeros) Valid = Valid .and. Valid_State(ELLM%Maximum) Valid = Valid .and. Valid_State(ELLM%Maximum_is_Updated) Valid = Valid .and. Valid_State(ELLM%Minimum) Valid = Valid .and. Valid_State(ELLM%Minimum_is_Updated) Valid = Valid .and. Valid_State(ELLM%Name) Valid = Valid .and. Valid_State(ELLM%One_Norm) Valid = Valid .and. Valid_State(ELLM%One_Norm_is_Updated) Valid = Valid .and. Valid_State(ELLM%Row_Structure) Valid = Valid .and. Valid_State(ELLM%Sum) Valid = Valid .and. Valid_State(ELLM%Sum_is_Updated) Valid = Valid .and. Valid_State(ELLM%Two_Norm_Estimate) Valid = Valid .and. Valid_State(ELLM%Two_Norm_is_Updated) if (.not.Valid) return ! Checks on the validity of ELL_Matrix. N = changetype(real, Length_Total(ELLM%Row_Structure)) M = changetype(real, Length_Total(ELLM%Column_Structure)) Valid = Valid .and. ALL(ELLM%Columns >= 0) Valid = Valid .and. ELLM%Infinity_Norm >= zero Valid = Valid .and. ELLM%One_Norm >= zero Valid = Valid .and. ELLM%Frobenius_Norm >= zero Valid = Valid .and. ELLM%Two_Norm_Estimate >= zero if (ELLM%Two_Norm_is_Updated) then Valid = Valid .and. & (ELLM%Two_Norm_Estimate .InInterval. ELLM%Two_Norm_Range) end if if (ELLM%Average_is_updated .and. ELLM%Sum_is_updated) then Valid = Valid .and. & (ELLM%Average .VeryClose. ELLM%Sum/changetype(real,(N*M))) end if if (ELLM%Maximum_is_updated .and. ELLM%Minimum_is_updated) then Valid = Valid .and. ELLM%Maximum >= ELLM%Minimum end if if (.not.Valid) return ! Mathematic relationship checks. !if (ELLM%One_Norm_is_updated .and. ELLM%Two_Norm_is_updated) then ! Valid = Valid .and. ELLM%One_Norm >= ELLM%Two_Norm ! Valid = Valid .and. ELLM%Two_Norm * SQRT(N) >= ELLM%One_Norm !end if !if (ELLM%Infinity_Norm_is_updated .and. ELLM%Two_Norm_is_updated) then ! Valid = Valid .and. ELLM%Two_Norm >= ELLM%Infinity_Norm ! Valid = Valid .and. ELLM%Infinity_Norm * SQRT(N) >= ELLM%Two_Norm !end if !if (ELLM%Infinity_Norm_is_updated .and. ELLM%One_Norm_is_updated) then ! Valid = Valid .and. ELLM%One_Norm >= ELLM%Infinity_Norm ! Valid = Valid .and. ELLM%Infinity_Norm * N >= ELLM%One_Norm !end if return end function Valid_State_ELL_Matrix