24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>FORTRAN</strong> Statements<br />

2.23 DO WHILE Statement<br />

DO [s[,]] WHILE (e)<br />

[: block-label]<br />

where:<br />

s<br />

e<br />

block-label<br />

is an optional statement label of an executable statement, called the terminal<br />

statement, which follows the DO statement in the same program unit.<br />

is a logical expression or integer arithmetic expression, in which case the result<br />

of the integer expression is compared for inequality to the integer value 0.<br />

is an optional block label.<br />

The DO WHILE statement is an extension to the <strong>FORTRAN</strong> <strong>77</strong> language.<br />

Example:<br />

X = 0.0<br />

DO 10 WHILE( X .LT. 100.0 )<br />

PRINT *, X, SQRT( X )<br />

X = X + 1.0<br />

10 CONTINUE<br />

If no statement label is present, the terminal statement of the DO-loop must be an END DO statement.<br />

Example:<br />

X = 0.0<br />

DO WHILE( X .LT. 100.0 )<br />

PRINT *, X, SQRT( X )<br />

X = X + 1.0<br />

ENDDO<br />

The following example illustrates the use of an integer arithmetic expression.<br />

Example:<br />

I = 10<br />

DO WHILE( I )<br />

PRINT *, I<br />

I = I - 1<br />

ENDDO<br />

END<br />

The DO WHILE statement, is similar to the DO statement. All nesting rules that apply to the DO statement<br />

also apply to the DO WHILE statement. The difference is the way in which the looping is accomplished;<br />

the DO-loop is executed while the logical expression of the DO WHILE statement has a true value or until<br />

control is transferred out of the DO-loop.<br />

For more information, see the chapter entitled "Program Structure Control Statements" on page 193.<br />

DO WHILE Statement 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!