Statistics
| Branch: | Revision:

root / synthbench / euroben-ports / base / Fortran-MPI / mod2a / .svn / text-base / dmacdp.f.svn-base @ 0:839f52ef7657

History | View | Annotate | Download (4 kB)

1 0:839f52ef7657 louridas
      Function dmacdp( i )               Result( mpar )
2 0:839f52ef7657 louridas
      Use        numerics
3 0:839f52ef7657 louridas
      Integer  :: i
4 0:839f52ef7657 louridas
      Real(l_) :: mpar
5 0:839f52ef7657 louridas
! --------------------------------------------------------------------
6 0:839f52ef7657 louridas
! --- This function provides 8-byte precision machine parameters.
7 0:839f52ef7657 louridas
!     The Fortran 90 intrisics are employed to get the relevant
8 0:839f52ef7657 louridas
!     parameters.
9 0:839f52ef7657 louridas
!
10 0:839f52ef7657 louridas
! --- A reference to dmacdp(i) produces one of the machine parameters
11 0:839f52ef7657 louridas
!     where:
12 0:839f52ef7657 louridas
!
13 0:839f52ef7657 louridas
!     I is an integer input variable in the range [1,...,6] which
14 0:839f52ef7657 louridas
!         selects the desired machine parameter. If the machine has
15 0:839f52ef7657 louridas
!         T base B digits and its smallest and largest exponents are
16 0:839f52ef7657 louridas
!         EMIN and EMAX, respectively, then these parameters are:
17 0:839f52ef7657 louridas
!
18 0:839f52ef7657 louridas
!         dmacdp(1) = B**(1 - T), the relative machine precision
19 0:839f52ef7657 louridas
!                                 (RELEPS), at 1.0D0
20 0:839f52ef7657 louridas
!         dmacdp(2) = B**(EMIN - 1), the smallest representable Real
21 0:839f52ef7657 louridas
!                                    number (RMIN),
22 0:839f52ef7657 louridas
!         dmacdp(3) = B**EMAX*(1 - B**(-T)), the largest representable
23 0:839f52ef7657 louridas
!                                            Real number (RMAX).
24 0:839f52ef7657 louridas
!         dmacdp(4) = T, N.B.: T is returned as a Real (Double
25 0:839f52ef7657 louridas
!                              Precision) value (due to the restric-
26 0:839f52ef7657 louridas
!                              tions of Fortran functions). It
27 0:839f52ef7657 louridas
!                              should be converted to type Integer
28 0:839f52ef7657 louridas
!                              after the function call to avoid
29 0:839f52ef7657 louridas
!                              type conflicts.
30 0:839f52ef7657 louridas
!         dmacdp(5) = B, N.B.: B is returned as a Real (Double
31 0:839f52ef7657 louridas
!                              Precision) value (due to the restric-
32 0:839f52ef7657 louridas
!                              tions of Fortran functions). It
33 0:839f52ef7657 louridas
!                              should be converted to type Integer
34 0:839f52ef7657 louridas
!                              after the function call to avoid
35 0:839f52ef7657 louridas
!                              type conflicts.
36 0:839f52ef7657 louridas
!         dmacdp(6) = P, N.B.: P is is the length in bits of the
37 0:839f52ef7657 louridas
!                              floating-point numbers used in the
38 0:839f52ef7657 louridas
!                              benchmark.
39 0:839f52ef7657 louridas
!                              It is returned as a Real (Double
40 0:839f52ef7657 louridas
!                              Precision) value (due to the restric-
41 0:839f52ef7657 louridas
!                              tions of Fortran-77 functions). It
42 0:839f52ef7657 louridas
!                              should be converted to type Integer
43 0:839f52ef7657 louridas
!                              after the function call to avoid
44 0:839f52ef7657 louridas
!                              type conflicts.
45 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
46 0:839f52ef7657 louridas
      Real(l_), Parameter ::
47 0:839f52ef7657 louridas
     &                       releps = 1.0_l_, rmin = 1.0_l_,
48 0:839f52ef7657 louridas
     &                       rmax   = 1.0_l_, t    = 1.0_l_,
49 0:839f52ef7657 louridas
     &                       b      = 1.0_l_
50 0:839f52ef7657 louridas
51 0:839f52ef7657 louridas
!----------------------------------------------------------------------
52 0:839f52ef7657 louridas
! --- Return value according to value of 'i'.
53 0:839f52ef7657 louridas
54 0:839f52ef7657 louridas
      Select Case( i )
55 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
56 0:839f52ef7657 louridas
! --- Relative machine precision:
57 0:839f52ef7657 louridas
58 0:839f52ef7657 louridas
      Case( 1 )
59 0:839f52ef7657 louridas
         mpar = Epsilon( releps )
60 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
61 0:839f52ef7657 louridas
! --- Smallest representable f.p. number:
62 0:839f52ef7657 louridas
63 0:839f52ef7657 louridas
      Case( 2 )
64 0:839f52ef7657 louridas
         mpar = Tiny( rmin )
65 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
66 0:839f52ef7657 louridas
! --- Largest representable f.p. number:
67 0:839f52ef7657 louridas
68 0:839f52ef7657 louridas
      Case( 3 )
69 0:839f52ef7657 louridas
         mpar = Huge( rmax )
70 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
71 0:839f52ef7657 louridas
! --- Number of base B digits.
72 0:839f52ef7657 louridas
73 0:839f52ef7657 louridas
      Case( 4 )
74 0:839f52ef7657 louridas
         mpar = Digits( t )
75 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
76 0:839f52ef7657 louridas
! --- Base B of floating-point representation.
77 0:839f52ef7657 louridas
78 0:839f52ef7657 louridas
      Case( 5 )
79 0:839f52ef7657 louridas
         mpar = Radix( b )
80 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
81 0:839f52ef7657 louridas
! --- Number of bits in floating-point representation used: P.
82 0:839f52ef7657 louridas
83 0:839f52ef7657 louridas
      Case( 6 )
84 0:839f52ef7657 louridas
         p = Log( Dble( Maxexponent(b) ) )
85 0:839f52ef7657 louridas
         mpar =  p/Log( 2.0_l_ ) + Digits( b ) + 1.0_l_
86 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
87 0:839f52ef7657 louridas
! --- i out of range:
88 0:839f52ef7657 louridas
89 0:839f52ef7657 louridas
      Case Default
90 0:839f52ef7657 louridas
         Print *, 'Parameter i out of range in function dmacdp:', i
91 0:839f52ef7657 louridas
         Stop
92 0:839f52ef7657 louridas
      End Select
93 0:839f52ef7657 louridas
! ---------------------------------------------------------------------
94 0:839f52ef7657 louridas
      Return
95 0:839f52ef7657 louridas
      End