
Subroutine Frequency(X, N, BIN_I, Freq, M, Miss)
! Calculation of Frequency distribution of X(N) array and BIN_I(M+1) array with missing value Miss 
! Input:  BIN_I(M+1) is array of M+1 values of two ends of each interval
!         X(N) data
! Output: 
!         Freq(M) is qfrequency array (%)

Integer :: N, M, i, j, itotal, icouunt
Real :: X(N), BIN_I(M+1), Freq(M), Miss

Do j=1, M
   itotal=0; icouunt=0
   Do i=1, N
      if (X(i) /= Miss) then
         itotal=itotal+1
         if (X(i)>=BIN_I(j).AND.X(i)<BIN_I(j+1)) icouunt=icouunt+1
      endif
   Enddo
   Freq(j)=Real(icouunt)/Real(itotal)*100.
Enddo
End Subroutine Frequency

