IFNAN(X)
This logical function checks if the argument X is NaN (not a number).
Function Return Value
IFNAN - Logical function value. True is returned if the input argument is a NAN. Otherwise, False is returned. (Output)
Required Arguments
X – Argument for which the test for NAN is desired. (Input)
FORTRAN 90 Interface
Generic: IFNAN(X)
Specific: The specific interface names are S_IFNAN and D_IFNAN.
FORTRAN 77 Interface
Single: IFNAN (X)
Double: The double precision name is DIFNAN.
Description
The logical function IFNAN checks if the single or double precision argument X is NAN (not a number). The function IFNAN is provided to facilitate the transfer of programs across computer systems. This is because the check for NaN can be tricky and not portable across computer systems that do not adhere to the IEEE standard. For example, on computers that support the IEEE standard for binary arithmetic (see IEEE 1985), NaN is specified as a bit format not equal to itself. Thus, the check is performed as
IFNAN = X .NE. X
On other computers that do not use IEEE floating‑point format, the check can be performed as:
IFNAN = X .EQ. AMACH(6)
The function IFNAN is equivalent to the specification of the function Isnan listed in the Appendix, (IEEE 1985). The above example illustrates the use of IFNAN. If X is NaN, a message is printed instead of X. (Routine UMACH, which is described in the following section, is used to retrieve the output unit number for printing the message.)
Example
 
USE IFNAN_INT
USE AMACH_INT
USE UMACH_INT
INTEGER NOUT
REAL X
!
CALL UMACH (2, NOUT)
!
X = AMACH(6)
IF (IFNAN(X)) THEN
WRITE (NOUT,*) ’ X is NaN (not a number).’
ELSE
WRITE (NOUT,*) ’ X = ’, X
END IF
!
END
Output
 
X is NaN (not a number).