FORTRAN 77 Language Reference

Arithmetic Assignment

The arithmetic assignment statement assigns a value to a variable, array element, or record field. The syntax is:

 v = e e Arithmetic expression, a character constant, or a logical expression v Numeric variable, array element, or record field

Assigning logicals to numerics is allowed, but nonstandard, and may not be portable. The resultant data type is, of course, the data type of v. @

Execution of an arithmetic assignment statement causes the evaluation of the expression e, and conversion to the type of v (if types differ), and assignment of v with the resulting value typed according to the table below.

Character constants can be assigned to variables of type integer or real. Such a constant can be a Hollerith constant or a string in apostrophes or quotes. The characters are transferred to the variables without any conversion of data. This practice is nonstandard and may not be portable. @

Type of v

Conversion of e

INTEGER*2, INTEGER*4, or INTEGER*8

REAL

REAL*8

REAL*16 (SPARC only)

DOUBLE PRECISION

COMPLEX*8

COMPLEX*16

COMPLEX*32 (SPARC only)

INT(e)

REAL(e)

DBLE(e)

QREAL(e) (SPARC only)

DBLE(e)

CMPLX(e)

DCMPLX(e)

QCMPLX(e) (SPARC only)

Note -

Compiling with any of the options -i2, -dbl, -r8, or -xtypemap will have an effect on the assumed type of e. This is discussed in Chapter 2. See also the Fortran User's Guide for a description of these options.

Example: Arithmetic assignment:

```	INTEGER I2*2, J2*2, I4*4
LOGICAL L1, L2
REAL R4*4, R16*16
DOUBLE PRECISION DP
COMPLEX C8, C16*16
J2 = 29002
I2 = J2
I4 = (I2 * 2) + 1
DP = 6.4D0
QP = 9.8Q1
R4 = DP
R16 = QP
C8 = R1
C8 = ( 3.0, 5.0 )
I2 = C8
C16 = C8
C8 = L1
R4 = L2```