       program rms_progs

*      Program to compute rms from random values
       implicit none

       character*20 hworld

       real*4 mean   !  Mean value of random numbers
       real*4 xrand  !  Random number being generated
       real*4 sumx, sumxsq ! Sum of xrand and xrand squared
       real*4 rms    ! RMS of sample

       integer*4 num  !  Number of random numbers to generate
       integer*4 i    !  loop counter for random numbers

       hworld = 'Please input number of random numbers'

       print *, hworld

       read(*,*) num
***    Should check num > 0
       sumx = 0
       sumxsq = 0

       do i=1,num
          xrand = rand()
          sumx = sumx + xrand
          sumxsq = sumxsq + xrand**2 
       enddo

       mean = sumx/num
       rms = sqrt((sumxsq - num*mean**2)/(num-1))
       write(*,100) num, mean, rms
 100   format('For ',i4,' values, mean ',F8.3,' RMS ',f8.3)
         
       end
