############################################################# # Output from 'meps' on Cray J90 (Cray 64-bit floating point) ############################################################# ############################################################# # First consider source code: Only difference between this # version and the SGI version is that here we use 'e0' # rather than 'd0' for real*8 constants. A double precision # variable or constant (d0) on a Cray system uses 16 bytes # and arithmetic involving such quantities is *not* # implemented in hardware, and consequently is very slow # compared to real*8 (e0) arithmetic. ############################################################# charon 21> cat meps.f c=========================================================== c Computes and reports estimate of machine epsilon. c c Recall: machine epsilon is smallest positive 'eps' c such that c c (1.0e0 + eps ) .ne. (1.0e0) c c Program accepts optional argument which specifies c division factor: values close to 1.0 will result c in more accurate estimate of machine epsilon. c=========================================================== program meps implicit none c----------------------------------------------------------- c Note use of 'r8arg', available in 'libp329f.a' which c works exactly like 'i4arg' except that it returns c a real value parsed from the specified command-line c argument c----------------------------------------------------------- real r8arg real default_fac parameter ( default_fac = 2.0e0 ) real eps, neweps, fac fac = r8arg(1,default_fac) write(0,*) 'meps: using division factor: ', fac eps = 1.0e0 neweps = 1.0e0 do while( .true. ) if( 1.0e0 .eq. (1.0e0 + neweps) ) then write(*,*) eps stop else eps = neweps neweps = neweps / fac end if end do stop end charon 22> meps meps: using division factor: 2. 7.105427357601001E-15 STOP executed at line 38 in Fortran routine 'MEPS' CPU: 0.005s, Wallclock: 0.015s, 4.2% of 8-CPU Machine Memory HWM: 200255, Stack HWM: 2048, Stack segment expansions: 0 charon 23> meps 1.01 meps: using division factor: 1.009999999999998 7.10922461021392E-15 STOP executed at line 38 in Fortran routine 'MEPS' CPU: 0.009s, Wallclock: 0.020s, 5.6% of 8-CPU Machine Memory HWM: 200257, Stack HWM: 2048, Stack segment expansions: 0 charon 24> meps 1.0001 meps: using division factor: 1.000100000000003 7.105756717509093E-15 STOP executed at line 38 in Fortran routine 'MEPS' CPU: 0.338s, Wallclock: 0.348s, 12.1% of 8-CPU Machine Memory HWM: 200257, Stack HWM: 2048, Stack segment expansions: 0