next up previous contents
Next: Internal Subprograms Up: Examples and Exercises Previous: Getting Started

Basic Fortran Programs

Declarations of variables and parameters in Fortran 77 have been changed slightly in the new standard to allow for more concise specification of an identifier's attributes. The Fortran 77 declaration,

integer N
parameter( N = 10 )

now can be written more concisely as

integer, parameter :: N = 10

As shown in the above declaration, constants and variables alike may be initialized at the time of declaration.gif

Several new control constructs, many implemented as extensions to Fortran 77, are now officially part of Fortran 90. These include do ... end do, do while ( condition ) ... end do, and select case ( case expr ) ... end case. The do while ( condition ) ... end do construct is illustrated in next exercise. Note that a line number and the continue statement are no longer necessary to mark the end of a do loop.

Fortran 90 introduces synonyms for several relational operators, making them more natural and similar to relational operators in other languages. These are summarized in Table 3.

   table134
Table 3: Fortran 90 Relational Operators

Either style is acceptable in Fortran 90 and the styles may be used interchangeably in either source form.

Non-advancing I/O is another new feature of Fortran 90 illustrated in the next exercise. It permits several write statements to output to a single line, something that was not possible in Fortran 77. The specification of the format for the output has also been improved, eliminating the need for line numbers and a separate format statement.

Comments may be placed anywhere on the source line, preceded with a `!' character. Trailing comments are also possible. All of these features are illustrated in the following exercise.

exercise158



next up previous contents
Next: Internal Subprograms Up: Examples and Exercises Previous: Getting Started