PROGRAM GAUSS_90 REAL, allocatable :: A(:,:), X(:), Y(:), START(:) INTEGER :: i INTEGER j, n !HPF$ ALIGN START(:) WITH A(*,:) !HPF$ ALIGN Y(:) WITH A(:,*) !HPF$ ALIGN X(:) WITH A(*,:) !HPF$ PROCESSORS P(16,16) ! say !HPF$ DISTRIBUTE A(CYCLIC,CYCLIC) ONTO P INTERFACE SUBROUTINE GAUSS_ELIM_90( A, X, Y ) REAL, DIMENSION(:,:), INTENT(INOUT) :: A REAL, DIMENSION(:), INTENT(INOUT) :: X, Y !HPF$ ALIGN Y(:) WITH *A(:,*) !HPF$ ALIGN X(:) WITH *A(:,*) !HPF$ DISTRIBUTE A *(CYCLIC,*) END SUBROUTINE GAUSS_ELIM_90 END INTERFACE print *, "Problem size = ? (>5)" read (*,*) n print *, "Problem size = ", n allocate(a(n,n), x(n), y(n), start(n)) A = 0.1 DO i=1,n START(i) = i A(1+MODULO(i+1,n),i) = i+5 ENDDO Y = 0 DO i = 1, n Y(i) = SUM( A(i,:)*START ) ENDDO CALL GAUSS_ELIM_90( A, X, Y ) DO i = 1, 5 WRITE(*,*) i, X(i) ENDDO DO i = n - 4, n WRITE(*,*) i, X(i) ENDDO END PROGRAM GAUSS_90 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) 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 ! END IF ! 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