Tuesday, March 19, 2013

Fortran 90

The much delayed successor to FORTRAN 77, informally known as Fortran 90 (and prior to that, Fortran 8X), was finally released as ISO/IEC standard 1539:1991 in 1991 and an ANSI Standard in 1992. In addition to changing the official spelling from FORTRAN to Fortran, this major revision added many new features to reflect the significant changes in programming practice that had evolved since the 1978 standard:

  • Free-form source input, also with lowercase Fortran keywords
  • Identifiers up to 31 characters in length
  • Inline comments
  • Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations.
    • whole, partial and masked array assignment statements and array expressions, such as   X(1:N)=R(1:N)*COS(A(1:N))
    • WHERE statement for selective array assignment
    • array-valued constants and expressions,
    • user-defined array-valued functions and array constructors.
  • RECURSIVE procedures
  • Modules, to group related procedures and data together, and make them available to other program units, including the capability to limit the accessibility to only specific parts of the module.
  • A vastly improved argument-passing mechanism, allowing interfaces to be checked at compile time
  • User-written interfaces for generic procedures
  • Operator overloading
  • Derived (structured) data types
  • New data type declaration syntax, to specify the data type and other attributes of variables
  • Dynamic memory allocation by means of the ALLOCATABLE attribute and the ALLOCATE and DEALLOCATE statements
  • POINTER attribute, pointer assignment, and NULLIFY statement to facilitate the creation and manipulation of dynamic data structures
  • Structured looping constructs, with an END DO statement for loop termination, and EXIT and CYCLE statements for terminating normal DO loop iterations in an orderly way
  • SELECT . . . CASE construct for multi-way selection
  • Portable specification of numerical precision under the user's control
  • New and enhanced intrinsic procedures.

Obsolescence and deletions

Unlike the previous revision, Fortran 90 did not delete any features. (Appendix B.1 says, "The list of deleted features in this standard is empty.") Any standard-conforming FORTRAN 77 program is also standard-conforming under Fortran 90, and either standard should be usable to define its behavior.
A small set of features were identified as "obsolescent" and expected to be removed in a future standard.
Obsolescent feature Example Status / Fate in Fortran 95
Arithmetic IF-statement     IF (X) 10, 20, 30
Non-integer DO parameters or control variables     DO 9 X= 1.7, 1.6, -0.1 Deleted
Shared DO-loop termination or
termination with a statement
other than END DO or CONTINUE  
    DO 9 J= 1, 10         DO 9 K= 1, 10
9   L= J + K


Branching to END IF
from outside a block
66  GO TO 77 ; . . .     IF (E) THEN ;     . . .
77  END IF

Deleted
Alternate return     CALL SUBR( X, Y *100, *200 )
PAUSE statement     PAUSE 600 Deleted
ASSIGN statement
  and assigned GO TO statement
100  . . .     ASSIGN 100 TO H
    . . .
    GO TO H . . .

Deleted
Assigned FORMAT specifiers     ASSIGN F TO 606 Deleted
H edit descriptors 606 FORMAT ( 9H1GOODBYE. ) Deleted
Computed GO TO statement     GO TO (10, 20, 30, 40), index (obsolete)
Statement functions     FOIL( X, Y )= X**2 + 2*X*Y + Y**2 (obsolete)
DATA statements
  among executable statements
    X= 27.3     DATA A, B, C / 5.0, 12.0. 13.0 /     . . .
(obsolete)
CHARACTER* form of CHARACTER declaration     CHARACTER*8 STRING   ! Use CHARACTER(8) (obsolete)
Assumed character length functions     CHARACTER*(*) STRING (obsolete)[14]
Fixed form source code Column 1 contains *, ! or C for comments.
Column 6 for continuation.

"Hello world" example

program helloworld
     print *, "Hello, world."
end program helloworld

No comments:

Post a Comment