Eric Grosse,
ehg@bell-labs.com
Bell Laboratories 2T-504
700 Mountain Avenue
Murray Hill, New Jersey 07974-0636
USA
The authors were all from Bell Labs: P. A. Fox, A. D. Hall and N. L. Schryer (June 1978).
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)Similar descriptions exist for d1mach and i1mach.
Also d1mach has five lines, while i1mach has as many as 16 lines for each system.
Some of the integer parameters, like unit number of the punching unit, are now obsolete.
The routines r1mach.f, d1mach.f, and i1mach.f are nowadays available (with parameters for most systems) from netlib in the library slatec/src/.
The error message unit I1MACH(4) is usually 0 in UNIX systems.
The parameter I1MACH(6) is the number of characters per integer storage unit and applies to Fortran 66, where Hollerith characters were stored in integer variables (or even worse, in floating point variables). It was put to "1" for for the Fortran 77 versions of the Port error-handling routines to work correctly. Since the two Port routines e9rint and seterr now have been modified, the more relevant value I1MACH(6) = 4 is used. It is valid at least for all IEEE based computers, where a Fortran integer occupies 4 bytes.
The routines r1mach.f90, d1mach.f90, and i1mach.f90 are available here.
Also a set of very simple test programs have been made available, they show the hexadecimal values obtained. These values can be compared with the values from the older versions. The test programs are test_of_r1mach.f90, test_of_d1mach.f90, and test_of_i1mach.f90.
In April 1999 a new set of test programs were prepared. These are closer to Fortran 77, they print the floating point values and not only the hexadecimal values, and are intended to be more system-independent than the old ones. The new ones however fail to print the hexadecimal values with the NAG compiler and on the Cray C90 in double precision. The new test programs are test2_of_r1mach.f90 and test2_of_d1mach.f90.
David Gay and Eric Grosse, Self-Adapting Fortran 77 Machine Constants: Comment on Algorithm 528, ACM Transactions on Mathematical Software 25, 1 (March 1999), pp. 123-126.