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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Language</strong> <strong>Reference</strong><br />

Example:<br />

* From the quadratic equation<br />

*<br />

* 2<br />

* ax + bx + c = 0<br />

*<br />

* we derive the following two equations:<br />

* ____________<br />

* + / 2<br />

* -b - \/ b - 4ac<br />

* x = ---------------------<br />

* 2a<br />

*<br />

* and express these equations in <strong>FORTRAN</strong> as:<br />

X1 = ( -B + SQRT( B**2 - 4 * A * C ) )<br />

$ / ( 2 * A )<br />

X2 = ( -B - SQRT( B**2 - 4 * A * C ) )<br />

$ / ( 2 * A )<br />

1.4 Order of <strong>FORTRAN</strong> Statements and Lines<br />

The first statement of a program unit may be a PROGRAM, FUNCTION, SUBROUTINE, or BLOCK<br />

DATA statement. The PROGRAM statement identifies the start of a main program and there may only be one<br />

of these in an executable <strong>FORTRAN</strong> program. Execution of a <strong>FORTRAN</strong> program begins with the first<br />

executable statement in the main program. The other statements identify the start of a subprogram. If the<br />

first statement of a program unit is not one of the above then the program unit is considered to be a main<br />

program.<br />

Although you may not be familiar with all of the terms used here, it is important that you understand that<br />

<strong>FORTRAN</strong> <strong>77</strong> has specific rules regarding the ordering of <strong>FORTRAN</strong> statements. You may wish to refer<br />

to this section at later times. In general, the following rules apply to the order of statements and comment<br />

lines within a program unit:<br />

1. Comment lines and INCLUDE statements may appear anywhere.<br />

2. FORMAT statements may appear anywhere in a subprogram.<br />

3. All specification statements must precede all DATA statements, statement function statements,<br />

and executable statements.<br />

4. All statement function statements must precede all executable statements.<br />

5. DATA statements may appear anywhere after the specification statements.<br />

6. ENTRY statements may appear anywhere except between a block IF statement and its<br />

corresponding END IF statement, or between a DO statement and its corresponding terminal<br />

statement. <strong>Open</strong> <strong>Watcom</strong> <strong>FORTRAN</strong> <strong>77</strong> extends these rules to apply to all program structure<br />

blocks resulting from the use of statements introduced to the language by <strong>Open</strong> <strong>Watcom</strong><br />

<strong>FORTRAN</strong> <strong>77</strong> (e.g., WHILE, LOOP, SELECT).<br />

7. IMPLICIT statements must precede all other specification statements, except PARAMETER<br />

statements. A specification statement that defines the type of a symbolic constant must appear<br />

6 Order of <strong>FORTRAN</strong> Statements and Lines

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

Saved successfully!

Ooh no, something went wrong!