forlatlon0.f


c     read gh##0
C      cut data during course change dhead>10
c
c
c      data read gh##0
c
c     **** data ****
c     iyr:Year, jdy:Julian day, min:time(GMT in minutes),
c     alat(latitude TKY deg), alon(longitude TKY deg),
c     spd:speed, hg:course(clockwise from North), 
c     idpc:corrected depth, mgt:total magnetic force,
c     mga:magnetic anomaly, gr:gravity reading, gt1:absolute gravity value,
c     ga:free-air anomaly
c
      dimension iflg(30000),jdy(30000),min(30000),nn(30000)
      dimension hdg(30000),spd(30000)
      dimension gto(30000),alt(30000),ga(30000)
c
      dimension iyr(30000),aln(30000),idp(30000),mgt(30000)
      dimension mga(30000),gr(30000)
c
      open(10,file='D:\GHdata2008\gh90a.datas01',status='old')
      open(20,file='D:\GHdata2008\gh90a.datas1')
c
      i=0
    1 continue
         i=i+1
         read(10,*,end=99) nn(i),iyr(i),jdy(i),min(i),alt(i),aln(i),
     +   spd(i),hdg(i),idp(i),mgt(i),mga(i),
     +   gr(i),gto(i),ga(i),iflg(i)
         go to 1
   99 close(10)
      jnum=i
      write(6,*) jnum
c
      do 10 k=1, jnum
         if(iflg(k).eq.2 .or. iflg(k).eq.0) then
         if(nn(k).ne.0) then
          write(20,207) nn(k),iyr(k),jdy(k),min(k),alt(k),aln(k),
     +                spd(k),hdg(k),idp(k),mgt(k),mga(k),
     +                gr(k),gto(k),ga(k),iflg(k)
         go to 10
         end if
         end if
         if(iflg(k).eq.1) then
         iflg(k+1)=2
         write(6,*) k,jdy(k),min(k)
         go to 10
         end if
   10 continue
      close(20)
  207 format(i7,i3,i4,i5,f10.5,f10.5,f6.2,f6.1,i6,i6,i6,f8.1,
     +   f10.1,f8.1,i2)
      stop
      end