[5113] | 1 | MODULE lmdz_assert_eq |
---|
[1157] | 2 | |
---|
[5119] | 3 | IMPLICIT NONE; PRIVATE |
---|
| 4 | PUBLIC assert_eq |
---|
[1157] | 5 | |
---|
| 6 | INTERFACE assert_eq |
---|
[5113] | 7 | MODULE PROCEDURE assert_eq2, assert_eq3, assert_eq4, assert_eqn |
---|
[1157] | 8 | END INTERFACE |
---|
| 9 | |
---|
| 10 | CONTAINS |
---|
| 11 | |
---|
[5113] | 12 | FUNCTION assert_eq2(n1, n2, string) |
---|
| 13 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
| 14 | INTEGER, INTENT(IN) :: n1, n2 |
---|
[1157] | 15 | INTEGER assert_eq2 |
---|
[5113] | 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 |
---|
[1157] | 24 | END FUNCTION assert_eq2 |
---|
| 25 | !BL |
---|
[5113] | 26 | FUNCTION assert_eq3(n1, n2, n3, string) |
---|
| 27 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
| 28 | INTEGER, INTENT(IN) :: n1, n2, n3 |
---|
[1157] | 29 | INTEGER assert_eq3 |
---|
[5117] | 30 | IF (n1 == n2 .AND. n2 == n3) THEN |
---|
[5113] | 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 |
---|
[1157] | 38 | END FUNCTION assert_eq3 |
---|
| 39 | !BL |
---|
[5113] | 40 | FUNCTION assert_eq4(n1, n2, n3, n4, string) |
---|
| 41 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
| 42 | INTEGER, INTENT(IN) :: n1, n2, n3, n4 |
---|
[1157] | 43 | INTEGER assert_eq4 |
---|
[5117] | 44 | IF (n1 == n2 .AND. n2 == n3 .AND. n3 == n4) THEN |
---|
[5113] | 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 |
---|
[1157] | 52 | END FUNCTION assert_eq4 |
---|
| 53 | !BL |
---|
[5113] | 54 | FUNCTION assert_eqn(nn, string) |
---|
| 55 | CHARACTER(LEN = *), INTENT(IN) :: string |
---|
[1157] | 56 | INTEGER, DIMENSION(:), INTENT(IN) :: nn |
---|
| 57 | INTEGER assert_eqn |
---|
[5113] | 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 |
---|
[1157] | 66 | END FUNCTION assert_eqn |
---|
| 67 | |
---|
[5113] | 68 | END MODULE lmdz_assert_eq |
---|