1 | MODULE lmdz_assert_eq |
---|
2 | |
---|
3 | IMPLICIT NONE; PRIVATE |
---|
4 | PUBLIC assert_eq |
---|
5 | |
---|
6 | INTERFACE assert_eq |
---|
7 | MODULE PROCEDURE assert_eq2, assert_eq3, assert_eq4, assert_eqn |
---|
8 | END INTERFACE |
---|
9 | |
---|
10 | CONTAINS |
---|
11 | |
---|
12 | FUNCTION assert_eq2(n1, n2, string) |
---|
13 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
14 | INTEGER, INTENT(IN) :: n1, n2 |
---|
15 | INTEGER assert_eq2 |
---|
16 | IF (n1 == n2) THEN |
---|
17 | assert_eq2 = n1 |
---|
18 | ELSE |
---|
19 | WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & |
---|
20 | string |
---|
21 | PRINT *, 'program terminated by assert_eq2' |
---|
22 | STOP 1 |
---|
23 | END IF |
---|
24 | END FUNCTION assert_eq2 |
---|
25 | !BL |
---|
26 | FUNCTION assert_eq3(n1, n2, n3, string) |
---|
27 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
28 | INTEGER, INTENT(IN) :: n1, n2, n3 |
---|
29 | INTEGER assert_eq3 |
---|
30 | IF (n1 == n2 .AND. n2 == n3) THEN |
---|
31 | assert_eq3 = n1 |
---|
32 | ELSE |
---|
33 | WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & |
---|
34 | string |
---|
35 | PRINT *, 'program terminated by assert_eq3' |
---|
36 | STOP 1 |
---|
37 | END IF |
---|
38 | END FUNCTION assert_eq3 |
---|
39 | !BL |
---|
40 | FUNCTION assert_eq4(n1, n2, n3, n4, string) |
---|
41 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
42 | INTEGER, INTENT(IN) :: n1, n2, n3, n4 |
---|
43 | INTEGER assert_eq4 |
---|
44 | IF (n1 == n2 .AND. n2 == n3 .AND. n3 == n4) THEN |
---|
45 | assert_eq4 = n1 |
---|
46 | ELSE |
---|
47 | WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & |
---|
48 | string, n1, n2, n3, n4 |
---|
49 | PRINT *, 'program terminated by assert_eq4' |
---|
50 | STOP 1 |
---|
51 | END IF |
---|
52 | END FUNCTION assert_eq4 |
---|
53 | !BL |
---|
54 | FUNCTION assert_eqn(nn, string) |
---|
55 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
56 | INTEGER, DIMENSION(:), INTENT(IN) :: nn |
---|
57 | INTEGER assert_eqn |
---|
58 | IF (all(nn(2:) == nn(1))) THEN |
---|
59 | assert_eqn = nn(1) |
---|
60 | ELSE |
---|
61 | WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & |
---|
62 | string |
---|
63 | PRINT *, 'program terminated by assert_eqn' |
---|
64 | STOP 1 |
---|
65 | END IF |
---|
66 | END FUNCTION assert_eqn |
---|
67 | |
---|
68 | END MODULE lmdz_assert_eq |
---|