INTEGER, PARAMETER :: N=33 INTEGER X(N), M(N), MAX DATA X /0,1,1,0,1,0,0,1,1,1,0,1,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,1,1,1,0,1/ M = 0 MAX=0 I = 0 DO I = I + 1 ! Loop until end of series data IF (X(I)==1) THEN ! Event occur at first time of this spell K = 0 ! Number of days event occur continuosly DO IF (X(I)==0.OR.I==N) THEN ! End of this spell IF (I==N.AND.X(I)/=0) K=K+1 ! For the last spell IF (K/=0) M(K)=M(K)+1 ! Increase for this spell MAX=MAX+1 ! Increase number of spells PRINT*, K, MAX EXIT END IF I = I + 1 K = K + 1 ! How many days of this spell ENDDO ELSE CYCLE END IF IF (I>=N) EXIT ENDDO I=MAX DO IF (M(I)/=0) EXIT ! Determine exactly how many spells I=I-1 ENDDO MAX=I PRINT '(/10I3)', (I,I=1,MAX) ! Spells PRINT '(/10I3)', M(1:MAX) ! Number of days in each spell END