root / synthbench / euroben-dm / mod2b / idmax.f @ 0:839f52ef7657
History | View | Annotate | Download (1 kB)
1 |
Function idmax( n, sx, incx ) Result( iiamax ) |
---|---|
2 |
! ---------------------------------------------------------------------- |
3 |
Use numerics |
4 |
Implicit None |
5 |
|
6 |
Real(l_) :: sx(*), smax, xmag |
7 |
Integer :: i, ii, incx, n, ns, iiamax |
8 |
! ---------------------------------------------------------------------- |
9 |
iiamax = 0 |
10 |
If ( n <= 0 ) Return |
11 |
iiamax = 1 |
12 |
If ( n <= 1 ) Return |
13 |
If ( incx /= 1 ) Then |
14 |
smax = Abs( sx(1) ) |
15 |
ns = n*incx |
16 |
ii = 1 |
17 |
Do i=1,ns,incx |
18 |
xmag = Abs( sx(i) ) |
19 |
If ( xmag > smax ) Then |
20 |
iiamax = ii |
21 |
smax = xmag |
22 |
End If |
23 |
ii = ii + 1 |
24 |
End Do |
25 |
Return |
26 |
End If |
27 |
smax = Abs( sx(1) ) |
28 |
Do i = 2, n |
29 |
xmag = Abs( sx(i) ) |
30 |
If ( xmag > smax ) Then |
31 |
iiamax = i |
32 |
smax = xmag |
33 |
End If |
34 |
End Do |
35 |
! ---------------------------------------------------------------------- |
36 |
End Function idmax |