PROGRAM test IMPLICIT NONE REAL, DIMENSION(:), ALLOCATABLE :: X INTEGER :: I, istat INTERFACE INTEGER FUNCTION NumLessThan(X,val) REAL, DIMENSION(:) :: X REAL :: val END FUNCTION NumLessThan END INTERFACE PRINT*, "Please type in the size of your array" READ*, I ALLOCATE(X(I), STAT=istat) IF (istat .NE. 0) THEN PRINT*, "Allocation request failed" ELSE CALL RANDOM_NUMBER(X) PRINT*, X PRINT*, "There are", NumLessThan(X,0.5), "numbers less than 0.5" DEALLOCATE(X) END IF END PROGRAM test INTEGER FUNCTION NumLessThan(X,val) IMPLICIT NONE REAL, DIMENSION(:) :: X REAL :: val NumLessThan = COUNT(X < val) END FUNCTION NumLessThan