PROGRAM Main IMPLICIT NONE INTEGER :: i, j, n, ierr REAL, DIMENSION(:,:), ALLOCATABLE :: A REAL, DIMENSION(:), ALLOCATABLE :: S !HPF$ PROCESSORS P(4) !HPF$ DISTRIBUTE A(*,CYCLIC) ONTO P !HPF$ DISTRIBUTE S(CYCLIC) ONTO P PRINT*, "Type in array size" READ*, n ALLOCATE(A(n,n),STAT=ierr) IF (ierr .EQ. 0) THEN ALLOCATE(S(n),STAT=ierr) IF (ierr .EQ. 0) THEN S = 0 CALL RANDOM_NUMBER(A) DO j=1,n DO i=1,n S(j) = S(j) + A(i,j) END DO END DO PRINT*, S DEALLOCATE(S) END IF DEALLOCATE(A) END IF END PROGRAM
Second part, marks:
REAL, DIMENSION(:,:), ALLOCATABLE :: A REAL, DIMENSION(:), ALLOCATABLE :: Pr !HPF$ PROCESSORS Q(4) !HPF$ DISTRIBUTE A(CYCLIC,*) ONTO Q !HPF$ DISTRIBUTE Pr(CYCLIC) ONTO Q PRINT*, "Type in array size" READ*, n ALLOCATE(A(n,n),STAT=ierr) IF (ierr .EQ. 0) THEN ALLOCATE(Pr(n),STAT=ierr) IF (ierr .EQ. 0) THEN Pr = 1 CALL RANDOM_NUMBER(A) DO i=1,n DO j=1,n Pr(i) = Pr(i) * A(i,j) END DO END DO PRINT*, Pr DEALLOCATE(Pr) END IF DEALLOCATE(A) END IF END PROGRAM