      program cateqmn
C........................................................Dec 2022
C Catalog of monthly Mwmax >=4.5 days 1964-2022
C Area:glats  -19: -2 (S), glons 152-169E (Australia)
C
       dimension IM(12)
      character*64 infile,outfile,txt
	character*4 AYEAR
	character*2 AMN,ADY
	DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
       infile='d:\Apkp\Equak\M45\eqYEAR.txt'
	outfile='cateqmn.txt'
	OPEN(11,file=outfile)
   30 format(I4,4(1X,I2),1X,F5.2,1X,F8.4,1X,F9.4,1X,F6.2
     +,1X,F5.2)
   31 format(1X,F8.3,1X,I3,2(1X,A2),1X,F5.2,2(1X,F6.2),1X,F5.1,1X,F5.2
     +,2(1X,I3))
C
      ndy=0
      DO 100 iyear=1964,2022
	call blet4(iyear,AYEAR)
	infile(21:24)=AYEAR
	OPEN(10,file=infile,action='READ')
	do k=1,13
	read(10,*) txt  ! title lines
	enddo
		iyr=iyear-iyear/100*100
		ryr=float(iyr)
		if(int(ryr/4.)*4.eq.iyr) THEN 
	ndr=366
	im(2)=29
	                          ELSE
	ndr=365
	im(2)=28
	ENDIF
C
       del=1./ndr
C
      DO 101 imn=1,12
      amax=0.
	kdym=0
	rutm=0.
	alatm=0.
	alonm=0.
	depm=0.
	icnt=0
	call blet2(imn,AMN)
    1	READ(10,30,end=51) kyear,kmn,kdy,kut,kmm,rss,alat,alon,dep,amw	
      rut=kut+(kmm+rss/60.)/60.
	if (kmn.eq.imn) then
	icnt=icnt+1
	if (amax.lt.amw) then
	amax=amw
	kdym=kdy
	rutm=rut
	alatm=alat
	alonm=alon
	depm=dep
	endif
	goto 1
	                   else
	backspace(10)
	lda=ndoy(iyr,imn,kdym)
	ryear=iyear+(lda-1)*del
      call blet2(kdym,ADY)
C
      if (rutm.gt.23.5) then
	rutm=0.0
	lda=lda+1
	mdy=kdym+1
	mmn=imn
	if (mdy.gt.im(imn)) then
	mmn=imn+1
	mdy=1
	endif
	call blet2(mmn,AMN)
	call blet2(mdy,ADY)
	endif
C
	ndy=ndy+1
	write(*,31) ryear,lda,AMN,ADY,rutm,alatm,alonm,depm,amax,icnt,ndy
	write(11,31) ryear,lda,AMN,ADY,rutm,alatm,alonm,depm,amax,icnt,ndy
	goto 101
	endif
  101 CONTINUE
   51	close(10)
  100	CONTINUE
      close(11)
	pause ' '
	STOP
	END