FORTRAN 77 Language Reference

COMPLEX

The COMPLEX statement specifies the type of a symbolic constant, variable, array, function, or dummy function to be complex, optionally specifies array dimensions and size, and initializes with values.

COMPLEX [*len[,]] v [*len[/c/]] [, v [*len[/c/]] ...

Parameter 

Description 

v

Name of a symbolic constant, variable, array, array declarator, function, or dummy function  

len

Either 8, 16, or 32, the length in bytes of the symbolic constant, variable, array element, or function (32 is SPARC only)

c

List of constants for the immediately preceding name  

Description

The declarations can be: COMPLEX, COMPLEX*8, COMPLEX*16, or COMPLEX*32. Specifying the size is nonstandard. @

COMPLEX

For a declaration such as COMPLEX W, the variable W is usually two REAL*4 elements contiguous in memory, interpreted as a complex number.

If you do not specify the size, a default size is used.

The default size for a declaration such as COMPLEX W can be altered by compiling with any of the options -dbl, -r8, or -xtypemap. See the discussion in Chapter 2 for details.

COMPLEX*8 @

For a declaration such as COMPLEX*8 W, the variable W is always two REAL*4 elements contiguous in memory, interpreted as a complex number.

COMPLEX*16 @

For a declaration such as COMPLEX*16 W, W is always two REAL*8 elements contiguous in memory, interpreted as a double-width complex number.

COMPLEX*32 @

(SPARC only) For a declaration such as COMPLEX*32 W, the variable W is always two REAL*16 elements contiguous in memory, interpreted as a quadruple-width complex number.

Comments

There is a double-complex version of each complex built-in function. Generally, the specific function names begin with Z or CD instead of C, except for the two functions DIMAG and DREAL, which return a real value.

There are specific complex functions for quad precision (SPARC only). In general, where there is a specific REAL a corresponding COMPLEX with a C prefix, and a corresponding COMPLEX DOUBLE with a CD prefix, there is also a quad-precision COMPLEX function with a CQ prefix. Examples are: SIN(), CSIN(), CDSIN(), CQSIN().

Examples

Example 1: Complex variables. These statements are equivalent.


       COMPLEX U, V
       COMPLEX*8 U, V
       COMPLEX U*8, V*8 

Example 2: Initialize complex variables:


       COMPLEX U/(1, 9.0)/,V/(4.0, 5)/ 

A complex constant is a pair of numbers, either integers or reals.

Example 3: Double complex, with initialization:


       COMPLEX U*16 / (1.0D0, 9 ) /, V*16 / (4.0, 5.0D0) / 
       COMPLEX*16 X / (1.0D0, 9.0) /, Y / (4.0D0, 5 ) /

A double-complex constant is a pair of numbers, and at least one number of the pair must be double precision.

Example 4: Quadruple complex, with initialization (SPARC only):


       COMPLEX U*32 / (1.0Q0, 9 ) /, V*32 / (4.0, 5.0Q0) / 
       COMPLEX*32 X / (1.0Q0, 9.0) /, Y / (4.0Q0, 5 ) / 

A quadruple complex constant is a pair of numbers, and at least one number of the pair must be quadruple precision.

Example 5: Complex arrays, all of which are nonstandard (SPARC only):


       COMPLEX R*16(5), S(5)*16 
       COMPLEX U*32(5), V(5)*32 
       COMPLEX X*8(5), Y(5)*8