next up previous contents index
Next: C. Fortran Intrinsics Up: ADAPTOR HPF Language Reference Previous: A. Appendix: Fortran 90   Contents   Index

Subsections


B. Fortran 95

This appendix gives a short summary of new features in Fortran 95 It was adopted in 1996 and is now an ANSI and the ISO standard.

B..1 The FORALL Statement

The FORALL statement can be used for specifying an array assignment in terms of array elements or array sections. It can be masked with a scalar logical expression. The parallelism of this assignment is given by the fact that the assignment can be executed in any order.

The single assignments of a FORALL statement will be executed by the owner of the left hand side in the assignment.

It is possible to use array statements within the FORALL loops.

      REAL a(n,n), b(n,n), c(n)
!hpf$ distribute (block,block) :: a, b
!hpf$ distribute (block) :: c
      ...
      FORALL (i=1:n) a(1:i,i) = b(1:i,i)
      FORALL (i=2:n) c(i) = sum(c(1:i))

B..2 The FORALL Construct

The FORALL construct can contain nested FORALL statements, FORALL constructs and WHERE statements. It can be used without any restrictions.

      FORALL (I=1:8)
         A(I,I) = SQRT (A(I,I))
         FORALL (J=I-3:I+3, J/=I .AND. J>=1 .AND. J<=9)
            A(I,J) = A(I,I) * A(J,J)
         END FORALL
         WHERE (A(I,:) .NE. 0.0)
            A(I,:) = A(I-1,:) + A(I+1,:)
          ELSEWHERE
            B(I,:) = A(6-I,:)
         END WHERE
      END FORALL

In a FORALL construct all statements are executed completely in order of appearance.


B..3 PURE Procedures

A pure procedure is designed to guarantee that it is free from side effects (i.e., modifications of data visible outside the procedure). Therefore it is safe to reference it in constructs such as a FORALL assignment statement where there is no explicit order of evaluation.

Pure subprograms must have the keyword PURE.

      PURE REAL FUNCTION f (x1, x2)
      REAL x1, x2
      f = (x1 - 1) * (x2 + 1)
      END

      PURE SUBROUTINE x (a, b, c)
      REAL a, b, c
      c = (a - 1) * (b + 1)
      END

A pure procedure must not have any side effects. For this reason, a lot of syntactical restrictions are given for pure routines.


B..4 Elemental Procedures

Elemental procedures are designed to specify pure routines for scalar arguments that can later also be called with array arguments.

Elemental subprograms must have the keyword ELEMENTAL. Every elemental procedure must also be pure, but there are some more restrictions. Dummy procedures are not allowed, all dummy arguments and the function result must be scalar and not have the POINTER attribute.


next up previous contents index
Next: C. Fortran Intrinsics Up: ADAPTOR HPF Language Reference Previous: A. Appendix: Fortran 90   Contents   Index
Thomas Brandes 2004-03-18