PROGRAM Test_Outer IMPLICIT NONE REAL, ALLOCATABLE, DIMENSION(:) :: A REAL, ALLOCATABLE, DIMENSION(:) :: B INTEGER N_elts, istat PRINT*, "Type in size of A vector" READ*, N_elts ALLOCATE(A(N_elts), STAT=istat) IF (istat .NE. 0) THEN PRINT*, "Allocation Error" STOP END IF PRINT*, "Type in size of B vector" READ*, N_elts ALLOCATE(B(N_elts), STAT=istat) IF (istat .NE. 0) THEN PRINT*, "Allocation Error" STOP END IF CALL RANDOM_NUMBER(A) CALL RANDOM_NUMBER(B) PRINT*, "Outer product of A and B is:" PRINT*, Outer(A,B) DEALLOCATE(A) DEALLOCATE(B) CONTAINS FUNCTION Outer(A,B) REAL, INTENT(IN), DIMENSION(:) :: A, B REAL, DIMENSION(SIZE(A),SIZE(B)) :: Outer INTEGER i,j DO i = 1, SIZE(A) DO j = 1, SIZE(B) Outer(i,j) = A(i) * B(j) END DO END DO END FUNCTION Outer END PROGRAM Test_Outer