The REAL statement specifies the type of a symbolic constant, variable, array, function, or dummy function to be real, and optionally specifies array dimensions and size, and initializes with values.
REAL [*len[,]] v[*len[/c/]] [, v[*len[/c/]] ...
Parameter |
Description |
v |
Name of a variable, symbolic constant, array, array declarator, function, or dummy function |
len |
Either 4, 8, or 16 (SPARC only), the length in bytes of the symbolic constant, variable, array element, or function |
c |
List of constants for the immediately preceding name |
Following are descriptions for REAL, REAL*4, REAL*8, and REAL*16.
For a declaration such as REAL W, the variable W is usually a REAL*4 element in memory, interpreted as a real number. Specifying the size is nonstandard. @
The default size, for a declaration such as REAL H, can be altered by compiling with any of the options -dbl, -r8, or -xtypemap. See the discussion in Chapter 2 for details.
For a declaration such as REAL*4 W, the variable W is always a REAL*4 element in memory, interpreted as a single-width real number.
For a declaration such as REAL*8 W, the variable W is always a REAL*8 element in memory, interpreted as a double-width real number.
(SPARC only) For a declaration such as REAL*16 W, the variable W is always an element of type REAL*16 in memory, interpreted as a quadruple-width real.
Example 1: Simple real variables--these declarations are all equivalent:
REAL U, V(9) REAL*4 U, V(9) REAL U*4, V(9)*4
Example 2: Initialize variables (REAL*16 is SPARC only):
REAL U/ 1.0 /, V/ 4.3 /, D*8/ 1.0 /, Q*16/ 4.5 /
Example 3: Specify dimensions for some real arrays:
REAL A(10,100), V(10) REAL X*4(10), Y(10)*4
Example 4: Initialize some arrays:
REAL A(10,100) / 1000 * 0.0 /, B(2,2) /1.0, 2.0, 3.0, 4.0/
Example 5: Double and quadruple precision (REAL*16 is SPARC only):
REAL*8 R REAL*16 Q DOUBLE PRECISION D
In the above example, D and R are both double precision; Q is quadruple precision.