next up previous contents
Next: Programming Example Using F77-Callable Up: Programming Example Using HPF_SUBGRID_INFO Previous: HPF Caller

FORTRAN 77 Callee

    SUBROUTINE LOCAL1( LB1, UB1, LB2, UB2, NX, X )

! The global actual arguments passed to LB1, UB1, LB2, and UB2
! have only one element apiece and so can be treated as scalars
! in the local Fortran 77 procedures
    INTEGER LB1, UB1, LB2, UB2
! NX contains the global extent of the first dimension
! of the global array associated with local array X
    INTEGER NX
! Note that X may have no local elements.
    REAL X ( LB1 : UB1 , LB2 : UB2 )
! Initialize the elements of the array, if any
    DO J = LB2, UB2
        DO I = LB2, UB2
            X(I,J) = I + (J-1) * NX
        END DO
    END DO
    END

    SUBROUTINE LOCAL2(N,X,R)
! Here, the rank of the original array is unimportant
! Only the total number of local elements is needed
!   INTEGER N
    REAL X(N), R
! If N is zero, local array X has no elements, but R
! still computes the correct local sum
    R = 0.
    DO I = 1, N
        R = R + X(I)
    END DO
    END