next up previous

3.5 Environmental Inquiry     continued...

The seven numeric manipulation functions allow the programmer to access important model values related to a given specific value of that kind. The given value is the value of the (first) argument, which may be any expression that has a (defined) value of that kind. (Three of these seven functions also have a second argument.) These seven useful values and the related numeric manipulation intrinsic functions are shown in Table 3:

Table 3: Numerical Manipulation Functions.

An (idealized) example will illustrate the use of these functions for writing robust portable code. In this example Newton's method is used to find the root to maximum accuracy (for the real kind being used) of a function F, in the minimum number of iterations. This example assumes the function F and its derivative function DF are available, and that the value X is already established in a region in which Newton's method will converge to the root.

 DX = F(X)/DF(X)                 ! Compute the next delta-X.
 X = X-DX
 if (DX<2*spacing(X)) exit       ! Stop if near the spacing
end do                           !  limits of that kind 
...                              !      in this region.