jdamax Function

private function jdamax(n, x, incx) result(iAmax)

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: n
real(kind=rp), intent(in) :: x(:)
integer(kind=ip), intent(in) :: incx

Return Value integer(kind=ip)


Called by

proc~~jdamax~~CalledByGraph proc~jdamax lusol::jdamax proc~lu1dcp lusol::lu1DCP proc~lu1dcp->proc~jdamax proc~lu1dpp lusol::lu1DPP proc~lu1dpp->proc~jdamax proc~lu1ful lusol::lu1ful proc~lu1ful->proc~lu1dcp proc~lu1ful->proc~lu1dpp proc~lu1fad lusol::lu1fad proc~lu1fad->proc~lu1ful proc~lu1fac lusol::lu1fac proc~lu1fac->proc~lu1fad proc~solve lusol_ez_module::solve proc~solve->proc~lu1fac proc~test_1 main::test_1 proc~test_1->proc~solve proc~test_2 main::test_2 proc~test_2->proc~solve program~main~2 main program~main~2->proc~test_1 program~main~2->proc~test_2

Source Code

  function jdamax( n, x, incx )  result(iAmax)

    integer(ip), intent(in)    :: n, incx
    real(rp),    intent(in)    :: x(:)
    integer(ip)                :: iAmax

    !===========================================================================
    ! jdamax does the same as idamax in most cases.
    ! jdamax > 0 if x contains normal values.
    ! jdamax = 0 if n = 0.
    ! jdamax < 0 means x(-jdamax) contains the first NaN or Inf.
    !
    ! 29 Jul 2003: First version of jdamax implemented for s5setx.
    ! 29 Jul 2003: Current version of jdamax
    ! 15 Mar 2008: First f90 version.
    !===========================================================================

    intrinsic           :: huge
    integer(ip)         :: i, ix, kmax
    real(rp)            :: dmax, xi
    real(rp), parameter :: realmax = huge(realmax)

    if (n < 1) then
       iAmax = 0
       return
    end if

    dmax  = zero
    ix    = 1
    kmax  = 1

    do  i = 1, n
       xi = abs( x(ix) )
       if (xi <= realmax) then  ! false if xi = Nan or Inf
          if (dmax < xi) then
             dmax   = xi
             kmax   = ix
          end if
       else
          go to 800
       end if
       ix = ix + incx
    end do

    iAmax = kmax
    return

800 iAmax = -ix

  end function jdamax