Last change
on this file since 5229 was
5159,
checked in by abarral, 4 months ago
|
Put dimensions.h and paramet.h into modules
|
File size:
1.0 KB
|
Line | |
---|
1 | ! Library for misc. useful math functions |
---|
2 | |
---|
3 | MODULE lmdz_libmath |
---|
4 | IMPLICIT NONE; PRIVATE |
---|
5 | PUBLIC ismin, ismax, minmax |
---|
6 | |
---|
7 | CONTAINS |
---|
8 | |
---|
9 | function ismax(n, sx, incx) |
---|
10 | INTEGER :: n, i, incx, ismax, ix |
---|
11 | REAL :: sx((n - 1) * incx + 1), sxmax |
---|
12 | |
---|
13 | ix = 1 |
---|
14 | ismax = 1 |
---|
15 | sxmax = sx(1) |
---|
16 | DO i = 1, n - 1 |
---|
17 | ix = ix + incx |
---|
18 | IF(sx(ix)>sxmax) THEN |
---|
19 | sxmax = sx(ix) |
---|
20 | ismax = i + 1 |
---|
21 | endif |
---|
22 | END DO |
---|
23 | END FUNCTION ismax |
---|
24 | |
---|
25 | |
---|
26 | FUNCTION ismin(n, sx, incx) |
---|
27 | INTEGER :: n, i, incx, ismin, ix |
---|
28 | REAL :: sx((n - 1) * incx + 1), sxmin |
---|
29 | |
---|
30 | ix = 1 |
---|
31 | ismin = 1 |
---|
32 | sxmin = sx(1) |
---|
33 | DO i = 1, n - 1 |
---|
34 | ix = ix + incx |
---|
35 | IF(sx(ix)<sxmin) THEN |
---|
36 | sxmin = sx(ix) |
---|
37 | ismin = i + 1 |
---|
38 | endif |
---|
39 | ENDDO |
---|
40 | END FUNCTION ismin |
---|
41 | |
---|
42 | SUBROUTINE minmax(imax, xi, zmin, zmax) |
---|
43 | |
---|
44 | ! P. Le Van |
---|
45 | |
---|
46 | INTEGER :: imax |
---|
47 | REAL :: xi(imax) |
---|
48 | REAL :: zmin, zmax |
---|
49 | INTEGER :: i |
---|
50 | |
---|
51 | zmin = xi(1) |
---|
52 | zmax = xi(1) |
---|
53 | |
---|
54 | DO i = 2, imax |
---|
55 | zmin = MIN(zmin, xi(i)) |
---|
56 | zmax = MAX(zmax, xi(i)) |
---|
57 | ENDDO |
---|
58 | |
---|
59 | END SUBROUTINE minmax |
---|
60 | |
---|
61 | END MODULE lmdz_libmath |
---|
Note: See
TracBrowser
for help on using the repository browser.