1 | MODULE error_mod |
---|
2 | #include "use_logging.h" |
---|
3 | |
---|
4 | #ifndef XCODEML |
---|
5 | USE, INTRINSIC :: IEEE_ARITHMETIC |
---|
6 | #endif |
---|
7 | |
---|
8 | IMPLICIT NONE |
---|
9 | PRIVATE |
---|
10 | |
---|
11 | INTERFACE check_NaN |
---|
12 | MODULE PROCEDURE check_NaN1, check_NaN2 |
---|
13 | END INTERFACE check_NaN |
---|
14 | |
---|
15 | PUBLIC :: check_NaN |
---|
16 | |
---|
17 | CONTAINS |
---|
18 | |
---|
19 | |
---|
20 | SUBROUTINE check_NaN1(caller, name, data) |
---|
21 | CHARACTER(*), INTENT(IN) :: caller, name |
---|
22 | REAL, INTENT(IN) :: data(:) |
---|
23 | LOGICAL :: isnan(SIZE(data,1)) |
---|
24 | INTEGER :: i |
---|
25 | #ifdef XCODEML |
---|
26 | isnan = IEEE_IS_NAN(data) |
---|
27 | #endif |
---|
28 | IF(ANY(isnan)) THEN |
---|
29 | WRITELOG(*,*) 'In subroutine ', caller, ' array ', name, ' has NaN . Offending indices :' |
---|
30 | DO i=1, SIZE(isnan,1) |
---|
31 | IF(isnan(i)) THEN |
---|
32 | WRITELOG(*,*) i |
---|
33 | END IF |
---|
34 | END DO |
---|
35 | LOG_DBG('check_NaN') |
---|
36 | END IF |
---|
37 | END SUBROUTINE check_NaN1 |
---|
38 | |
---|
39 | SUBROUTINE check_NaN2(caller, name, data) |
---|
40 | CHARACTER(*), INTENT(IN) :: caller, name |
---|
41 | REAL, INTENT(IN) :: data(:,:) |
---|
42 | LOGICAL :: isnan(SIZE(data,1), SIZE(data,2)) |
---|
43 | INTEGER :: i,j |
---|
44 | #ifdef XCODEML |
---|
45 | isnan = IEEE_IS_NAN(data) |
---|
46 | #endif |
---|
47 | IF(ANY(isnan)) THEN |
---|
48 | WRITELOG(*,*) 'In subroutine ', caller, ' array ', name, ' has NaN . Offending indices :' |
---|
49 | DO i=1, SIZE(isnan,1) |
---|
50 | DO j=1, SIZE(isnan,2) |
---|
51 | IF(isnan(i,j)) THEN |
---|
52 | WRITELOG(*,*) i,j |
---|
53 | END IF |
---|
54 | END DO |
---|
55 | END DO |
---|
56 | LOG_DBG('check_NaN') |
---|
57 | END IF |
---|
58 | END SUBROUTINE check_NaN2 |
---|
59 | |
---|
60 | END MODULE error_mod |
---|