My Project
 All Classes Files Functions Variables Macros
i1mach.F
Go to the documentation of this file.
1 *DECK I1MACH
2  INTEGER FUNCTION i1mach (I)
3 C***BEGIN PROLOGUE I1MACH
4 C***PURPOSE Return integer machine dependent constants.
5 C***LIBRARY SLATEC
6 C***CATEGORY R1
7 C***TYPE INTEGER (I1MACH-I)
8 C***KEYWORDS MACHINE CONSTANTS
9 C***AUTHOR Fox, P. A., (Bell Labs)
10 C Hall, A. D., (Bell Labs)
11 C Schryer, N. L., (Bell Labs)
12 C***DESCRIPTION
13 C
14 C I1MACH can be used to obtain machine-dependent parameters for the
15 C local machine environment. It is a function subprogram with one
16 C (input) argument and can be referenced as follows:
17 C
18 C K = I1MACH(I)
19 C
20 C where I=1,...,16. The (output) value of K above is determined by
21 C the (input) value of I. The results for various values of I are
22 C discussed below.
23 C
24 C I/O unit numbers:
25 C I1MACH( 1) = the standard input unit.
26 C I1MACH( 2) = the standard output unit.
27 C I1MACH( 3) = the standard punch unit.
28 C I1MACH( 4) = the standard error message unit.
29 C
30 C Words:
31 C I1MACH( 5) = the number of bits per integer storage unit.
32 C I1MACH( 6) = the number of characters per integer storage unit.
33 C
34 C Integers:
35 C assume integers are represented in the S-digit, base-A form
36 C
37 C sign ( X(S-1)*A**(S-1) + ... + X(1)*A + X(0) )
38 C
39 C where 0 .LE. X(I) .LT. A for I=0,...,S-1.
40 C I1MACH( 7) = A, the base.
41 C I1MACH( 8) = S, the number of base-A digits.
42 C I1MACH( 9) = A**S - 1, the largest magnitude.
43 C
44 C Floating-Point Numbers:
45 C Assume floating-point numbers are represented in the T-digit,
46 C base-B form
47 C sign (B**E)*( (X(1)/B) + ... + (X(T)/B**T) )
48 C
49 C where 0 .LE. X(I) .LT. B for I=1,...,T,
50 C 0 .LT. X(1), and EMIN .LE. E .LE. EMAX.
51 C I1MACH(10) = B, the base.
52 C
53 C Single-Precision:
54 C I1MACH(11) = T, the number of base-B digits.
55 C I1MACH(12) = EMIN, the smallest exponent E.
56 C I1MACH(13) = EMAX, the largest exponent E.
57 C
58 C Double-Precision:
59 C I1MACH(14) = T, the number of base-B digits.
60 C I1MACH(15) = EMIN, the smallest exponent E.
61 C I1MACH(16) = EMAX, the largest exponent E.
62 C
63 C To alter this function for a particular environment, the desired
64 C set of DATA statements should be activated by removing the C from
65 C column 1. Also, the values of I1MACH(1) - I1MACH(4) should be
66 C checked for consistency with the local operating system.
67 C
68 C***REFERENCES P. A. Fox, A. D. Hall and N. L. Schryer, Framework for
69 C a portable library, ACM Transactions on Mathematical
70 C Software 4, 2 (June 1978), pp. 177-188.
71 C***ROUTINES CALLED (NONE)
72 C***REVISION HISTORY (YYMMDD)
73 C 750101 DATE WRITTEN
74 C 891012 Added VAX G-floating constants. (WRB)
75 C 891012 REVISION DATE from Version 3.2
76 C 891214 Prologue converted to Version 4.0 format. (BAB)
77 C 900618 Added DEC RISC constants. (WRB)
78 C 900723 Added IBM RS 6000 constants. (WRB)
79 C 901009 Correct I1MACH(7) for IBM Mainframes. Should be 2 not 16.
80 C (RWC)
81 C 910710 Added HP 730 constants. (SMR)
82 C 911114 Added Convex IEEE constants. (WRB)
83 C 920121 Added SUN -r8 compiler option constants. (WRB)
84 C 920229 Added Touchstone Delta i860 constants. (WRB)
85 C 920501 Reformatted the REFERENCES section. (WRB)
86 C 920625 Added Convex -p8 and -pd8 compiler option constants.
87 C (BKS, WRB)
88 C 930201 Added DEC Alpha and SGI constants. (RWC and WRB)
89 C 930618 Corrected I1MACH(5) for Convex -p8 and -pd8 compiler
90 C options. (DWL, RWC and WRB).
91 C 100623 Use Fortran 95 intrinsic functions (Lionel GUEZ)
92 C***END PROLOGUE I1MACH
93 C
94  INTEGER imach(16),output
95  SAVE imach
96  equivalence(imach(4),output)
97 C***FIRST EXECUTABLE STATEMENT I1MACH
98  imach( 1) = 5
99  imach( 2) = 6
100  imach( 3) = 6
101  imach( 4) = 6
102  imach( 5) = bit_size(0)
103  imach( 6) = imach( 5) / 8
104  imach( 7) = radix(0)
105  imach( 8) = digits(0)
106  imach( 9) = huge(0)
107  imach(10) = radix(0.)
108  imach(11) = digits(0.)
109  imach(12) = minexponent(0.)
110  imach(13) = maxexponent(0.)
111  imach(14) = digits(0d0)
112  imach(15) = minexponent(0d0)
113  imach(16) = maxexponent(0d0)
114  IF (i .LT. 1 .OR. i .GT. 16) go to 10
115 C
116  i1mach = imach(i)
117  RETURN
118 C
119  10 CONTINUE
120  WRITE (unit = output, fmt = 9000)
121  9000 FORMAT ('1ERROR 1 IN I1MACH - I OUT OF BOUNDS')
122 C
123 C CALL FDUMP
124 C
125  stop
126  END