OpenLibm/slatec/r1mach.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

419 lines
13 KiB
Fortran

*DECK R1MACH
REAL FUNCTION R1MACH (I)
C***BEGIN PROLOGUE R1MACH
C***PURPOSE Return floating point machine dependent constants.
C***LIBRARY SLATEC
C***CATEGORY R1
C***TYPE SINGLE PRECISION (R1MACH-S, D1MACH-D)
C***KEYWORDS MACHINE CONSTANTS
C***AUTHOR Fox, P. A., (Bell Labs)
C Hall, A. D., (Bell Labs)
C Schryer, N. L., (Bell Labs)
C***DESCRIPTION
C
C R1MACH can be used to obtain machine-dependent parameters for the
C local machine environment. It is a function subprogram with one
C (input) argument, and can be referenced as follows:
C
C A = R1MACH(I)
C
C where I=1,...,5. The (output) value of A above is determined by
C the (input) value of I. The results for various values of I are
C discussed below.
C
C R1MACH(1) = B**(EMIN-1), the smallest positive magnitude.
C R1MACH(2) = B**EMAX*(1 - B**(-T)), the largest magnitude.
C R1MACH(3) = B**(-T), the smallest relative spacing.
C R1MACH(4) = B**(1-T), the largest relative spacing.
C R1MACH(5) = LOG10(B)
C
C Assume single precision numbers are represented in the T-digit,
C base-B form
C
C sign (B**E)*( (X(1)/B) + ... + (X(T)/B**T) )
C
C where 0 .LE. X(I) .LT. B for I=1,...,T, 0 .LT. X(1), and
C EMIN .LE. E .LE. EMAX.
C
C The values of B, T, EMIN and EMAX are provided in I1MACH as
C follows:
C I1MACH(10) = B, the base.
C I1MACH(11) = T, the number of base-B digits.
C I1MACH(12) = EMIN, the smallest exponent E.
C I1MACH(13) = EMAX, the largest exponent E.
C
C To alter this function for a particular environment, the desired
C set of DATA statements should be activated by removing the C from
C column 1. Also, the values of R1MACH(1) - R1MACH(4) should be
C checked for consistency with the local operating system.
C
C***REFERENCES P. A. Fox, A. D. Hall and N. L. Schryer, Framework for
C a portable library, ACM Transactions on Mathematical
C Software 4, 2 (June 1978), pp. 177-188.
C***ROUTINES CALLED XERMSG
C***REVISION HISTORY (YYMMDD)
C 790101 DATE WRITTEN
C 890213 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 900618 Added DEC RISC constants. (WRB)
C 900723 Added IBM RS 6000 constants. (WRB)
C 910710 Added HP 730 constants. (SMR)
C 911114 Added Convex IEEE constants. (WRB)
C 920121 Added SUN -r8 compiler option constants. (WRB)
C 920229 Added Touchstone Delta i860 constants. (WRB)
C 920501 Reformatted the REFERENCES section. (WRB)
C 920625 Added CONVEX -p8 and -pd8 compiler option constants.
C (BKS, WRB)
C 930201 Added DEC Alpha and SGI constants. (RWC and WRB)
C***END PROLOGUE R1MACH
C
INTEGER SMALL(2)
INTEGER LARGE(2)
INTEGER RIGHT(2)
INTEGER DIVER(2)
INTEGER LOG10(2)
C
REAL RMACH(5)
SAVE RMACH
C
EQUIVALENCE (RMACH(1),SMALL(1))
EQUIVALENCE (RMACH(2),LARGE(1))
EQUIVALENCE (RMACH(3),RIGHT(1))
EQUIVALENCE (RMACH(4),DIVER(1))
EQUIVALENCE (RMACH(5),LOG10(1))
C
C MACHINE CONSTANTS FOR THE AMIGA
C ABSOFT FORTRAN COMPILER USING THE 68020/68881 COMPILER OPTION
C
C DATA SMALL(1) / Z'00800000' /
C DATA LARGE(1) / Z'7F7FFFFF' /
C DATA RIGHT(1) / Z'33800000' /
C DATA DIVER(1) / Z'34000000' /
C DATA LOG10(1) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE AMIGA
C ABSOFT FORTRAN COMPILER USING SOFTWARE FLOATING POINT
C
C DATA SMALL(1) / Z'00800000' /
C DATA LARGE(1) / Z'7EFFFFFF' /
C DATA RIGHT(1) / Z'33800000' /
C DATA DIVER(1) / Z'34000000' /
C DATA LOG10(1) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE APOLLO
C
C DATA SMALL(1) / 16#00800000 /
C DATA LARGE(1) / 16#7FFFFFFF /
C DATA RIGHT(1) / 16#33800000 /
C DATA DIVER(1) / 16#34000000 /
C DATA LOG10(1) / 16#3E9A209B /
C
C MACHINE CONSTANTS FOR THE BURROUGHS 1700 SYSTEM
C
C DATA RMACH(1) / Z400800000 /
C DATA RMACH(2) / Z5FFFFFFFF /
C DATA RMACH(3) / Z4E9800000 /
C DATA RMACH(4) / Z4EA800000 /
C DATA RMACH(5) / Z500E730E8 /
C
C MACHINE CONSTANTS FOR THE BURROUGHS 5700/6700/7700 SYSTEMS
C
C DATA RMACH(1) / O1771000000000000 /
C DATA RMACH(2) / O0777777777777777 /
C DATA RMACH(3) / O1311000000000000 /
C DATA RMACH(4) / O1301000000000000 /
C DATA RMACH(5) / O1157163034761675 /
C
C MACHINE CONSTANTS FOR THE CDC 170/180 SERIES USING NOS/VE
C
C DATA RMACH(1) / Z"3001800000000000" /
C DATA RMACH(2) / Z"4FFEFFFFFFFFFFFE" /
C DATA RMACH(3) / Z"3FD2800000000000" /
C DATA RMACH(4) / Z"3FD3800000000000" /
C DATA RMACH(5) / Z"3FFF9A209A84FBCF" /
C
C MACHINE CONSTANTS FOR THE CDC 6000/7000 SERIES
C
C DATA RMACH(1) / 00564000000000000000B /
C DATA RMACH(2) / 37767777777777777776B /
C DATA RMACH(3) / 16414000000000000000B /
C DATA RMACH(4) / 16424000000000000000B /
C DATA RMACH(5) / 17164642023241175720B /
C
C MACHINE CONSTANTS FOR THE CELERITY C1260
C
C DATA SMALL(1) / Z'00800000' /
C DATA LARGE(1) / Z'7F7FFFFF' /
C DATA RIGHT(1) / Z'33800000' /
C DATA DIVER(1) / Z'34000000' /
C DATA LOG10(1) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE CONVEX
C USING THE -fn COMPILER OPTION
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7FFFFFFF' /
C DATA RMACH(3) / Z'34800000' /
C DATA RMACH(4) / Z'35000000' /
C DATA RMACH(5) / Z'3F9A209B' /
C
C MACHINE CONSTANTS FOR THE CONVEX
C USING THE -fi COMPILER OPTION
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE CONVEX
C USING THE -p8 OR -pd8 COMPILER OPTION
C
C DATA RMACH(1) / Z'0010000000000000' /
C DATA RMACH(2) / Z'7FFFFFFFFFFFFFFF' /
C DATA RMACH(3) / Z'3CC0000000000000' /
C DATA RMACH(4) / Z'3CD0000000000000' /
C DATA RMACH(5) / Z'3FF34413509F79FF' /
C
C MACHINE CONSTANTS FOR THE CRAY
C
C DATA RMACH(1) / 200034000000000000000B /
C DATA RMACH(2) / 577767777777777777776B /
C DATA RMACH(3) / 377224000000000000000B /
C DATA RMACH(4) / 377234000000000000000B /
C DATA RMACH(5) / 377774642023241175720B /
C
C MACHINE CONSTANTS FOR THE DATA GENERAL ECLIPSE S/200
C NOTE - IT MAY BE APPROPRIATE TO INCLUDE THE FOLLOWING CARD -
C STATIC RMACH(5)
C
C DATA SMALL / 20K, 0 /
C DATA LARGE / 77777K, 177777K /
C DATA RIGHT / 35420K, 0 /
C DATA DIVER / 36020K, 0 /
C DATA LOG10 / 40423K, 42023K /
C
C MACHINE CONSTANTS FOR THE DEC ALPHA
C USING G_FLOAT
C
C DATA RMACH(1) / '00000080'X /
C DATA RMACH(2) / 'FFFF7FFF'X /
C DATA RMACH(3) / '00003480'X /
C DATA RMACH(4) / '00003500'X /
C DATA RMACH(5) / '209B3F9A'X /
C
C MACHINE CONSTANTS FOR THE DEC ALPHA
C USING IEEE_FLOAT
C
C DATA RMACH(1) / '00800000'X /
C DATA RMACH(2) / '7F7FFFFF'X /
C DATA RMACH(3) / '33800000'X /
C DATA RMACH(4) / '34000000'X /
C DATA RMACH(5) / '3E9A209B'X /
C
C MACHINE CONSTANTS FOR THE DEC RISC
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE DEC VAX
C (EXPRESSED IN INTEGER AND HEXADECIMAL)
C THE HEX FORMAT BELOW MAY NOT BE SUITABLE FOR UNIX SYSTEMS
C THE INTEGER FORMAT SHOULD BE OK FOR UNIX SYSTEMS
C
C DATA SMALL(1) / 128 /
C DATA LARGE(1) / -32769 /
C DATA RIGHT(1) / 13440 /
C DATA DIVER(1) / 13568 /
C DATA LOG10(1) / 547045274 /
C
C DATA SMALL(1) / Z00000080 /
C DATA LARGE(1) / ZFFFF7FFF /
C DATA RIGHT(1) / Z00003480 /
C DATA DIVER(1) / Z00003500 /
C DATA LOG10(1) / Z209B3F9A /
C
C MACHINE CONSTANTS FOR THE ELXSI 6400
C (ASSUMING REAL*4 IS THE DEFAULT REAL)
C
C DATA SMALL(1) / '00800000'X /
C DATA LARGE(1) / '7F7FFFFF'X /
C DATA RIGHT(1) / '33800000'X /
C DATA DIVER(1) / '34000000'X /
C DATA LOG10(1) / '3E9A209B'X /
C
C MACHINE CONSTANTS FOR THE HARRIS 220
C
C DATA SMALL(1), SMALL(2) / '20000000, '00000201 /
C DATA LARGE(1), LARGE(2) / '37777777, '00000177 /
C DATA RIGHT(1), RIGHT(2) / '20000000, '00000352 /
C DATA DIVER(1), DIVER(2) / '20000000, '00000353 /
C DATA LOG10(1), LOG10(2) / '23210115, '00000377 /
C
C MACHINE CONSTANTS FOR THE HONEYWELL 600/6000 SERIES
C
C DATA RMACH(1) / O402400000000 /
C DATA RMACH(2) / O376777777777 /
C DATA RMACH(3) / O714400000000 /
C DATA RMACH(4) / O716400000000 /
C DATA RMACH(5) / O776464202324 /
C
C MACHINE CONSTANTS FOR THE HP 730
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE HP 2100
C 3 WORD DOUBLE PRECISION WITH FTN4
C
C DATA SMALL(1), SMALL(2) / 40000B, 1 /
C DATA LARGE(1), LARGE(2) / 77777B, 177776B /
C DATA RIGHT(1), RIGHT(2) / 40000B, 325B /
C DATA DIVER(1), DIVER(2) / 40000B, 327B /
C DATA LOG10(1), LOG10(2) / 46420B, 46777B /
C
C MACHINE CONSTANTS FOR THE HP 2100
C 4 WORD DOUBLE PRECISION WITH FTN4
C
C DATA SMALL(1), SMALL(2) / 40000B, 1 /
C DATA LARGE(1), LARGE(2) / 77777B, 177776B /
C DATA RIGHT(1), RIGHT(2) / 40000B, 325B /
C DATA DIVER(1), DIVER(2) / 40000B, 327B /
C DATA LOG10(1), LOG10(2) / 46420B, 46777B /
C
C MACHINE CONSTANTS FOR THE HP 9000
C
C DATA SMALL(1) / 00004000000B /
C DATA LARGE(1) / 17677777777B /
C DATA RIGHT(1) / 06340000000B /
C DATA DIVER(1) / 06400000000B /
C DATA LOG10(1) / 07646420233B /
C
C MACHINE CONSTANTS FOR THE IBM 360/370 SERIES,
C THE XEROX SIGMA 5/7/9, THE SEL SYSTEMS 85/86 AND
C THE PERKIN ELMER (INTERDATA) 7/32.
C
C DATA RMACH(1) / Z00100000 /
C DATA RMACH(2) / Z7FFFFFFF /
C DATA RMACH(3) / Z3B100000 /
C DATA RMACH(4) / Z3C100000 /
C DATA RMACH(5) / Z41134413 /
C
C MACHINE CONSTANTS FOR THE IBM PC
C
C DATA SMALL(1) / 1.18E-38 /
C DATA LARGE(1) / 3.40E+38 /
C DATA RIGHT(1) / 0.595E-07 /
C DATA DIVER(1) / 1.19E-07 /
C DATA LOG10(1) / 0.30102999566 /
C
C MACHINE CONSTANTS FOR THE IBM RS 6000
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE INTEL i860
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE PDP-10 (KA OR KI PROCESSOR)
C
C DATA RMACH(1) / "000400000000 /
C DATA RMACH(2) / "377777777777 /
C DATA RMACH(3) / "146400000000 /
C DATA RMACH(4) / "147400000000 /
C DATA RMACH(5) / "177464202324 /
C
C MACHINE CONSTANTS FOR PDP-11 FORTRAN SUPPORTING
C 32-BIT INTEGERS (EXPRESSED IN INTEGER AND OCTAL).
C
C DATA SMALL(1) / 8388608 /
C DATA LARGE(1) / 2147483647 /
C DATA RIGHT(1) / 880803840 /
C DATA DIVER(1) / 889192448 /
C DATA LOG10(1) / 1067065499 /
C
C DATA RMACH(1) / O00040000000 /
C DATA RMACH(2) / O17777777777 /
C DATA RMACH(3) / O06440000000 /
C DATA RMACH(4) / O06500000000 /
C DATA RMACH(5) / O07746420233 /
C
C MACHINE CONSTANTS FOR PDP-11 FORTRAN SUPPORTING
C 16-BIT INTEGERS (EXPRESSED IN INTEGER AND OCTAL).
C
C DATA SMALL(1), SMALL(2) / 128, 0 /
C DATA LARGE(1), LARGE(2) / 32767, -1 /
C DATA RIGHT(1), RIGHT(2) / 13440, 0 /
C DATA DIVER(1), DIVER(2) / 13568, 0 /
C DATA LOG10(1), LOG10(2) / 16282, 8347 /
C
C DATA SMALL(1), SMALL(2) / O000200, O000000 /
C DATA LARGE(1), LARGE(2) / O077777, O177777 /
C DATA RIGHT(1), RIGHT(2) / O032200, O000000 /
C DATA DIVER(1), DIVER(2) / O032400, O000000 /
C DATA LOG10(1), LOG10(2) / O037632, O020233 /
C
C MACHINE CONSTANTS FOR THE SILICON GRAPHICS
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE SUN
C
C DATA RMACH(1) / Z'00800000' /
C DATA RMACH(2) / Z'7F7FFFFF' /
C DATA RMACH(3) / Z'33800000' /
C DATA RMACH(4) / Z'34000000' /
C DATA RMACH(5) / Z'3E9A209B' /
C
C MACHINE CONSTANTS FOR THE SUN
C USING THE -r8 COMPILER OPTION
C
C DATA RMACH(1) / Z'0010000000000000' /
C DATA RMACH(2) / Z'7FEFFFFFFFFFFFFF' /
C DATA RMACH(3) / Z'3CA0000000000000' /
C DATA RMACH(4) / Z'3CB0000000000000' /
C DATA RMACH(5) / Z'3FD34413509F79FF' /
C
C MACHINE CONSTANTS FOR THE UNIVAC 1100 SERIES
C
C DATA RMACH(1) / O000400000000 /
C DATA RMACH(2) / O377777777777 /
C DATA RMACH(3) / O146400000000 /
C DATA RMACH(4) / O147400000000 /
C DATA RMACH(5) / O177464202324 /
C
C MACHINE CONSTANTS FOR THE Z80 MICROPROCESSOR
C
C DATA SMALL(1), SMALL(2) / 0, 256/
C DATA LARGE(1), LARGE(2) / -1, -129/
C DATA RIGHT(1), RIGHT(2) / 0, 26880/
C DATA DIVER(1), DIVER(2) / 0, 27136/
C DATA LOG10(1), LOG10(2) / 8347, 32538/
C
C***FIRST EXECUTABLE STATEMENT R1MACH
IF (I .LT. 1 .OR. I .GT. 5) CALL XERMSG ('SLATEC', 'R1MACH',
+ 'I OUT OF BOUNDS', 1, 2)
C
R1MACH = RMACH(I)
RETURN
C
END