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