ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_except::setNAN Interface Reference

Return an IEEE-compliant quiet NAN (Not a Number).
More...

Detailed Description

Return an IEEE-compliant quiet NAN (Not a Number).

This procedure is useful for deliberate initializations of real or complex numbers to NaN without signaling the occurrence of an exception.

Parameters
[out]nan: The output scalar or array of arbitrary rank of either
  1. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128), or
  2. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
which will contain a NaN.


Possible calling interfaces

use pm_except, only: setNAN
call setNAN(nan)
Return an IEEE-compliant quiet NAN (Not a Number).
Definition: pm_except.F90:2593
This module contains procedures and generic interfaces for testing for exceptional cases at runtime.
Definition: pm_except.F90:46
Warning
Keep in mind that NaN might not even be defined for non-IEEE-compliant compilers or when certain aggressive IEEE-breaking optimization flags are specified like -O3 -ffast-math with GNU gfortran or -fast with Intel ifort compilers.
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
See also
isInf
isNAN
getNAN
setNAN
isInfPos
isInfNeg
getInfPos
setInfPos
getInfNeg
setInfNeg


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_kind, only: RKS, RKD, RKH ! all processor types and kinds are supported.
5 use pm_kind, only: CKS, CKD, CKH ! all processor types and kinds are supported.
6 use pm_io, only: display_type
7 use pm_except, only: setNAN
8
9 implicit none
10
11 real(RKH) :: X_RKH(3)
12 real(RKD) :: X_RKD(3)
13 real(RKS) :: X_RKS(3)
14 complex(CKH) :: X_CKH(3)
15 complex(CKD) :: X_CKD(3)
16 complex(CKS) :: X_CKS(3)
17
18 type(display_type) :: disp
19 disp = display_type(file = "main.out.F90")
20
21 call disp%skip
22 call disp%show("!%%%%%%%%%%%%%%%%%%")
23 call disp%show("!%%%%%%%%%%%%%%%%%%")
24 call disp%show("!Generate real NaN.")
25 call disp%show("!%%%%%%%%%%%%%%%%%%")
26 call disp%show("!%%%%%%%%%%%%%%%%%%")
27 call disp%skip
28
29 call disp%skip
30 call disp%show("!%%%%%%%%%%%")
31 call disp%show("!32-bit real")
32 call disp%show("!%%%%%%%%%%%")
33 call disp%skip
34
35 call disp%skip
36 call disp%show("call setNAN(X_RKS(1))")
37 call setNAN(X_RKS(1))
38 call disp%show("X_RKS(1)")
39 call disp%show( X_RKS(1) )
40 call disp%skip
41
42 call disp%skip
43 call disp%show("call setNAN(X_RKS)")
44 call setNAN(X_RKS)
45 call disp%show("X_RKS")
46 call disp%show( X_RKS )
47 call disp%skip
48
49 call disp%skip
50 call disp%show("!%%%%%%%%%%%")
51 call disp%show("!64-bit real")
52 call disp%show("!%%%%%%%%%%%")
53 call disp%skip
54
55 call disp%skip
56 call disp%show("call setNAN(X_RKD(1))")
57 call setNAN(X_RKD(1))
58 call disp%show("X_RKD(1)")
59 call disp%show( X_RKD(1) )
60 call disp%skip
61
62 call disp%skip
63 call disp%show("call setNAN(X_RKD)")
64 call setNAN(X_RKD)
65 call disp%show("X_RKD")
66 call disp%show( X_RKD)
67 call disp%skip
68
69 call disp%skip
70 call disp%show("!%%%%%%%%%%%%")
71 call disp%show("!128-bit real")
72 call disp%show("!%%%%%%%%%%%%")
73 call disp%skip
74
75 call disp%skip
76 call disp%show("call setNAN(X_RKH(1))")
77 call setNAN(X_RKH(1))
78 call disp%show("X_RKH(1)")
79 call disp%show( X_RKH(1) )
80 call disp%skip
81
82 call disp%skip
83 call disp%show("call setNAN(X_RKH)")
84 call setNAN(X_RKH)
85 call disp%show("X_RKH")
86 call disp%show( X_RKH )
87 call disp%skip
88
89
90 call disp%skip
91 call disp%show("!%%%%%%%%%%%%%%%%%%%%%")
92 call disp%show("!%%%%%%%%%%%%%%%%%%%%%")
93 call disp%show("!Generate complex NaN.")
94 call disp%show("!%%%%%%%%%%%%%%%%%%%%%")
95 call disp%show("!%%%%%%%%%%%%%%%%%%%%%")
96 call disp%skip
97
98
99 call disp%skip
100 call disp%show("!%%%%%%%%%%%%%%")
101 call disp%show("!32-bit complex")
102 call disp%show("!%%%%%%%%%%%%%%")
103 call disp%skip
104
105 call disp%skip
106 call disp%show("call setNAN(X_CKS(1))")
107 call setNAN(X_CKS(1))
108 call disp%show("X_CKS(1)")
109 call disp%show( X_CKS(1) )
110 call disp%skip
111
112 call disp%skip
113 call disp%show("call setNAN(X_CKS)")
114 call setNAN(X_CKS)
115 call disp%show("X_CKS")
116 call disp%show( X_CKS )
117 call disp%skip
118
119 call disp%skip
120 call disp%show("!%%%%%%%%%%%%%%")
121 call disp%show("!64-bit complex")
122 call disp%show("!%%%%%%%%%%%%%%")
123 call disp%skip
124
125 call disp%skip
126 call disp%show("call setNAN(X_CKD(1))")
127 call setNAN(X_CKD(1))
128 call disp%show("X_CKD(1)")
129 call disp%show( X_CKD(1) )
130 call disp%skip
131
132 call disp%skip
133 call disp%show("call setNAN(X_CKD)")
134 call setNAN(X_CKD)
135 call disp%show("X_CKD")
136 call disp%show( X_CKD )
137 call disp%skip
138
139 call disp%skip
140 call disp%show("!%%%%%%%%%%%%%%%")
141 call disp%show("!128-bit complex")
142 call disp%show("!%%%%%%%%%%%%%%%")
143 call disp%skip
144
145 call disp%skip
146 call disp%show("call setNAN(X_CKH(1))")
147 call setNAN(X_CKH(1))
148 call disp%show("X_CKH(1)")
149 call disp%show( X_CKH(1) )
150 call disp%skip
151
152 call disp%skip
153 call disp%show("call setNAN(X_CKH)")
154 call setNAN(X_CKH)
155 call disp%show("X_CKH")
156 call disp%show( X_CKH )
157 call disp%skip
158
159end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter CKH
The scalar integer constant of intrinsic default kind, representing the highest-precision complex kin...
Definition: pm_kind.F90:843
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
Definition: pm_kind.F90:570
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter CKD
The double precision complex kind in Fortran mode. On most platforms, this is a 64-bit real kind.
Definition: pm_kind.F90:571
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
Definition: pm_kind.F90:568
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
Definition: pm_kind.F90:858
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%
3!%%%%%%%%%%%%%%%%%%
4!Generate real NaN.
5!%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%
7
8
9!%%%%%%%%%%%
10!32-bit real
11!%%%%%%%%%%%
12
13
14call setNAN(X_RKS(1))
15X_RKS(1)
16NaN
17
18
19call setNAN(X_RKS)
20X_RKS
21NaN, NaN, NaN
22
23
24!%%%%%%%%%%%
25!64-bit real
26!%%%%%%%%%%%
27
28
29call setNAN(X_RKD(1))
30X_RKD(1)
31NaN
32
33
34call setNAN(X_RKD)
35X_RKD
36NaN, NaN, NaN
37
38
39!%%%%%%%%%%%%
40!128-bit real
41!%%%%%%%%%%%%
42
43
44call setNAN(X_RKH(1))
45X_RKH(1)
46NaN
47
48
49call setNAN(X_RKH)
50X_RKH
51NaN, NaN, NaN
52
53
54!%%%%%%%%%%%%%%%%%%%%%
55!%%%%%%%%%%%%%%%%%%%%%
56!Generate complex NaN.
57!%%%%%%%%%%%%%%%%%%%%%
58!%%%%%%%%%%%%%%%%%%%%%
59
60
61!%%%%%%%%%%%%%%
62!32-bit complex
63!%%%%%%%%%%%%%%
64
65
66call setNAN(X_CKS(1))
67X_CKS(1)
68(NaN, NaN)
69
70
71call setNAN(X_CKS)
72X_CKS
73(NaN, NaN), (NaN, NaN), (NaN, NaN)
74
75
76!%%%%%%%%%%%%%%
77!64-bit complex
78!%%%%%%%%%%%%%%
79
80
81call setNAN(X_CKD(1))
82X_CKD(1)
83(NaN, NaN)
84
85
86call setNAN(X_CKD)
87X_CKD
88(NaN, NaN), (NaN, NaN), (NaN, NaN)
89
90
91!%%%%%%%%%%%%%%%
92!128-bit complex
93!%%%%%%%%%%%%%%%
94
95
96call setNAN(X_CKH(1))
97X_CKH(1)
98(NaN, NaN)
99
100
101call setNAN(X_CKH)
102X_CKH
103(NaN, NaN), (NaN, NaN), (NaN, NaN)
104
105
Test:
test_pm_except


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Friday 1:54 AM, April 21, 2017, Institute for Computational Engineering and Sciences (ICES), The University of Texas, Austin, TX

Definition at line 2593 of file pm_except.F90.


The documentation for this interface was generated from the following file: