G.2.13 Set_0_Diagonal_to_1_ELL_Matrix Procedure

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

  subroutine Set_0_Diagonal_to_1_ELL_Matrix (ELLM)

    ! Use association information.

    use Caesar_Numbers_Module, only: zero, one

    ! Input variables - none.

    ! Input/Output variable.
    
    type(ELL_Matrix_type), intent(inout) :: ELLM ! Variable to be set.

    ! Internal variables.

    type(integer) :: Row      ! Row number.
    type(integer) :: shift    ! Index shift.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
    ! Verify requirements.
  
    VERIFY(Valid_State(ELLM),5)                          ! ELLM is valid.

    ! Set the diagonal to unity if the equation is missing (row is all zero).

    shift = -First_PE(ELLM%Row_Structure) + 1
    do Row = 1, Length_PE(ELLM%Row_Structure)

      if (ALL(ELLM%Values(Row,:) == zero) .AND. &
          ALL(ELLM%Columns(Row,:) == 0)) then
        ELLM%Values(Row,1) = one
        ELLM%Columns(Row,1) = Row - shift   ! Must convert column number
      end if                                ! from local to global.

    end do

    ! Unset the updated? variables.

    call Set_Not_Up_to_Date (ELLM)

    ! Verify guarantees.

    VERIFY(Valid_State(ELLM),5)                          ! ELLM is still valid.

    return
  end subroutine Set_0_Diagonal_to_1_ELL_Matrix



Michael L. Hall