     ! Gan event cho cac thanh phan X(i):
     ! if (Less=true):
     !               - if (X(i)<=Threshold): Y(i)=Score; if (X(i)>Threshold): Y(i)=0
     ! if (Less=false):
     !               - if (X(i)>=Threshold): Y(i)=Score; if (X(i)<Threshold): Y(i)=0
     Subroutine Events (X,Y,N,Threshold,Score,Less,Miss)
        Integer :: N,i
        Real :: X(N),Y(N), Threshold, Score, Miss
        Logical :: Less

        Y(:)=Miss
        Do i=1,N
           if (Less) then
              if (X(i)/=Miss.AND.X(i)<=Threshold) then
                 Y(i)=Score
              elseif (X(i)/=Miss.AND.X(i)>Threshold) then
                 Y(i)=0.
              endif
           else
              if (X(i)/=Miss.AND.X(i)>=Threshold) then
                 Y(i)=Score
              elseif (X(i)/=Miss.AND.X(i)<Threshold) then
                 Y(i)=0.
              endif
           endif
        Enddo
     End Subroutine Events
