Intel fortran-80 manual Logical Assignment Statement, 3.3.3Character Assignment Statement, v = exp

Models: fortran-80

1 130
Download 130 pages 742 b
Page 35
Image 35
3.3.2 Logical Assignment Statement

FORTRAN-SO

Defining Variables, Arrays, And Memory

3.3.2 Logical Assignment Statement

The logical assignment statement assigns the value. TRUE. or .FALSE. to a logical variable or array element. It has the format

v = exp

where

vis the name of a logical variable or logical array element

exp is a logical expression

Examples:

LOGICAL FLAG, TABLE(3,3)

FLAG = (INT1 .NE. 1 .AND. INT2 .EQ. 1)

CFLAG IS .TRUE.IF BOTH CONDITIONS ARE TRUE AND

C OTH ERWISE IS .FALSE. TABLE(1,3) = .FALSE. TABLE(1,2) = FLAG

3.3.3Character Assignment Statement

The character assignment statement assigns a character constant, variable name, or array element name to a character variable or array element. Its format is:

v = char

where

vis the name of a character variable or character array element

char is a character constant, character variable name, or character array element name.

None of the character positions being defined in 'v' can be referenced in 'char.' The two sides of the assignment may have different lengths, however. If 'v' is longer than 'char,' the latter is padded on the right with blank characters. If 'v' is shorter, 'char' is truncated on the right until it fits into 'v.'

Examples:

CHARACTER*10 NAMES(4), MGR

MGR = 'STENGEL'

NAMES(1) = 'GEHRIG'

NAMES(2) = 'OTT'

NAMES(3) = 'RUTH'

NAMES(4) = MGR

3.3.4 ASSIG N Statement

The ASSIGN statement is the only way to assign a statement label to a symbolic name. The symbolic name can then be referenced in a GO TO statement or as a for- mat identifier in an input/output statement. To use the symbolic name in any other context, it must first be redefined as an integer value in an arithmetic assignment statement.

3-9

Page 35
Image 35
Intel fortran-80 Logical Assignment Statement, 3.3.3Character Assignment Statement, ASSIG N Statement, v = exp, v = char