LJ Archive

Listing 1. Example HPF Subroutine

       SUBROUTINE GAUSS_ELIM_90 ( A, X, Y )
       REAL, DIMENSION(:,:), INTENT(INOUT) :: A
       REAL, DIMENSION(:),   INTENT(INOUT) :: X, Y
       REAL TEMP
       REAL SWAP(SIZE(X))

!HPF$ ALIGN SWAP(:) WITH A(*,:)
!HPF$ ALIGN Y(:) WITH *A(:,*)
!HPF$ ALIGN X(:) WITH *A(:,*)
!HPF$ DISTRIBUTE A *(CYCLIC,*)

       INTEGER i,j, n, location, location_array(1)

       character*10 time

       n = SIZE( X )
       DO i = 1, n-1
       location_array = MAXLOC( ABS(A(i:n,i)) )
       location = location_array(1)+i-1
       SWAP(i:n) = A(location,i:n)
       TEMP = Y(location)
       IF (location /= i) THEN
       A(location,i:n) = A(i,i:n)
       A(i,i:n) = SWAP(i:n)
       Y(location) = Y(i)
       Y(i) = TEMP
       ENDIF
       DO j = i+1, n
       A(j,i) = A(j, i) / swap(i)
       A(j, i+1:n) = A(j, i+1:n ) - a(j, i) &
       * SWAP(i+1:n)
       Y(j) = Y(j) - a(j,i) * TEMP
       ENDDO
       ENDDO

       X(n) = Y(n) / A(n,n)
       DO i = n-1, 1, -1
       Y(1:i) = Y(1:i) - X(i+1) * A(1:i, i+1)
       X(i) = Y(i) / A(i,i)
       ENDDO
       END SUBROUTINE GAUSS_ELIM_90
LJ Archive