02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's 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.

EXIT<br />

20 i = 20<br />

GO TO 100<br />

30 i = 30<br />

GO TO 100<br />

40 i = 40<br />

100 print *, i<br />

END DO<br />

Unconditional GO TO statement<br />

Execution control<br />

Flow control statements<br />

The unconditional GO TO statement transfers control to the statement with the specified label.<br />

Syntax<br />

GO TO label<br />

Execution logic<br />

Control transfers to the statement at label.<br />

Example<br />

Older, “dusty-deck” <strong>Fortran</strong> programs often combine the GO TO statement with the logical IF<br />

statement to form a kind of leap-frog logic, as in the following:<br />

IF ( num1 /= num2) GO TO 10<br />

PRINT *, ”num1 and num2 are equal.”<br />

GO TO 30<br />

10 IF ( num1 > num2 ) GO TO 20<br />

PRINT *, ”num1 is smaller than num2.”<br />

GO TO 30<br />

20 PRINT *, ”num1 is greater than num2.”<br />

30 CONTINUE<br />

Arithmetic IF statement<br />

The arithmetic IF transfers control to one of three labeled statements, as determined by the<br />

value of an arithmetic expression.<br />

Syntax<br />

IF ( arithmetic-expression ) label1, label2, label3<br />

Execution logic<br />

1. arithmetic-expression is evaluated.<br />

Chapter 6 117

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

Saved successfully!

Ooh no, something went wrong!