Note that compilers will continue to support obsolescent statements and features, and some new compilers may even continue to support features that have been recently removed. Future compilers, however, will not be required to support features once designated as obsolescent and then subsequently removed from the official definition of Fortran.
Fortran-90 "obsolescent" statements and features include the following:
HPF also includes a few additional intrinsic functions pertinent to executing code on parallel machines.
Further information about HPF should be obtained from detailed manuals for the machine being used.
The three options for the "intent" of an argument are:
REAL, INTENT(IN) :: X, Y
SUBROUTINE SOLVE(A, B, C, N)
REAL, OPTIONAL :: A, C
REAL :: B
INTEGER, OPTIONAL :: N
When invoking this subroutine and NOT including an optional argument,
one should specify the arguments AFTER the omitted argument
in this way:
CALL SOLVE(A,B,N=N2)
It is also permitted to specify all the argument or even to rearrange
the arguments when using the specification, e.g.,
CALL SOLVE(B=B,N=N2,A=A)
One makes use of a LOGICAL function PRESENT to
determine which an optional argument has, in fact, been used
and this can be used to give a default value, e.g.,
IF (.NOT. (PRESENT(C))) THEN
C = 1.0
END IF
The underlying data structure is part of a derived type and this type and associated subprograms are placed in a module called STACK_MOD. The derived type is called STACK and its data, the array STACKELEMENT which will contain the contents of the stack, and the top-of-stack pointer TOP will be PRIVATE, and therefore inaccessible to any program segment which makes use of the derived type.
The module also contains three local routines: PUSH, which adds elements to the stack; POP, which deletes the element on the top of the stack; and INIT, which initializes a new stack by correctly setting the TOP variable to 0. (This last routine is needed in Fortran-90, since initializing a component of a derived type is not allowed in Fortran-90, but this feature has been included in Fortran-95/2003.)
MODULE STACK_MOD
TYPE STACK
PRIVATE
INTEGER :: STACKELEMENT(100)
INTEGER :: TOP
END TYPE
CONTAINS
SUBROUTINE INIT(S)
TYPE(STACK) :: S
S%TOP = 0
END SUBROUTINE
!
SUBROUTINE PUSH(S,ITEM)
TYPE(STACK) :: S
INTEGER :: ITEM
IF (S%TOP < 100) THEN
S%TOP=S%TOP+1
S%STACKELEMENT(S%TOP) = ITEM
ELSE
WRITE(*,*) "STACK OVERFLOW"
STOP
ENDIF
END SUBROUTINE
!
INTEGER FUNCTION POP(S)
TYPE(STACK) :: S
IF (S%TOP > 0) THEN
POP = S%STACKELEMENT(S%TOP)
S%TOP = S%TOP-1
ELSE
WRITE(*,*) "STACK UNDERFLOW"
STOP
ENDIF
END FUNCTION
END MODULE
The following program makes use of the STACK_MOD module
and declares two stacks, S and T. It then pushes a few
values onto the two stacks and pops the values off to
print them out. (For further information about stacks, see
a complete book on Data Structures.)
PROGRAM TESTSTACK USE STACK_MOD TYPE(STACK) S,T INTEGER TEMP ! Initial both stackpointers CALL INIT(S) CALL INIT(T) ! Push several values onto the stacks CALL PUSH(S,3) CALL PUSH(S,4) CALL PUSH(S,5) CALL PUSH(T,1) CALL PUSH(T,2) ! Pop a value off and save it in TEMP ! before printing it out TEMP = POP(S) WRITE(*,*) TEMP ! Pop off values and print out directly WRITE(*,*) POP(S) WRITE(*,*) POP(S) WRITE(*,*) POP(T) WRITE(*,*) POP(T) END
Anyone needing information about these statements (for example, when maintaining older code) should consult a fuller reference on Fortran.
This page is maintained by Dennis C. Smolarski, S.J.
dsmolarski@math.scu.edu
© Copyright 1998, 1999, 2006 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 14 February 2006.