PROGRAM arraymin IMPLICIT NONE INTEGER :: i, N DOUBLE PRECISION, ALLOCATABLE :: X(:) DOUBLE PRECISION :: mymin 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 min using a loop ! mymin = X(1) DO i = 2, N IF (X(i) .lt. mymin) mymin = X(i) END DO PRINT *, 'min = ', mymin, MINVAL(X) ! print both answers for comparison PRINT *, 'ERROR = ', mymin - MINVAL(X) DEALLOCATE(X) END PROGRAM arraymin