PROGRAM arraymin IMPLICIT NONE INTEGER :: i, N DOUBLE PRECISION, ALLOCATABLE :: X(:) DOUBLE PRECISION :: myprod PRINT *, 'Enter the number of elements in the vector (N >= 1)' READ *, N IF (N .LT. 1) THEN PRINT *, 'FATAL ERROR: N must be strictly positive!' STOP END IF ALLOCATE(X(N)) ! get the space I need CALL RANDOM_NUMBER(X) ! initialize X ! ! Compute the produce of all elts in X using a loop ! myprod = X(1) DO i = 2, N myprod = myprod * X(i) END DO PRINT *, 'prod = ', myprod, PRODUCT(X) ! print both answers for comparison PRINT *, 'ERROR = ', myprod - PRODUCT(X) DEALLOCATE(X) END PROGRAM arraymin