The main documentation of the Initialize_ELL_Matrix Procedure contains additional explanation of this code listing.
subroutine Initialize_ELL_Matrix (ELLM, Max_Nonzeros, Row_Structure, & Column_Structure, Name, status) ! Use association information. use Caesar_Flags_Module, only: initialized_flag use Caesar_Numbers_Module, only: zero ! Input variables. type(integer) :: Max_Nonzeros ! Maximum number of nonzero elements/row. ! Row and Column Base_Structures. type(Base_Structure_type), intent(in), target :: Row_Structure, & Column_Structure type(character,*), intent(in), optional :: Name ! Variable name. ! Output variables. ! ELL_Matrix to be initialized. type(ELL_Matrix_type), intent(out) :: ELLM type(Status_type), intent(out), optional :: status ! Exit status. ! Internal variables. type(Status_type), dimension(20) :: allocate_status ! Allocation Status. type(Status_type) :: consolidated_status ! Consolidated Status. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(.not.Valid_State(ELLM),5) ! ELL_Matrix is not valid. VERIFY(Valid_State(Row_Structure),5) ! Row Structure is valid. VERIFY(Valid_State(Column_Structure),5) ! Column Structure is valid. ! Max_Nonzeros is reasonable. VERIFY(Max_Nonzeros .InInterval. (/1,Length_Total(Column_Structure)/),5) ! Set up structure pointers. ELLM%Row_Structure => Row_Structure ELLM%Column_Structure => Column_Structure ! Allocations and initializations. call Initialize (allocate_status) call Initialize (consolidated_status) call Initialize (ELLM%Values, Length_PE(Row_Structure), Max_Nonzeros, & allocate_status(1)) call Initialize (ELLM%Columns, Length_PE(Row_Structure), Max_Nonzeros, & allocate_status(2)) call Initialize (ELLM%Index, ELLM%Column_Structure, & ELLM%Row_Structure, Many_of_One_Array=ELLM%Columns, & status=allocate_status(3)) ! Set up internals. if (PRESENT(Name)) ELLM%Name = Name ELLM%Max_Nonzeros = Max_Nonzeros call Initialize (ELLM%Average, allocate_status( 4)) call Initialize (ELLM%Average_is_Updated, allocate_status( 5)) call Initialize (ELLM%Frobenius_Norm, allocate_status( 6)) call Initialize (ELLM%Frobenius_Norm_is_Updated, allocate_status( 7)) call Initialize (ELLM%Index_is_Updated, allocate_status( 8)) call Initialize (ELLM%Infinity_Norm, allocate_status( 9)) call Initialize (ELLM%Infinity_Norm_is_Updated, allocate_status(10)) call Initialize (ELLM%Maximum, allocate_status(11)) call Initialize (ELLM%Maximum_is_Updated, allocate_status(12)) call Initialize (ELLM%Minimum, allocate_status(13)) call Initialize (ELLM%Minimum_is_Updated, allocate_status(14)) call Initialize (ELLM%One_Norm, allocate_status(15)) call Initialize (ELLM%One_Norm_is_Updated, allocate_status(16)) call Initialize (ELLM%Sum, allocate_status(17)) call Initialize (ELLM%Sum_is_Updated, allocate_status(18)) call Initialize (ELLM%Two_Norm_Estimate, allocate_status(19)) call Initialize (ELLM%Two_Norm_is_Updated, allocate_status(20)) ! Make sure that initial values are correct. ELLM%Average = zero ELLM%Average_is_Updated = .false. ELLM%Frobenius_Norm = zero ELLM%Frobenius_Norm_is_Updated = .false. ELLM%Index_is_Updated = .false. ELLM%Infinity_Norm = zero ELLM%Infinity_Norm_is_Updated = .false. ELLM%Maximum = zero ELLM%Maximum_is_Updated = .false. ELLM%Minimum = zero ELLM%Minimum_is_Updated = .false. ELLM%One_Norm = zero ELLM%One_Norm_is_Updated = .false. ELLM%Sum = zero ELLM%Sum_is_Updated = .false. ELLM%Two_Norm_Estimate = zero ELLM%Two_Norm_Range = (/ zero, zero /) ELLM%Two_Norm_is_Updated = .false. ! Process status variables. consolidated_status = allocate_status if (PRESENT(status)) then WARN_IF(Error(consolidated_status), 5) status = consolidated_status else VERIFY(Normal(consolidated_status), 5) end if call Finalize (consolidated_status) call Finalize (allocate_status) ! Set initialization flag. ELLM%Initialized = initialized_flag ! Verify guarantees. VERIFY(Valid_State(ELLM),5) ! ELL_Matrix is now valid. return end subroutine Initialize_ELL_Matrix