MODULE lmdz_assert_eq IMPLICIT NONE INTERFACE assert_eq MODULE PROCEDURE assert_eq2, assert_eq3, assert_eq4, assert_eqn END INTERFACE PRIVATE assert_eq2, assert_eq3, assert_eq4, assert_eqn CONTAINS FUNCTION assert_eq2(n1, n2, string) CHARACTER(LEN = *), INTENT(IN) :: string INTEGER, INTENT(IN) :: n1, n2 INTEGER assert_eq2 IF (n1 == n2) THEN assert_eq2 = n1 ELSE WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & string PRINT *, 'program terminated by assert_eq2' STOP 1 END IF END FUNCTION assert_eq2 !BL FUNCTION assert_eq3(n1, n2, n3, string) CHARACTER(LEN = *), INTENT(IN) :: string INTEGER, INTENT(IN) :: n1, n2, n3 INTEGER assert_eq3 IF (n1 == n2 .AND. n2 == n3) THEN assert_eq3 = n1 ELSE WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & string PRINT *, 'program terminated by assert_eq3' STOP 1 END IF END FUNCTION assert_eq3 !BL FUNCTION assert_eq4(n1, n2, n3, n4, string) CHARACTER(LEN = *), INTENT(IN) :: string INTEGER, INTENT(IN) :: n1, n2, n3, n4 INTEGER assert_eq4 IF (n1 == n2 .AND. n2 == n3 .AND. n3 == n4) THEN assert_eq4 = n1 ELSE WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & string, n1, n2, n3, n4 PRINT *, 'program terminated by assert_eq4' STOP 1 END IF END FUNCTION assert_eq4 !BL FUNCTION assert_eqn(nn, string) CHARACTER(LEN = *), INTENT(IN) :: string INTEGER, DIMENSION(:), INTENT(IN) :: nn INTEGER assert_eqn IF (all(nn(2:) == nn(1))) THEN assert_eqn = nn(1) ELSE WRITE (*, *) 'nrerror: an assert_eq failed with this tag: ', & string PRINT *, 'program terminated by assert_eqn' STOP 1 END IF END FUNCTION assert_eqn END MODULE lmdz_assert_eq