      program main
      implicit double precision(a-h,o-z)
      dimension  x(1500000),amm(1500000),iff(1500000),id(12)
      data id/0,31,59,90,120,151,181,212,243,273,304,334/
      data iyr1,mon1,iday1,ihr1,min1 / 2011,06,01,00,00 /
      data iyr2,mon2,iday2,ihr2,min2 / 2018,10,01,24,00 /
      data e1,e2,an1,an2 / 0.,180, -90.,90. /
      data dp1,dp2 / 0.0, 999./
      data dmag,umag / 0.0, 9.9/
      data izs/ 1 /
      if(izs.ne.0) stime=id(mon1)+iday1-1+ihr1/24.d0+min1/24.d0/60
      n=0
c     open(2,file='/home/ogata/tseis/prm/hypo.dat')
c     open(2,file='/home/ogata/JMApde/work.ts')
      open(12,file='work.etas')
      write(12,*) 'formatted_for_etas'
   10 continue
c     read(2,*,end=15) jyr,mon,jday,jhr,min,sec,e,an,depth,amg
      read(5,*,end=15) jyr,mon,jday,jhr,min,sec,e,an,depth,amg
      n=n+1
      mg=amg *10+0.5+2
      if(n.gt.1500000) stop 10
      if(n.eq.1.and.izs.eq.0) iyr1=iyr
      x(n)=(jyr-iyr1)*365+id(mon)+jday-1+
     &      jhr/24.d0+min/24.d0/60+sec/24.d0/60/60
      do 719 i=iyr1,jyr-1
c For URU'U years
      if(mod(i,4).eq.0) x(n)=x(n)+1
  719 continue
      if(mod(jyr,4).eq.0.and.mon.gt.2) x(n)=x(n)+1
      if(n.eq.1.and.izs.eq.0) stime=x(n)
c     if(izs.eq.0) x(n)=x(n)-stime
      x(n)=x(n)-stime
      t=x(n)
      amm(n)=amg
      iff(n)=jf
      if(amg.lt.amgmin) amgmin=amg
      if(amg.gt.amgmax) amgmax=amg
      depth=-depth
*     write(12,7621) n,e,an,amg,x(n),depth,jyr-1900,mon,jday
      write(12,7621) n,e,an,amg,x(n),depth,jyr,mon,jday
c7621 format(i5,2f12.5,f12.1,f12.5,f5.1,5x,8x,3i3)
*7621 format(i5,2f12.5,f12.1,f12.5,f7.1,3x,8x,3i3)
*7621 format(i5,2f12.5,f12.1,f12.5,f7.1,3x,7x,i4,2i3)
 7621 format(i8,2f12.5,f12.1,f12.5,f8.2,2x,4x,i4,2i3)
c7621 format(i5,2f10.5,f4.1,f12.5,f8.2,2x,i4,2i3)
      go to 10
c  20 continue
   15 continue
      close(2)
      close(12)
      if(iyr2.ne.0)
     & t=(iyr2-iyr1)*365+(iyr2-iyr1)/4+iday2-1+id(mon2)+ihr2/24.-stime
      stop
      end
