Skip to content

Commit c2e413b

Browse files
authored
Use F2003 ieee_arithmetic module instead of live division-by-zero (Reference-LAPACK PR 1168)
1 parent 31e82fa commit c2e413b

1 file changed

Lines changed: 7 additions & 88 deletions

File tree

‎lapack-netlib/SRC/ieeeck.f‎

Lines changed: 7 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
* Online html documentation available at
66
* http://www.netlib.org/lapack/explore-html/
77
*
8-
*> \htmlonly
98
*> Download IEEECK + dependencies
109
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ieeeck.f">
1110
*> [TGZ]</a>
1211
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ieeeck.f">
1312
*> [ZIP]</a>
1413
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ieeeck.f">
1514
*> [TXT]</a>
16-
*> \endhtmlonly
1715
*
1816
* Definition:
1917
* ===========
@@ -75,10 +73,14 @@
7573
*> \author Univ. of Colorado Denver
7674
*> \author NAG Ltd.
7775
*
78-
*> \ingroup OTHERauxiliary
76+
*> \ingroup ieeeck
7977
*
8078
* =====================================================================
8179
INTEGER FUNCTION IEEECK( ISPEC, ZERO, ONE )
80+
USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY:
81+
& IEEE_SUPPORT_INF,
82+
& IEEE_SUPPORT_NAN
83+
IMPLICIT NONE
8284
*
8385
* -- LAPACK auxiliary routine --
8486
* -- LAPACK is a software package provided by Univ. of Tennessee, --
@@ -91,57 +93,11 @@ INTEGER FUNCTION IEEECK( ISPEC, ZERO, ONE )
9193
*
9294
* =====================================================================
9395
*
94-
* .. Local Scalars ..
95-
REAL NAN1, NAN2, NAN3, NAN4, NAN5, NAN6, NEGINF,
96-
$ NEGZRO, NEWZRO, POSINF
9796
* ..
9897
* .. Executable Statements ..
9998
IEEECK = 1
10099
*
101-
POSINF = ONE / ZERO
102-
IF( POSINF.LE.ONE ) THEN
103-
IEEECK = 0
104-
RETURN
105-
END IF
106-
*
107-
NEGINF = -ONE / ZERO
108-
IF( NEGINF.GE.ZERO ) THEN
109-
IEEECK = 0
110-
RETURN
111-
END IF
112-
*
113-
NEGZRO = ONE / ( NEGINF+ONE )
114-
IF( NEGZRO.NE.ZERO ) THEN
115-
IEEECK = 0
116-
RETURN
117-
END IF
118-
*
119-
NEGINF = ONE / NEGZRO
120-
IF( NEGINF.GE.ZERO ) THEN
121-
IEEECK = 0
122-
RETURN
123-
END IF
124-
*
125-
NEWZRO = NEGZRO + ZERO
126-
IF( NEWZRO.NE.ZERO ) THEN
127-
IEEECK = 0
128-
RETURN
129-
END IF
130-
*
131-
POSINF = ONE / NEWZRO
132-
IF( POSINF.LE.ONE ) THEN
133-
IEEECK = 0
134-
RETURN
135-
END IF
136-
*
137-
NEGINF = NEGINF*POSINF
138-
IF( NEGINF.GE.ZERO ) THEN
139-
IEEECK = 0
140-
RETURN
141-
END IF
142-
*
143-
POSINF = POSINF*POSINF
144-
IF( POSINF.LE.ONE ) THEN
100+
IF ( .NOT.IEEE_SUPPORT_INF(ONE) ) THEN
145101
IEEECK = 0
146102
RETURN
147103
END IF
@@ -154,44 +110,7 @@ INTEGER FUNCTION IEEECK( ISPEC, ZERO, ONE )
154110
IF( ISPEC.EQ.0 )
155111
$ RETURN
156112
*
157-
NAN1 = POSINF + NEGINF
158-
*
159-
NAN2 = POSINF / NEGINF
160-
*
161-
NAN3 = POSINF / POSINF
162-
*
163-
NAN4 = POSINF*ZERO
164-
*
165-
NAN5 = NEGINF*NEGZRO
166-
*
167-
NAN6 = NAN5*ZERO
168-
*
169-
IF( NAN1.EQ.NAN1 ) THEN
170-
IEEECK = 0
171-
RETURN
172-
END IF
173-
*
174-
IF( NAN2.EQ.NAN2 ) THEN
175-
IEEECK = 0
176-
RETURN
177-
END IF
178-
*
179-
IF( NAN3.EQ.NAN3 ) THEN
180-
IEEECK = 0
181-
RETURN
182-
END IF
183-
*
184-
IF( NAN4.EQ.NAN4 ) THEN
185-
IEEECK = 0
186-
RETURN
187-
END IF
188-
*
189-
IF( NAN5.EQ.NAN5 ) THEN
190-
IEEECK = 0
191-
RETURN
192-
END IF
193-
*
194-
IF( NAN6.EQ.NAN6 ) THEN
113+
IF( .NOT.IEEE_SUPPORT_NAN(ONE) ) THEN
195114
IEEECK = 0
196115
RETURN
197116
END IF

0 commit comments

Comments
 (0)