next up previous contents
Next: Pure Function Example Up: Expressing Parallel Execution Previous: Forall Construct

 

Pure Procedures

Pure procedures, which are also included in Fortran 95, are prefixed by the PURE keyword in the same way as recursive procedures are prefixed by the RECURSIVE keyword. They must be side-effect free in the sense that they cannot change the global state of the program. (If they could then the order of invocation of the individual procedures would be significant.) Clearly, any other procedures that are invoked by a pure procedure must themselves be pure. (All Fortran 90 intrinsics and Fortran 95 ELEMENTAL functions are pure.)

For example,

    PURE REAL FUNCTION F(x,y)
    PURE SUBROUTINE G(x,y,z)

They must be side effect free, this means:

The ALLOCATE statement is not allowed in case one of the processors that is running a copy of a procedure is unable to fulfill the allocate request. External I/O is disallowed in case any of the READ / WRITE statements lead to an error, such as writing to a full disk.

PURE procedures can be executed in parallel but note that a pure procedure may still involve communications. If it does then there will be synchronisation points within the procedure. Describing a procedure as PURE does not mean that it does not involve communications.

Return to corresponding overview page gif

 

PURE procedures must also follow additional rules. These are all concerned with making sure that each copy of the procedure does not interact with any other copy of the same procedure or change the global state of the program:

To make things simple, PURE functions must behave like mathematical functions in the sense that their arguments cannot be changes (must have INTENT(IN)).

Return to corresponding overview page gif




next up previous contents
Next: Pure Function Example Up: Expressing Parallel Execution Previous: Forall Construct

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.