# lcase
# '#' @
# QSUB -r ds7120 -q reg -lT 200
# QSUB -eo
# QSUB -s /bin/csh
ja
cd $TMPDIR

msread fort.11 /DSS/Y05279 
cat << EOF > tsrc.f
      program mur
c
c read murakami one degree grids of GATE satellite data from NCAR mass store
c See details in Murakami (1979; Mon. Wea. Rev., Vol. 107, 994-1013)
c data on one observation of Sept. 7, 9 and 18 may be wrong. Kuan-Man Xu
c
      dimension irdta(46,28,8),itime(8),miss(8)
      nr=0
   10 call rdir(11,iday,irdta,itime,miss)
      if(iday.ge.99999) go to 90
      nr=nr+1
      do i = 1, 8
C   read only 16 grids between 22-25 E and 7-10 N square 
          write(16,1001)iday,itime(i),miss(i),((irdta(j,k,i),
     2             j=26,29),k=13,16)
      enddo
 1001 format(' day ',i6, i4, i2, 16i3)
      go to 10
   90 continue
      write(16,1002)nr
 1002 format(' recs = ',i8)
      end
      subroutine rdir(iun,iday,irdta,itime,miss)
c
c input args
c   iun -          ftn unit number
c
c returned args
c   iday -         day+74000 of the year (99999 indicates end of data)
c   irdta(i,j,k)-  array of ir count
c                       i - lon 50W to 5W, by 1 deg
c                       j - lat 5S to 22N, by 1 deg
c                       k - hour of ob
c   itime(k)-             GMT time
c   miss(k)-              0=normal, 1=missing ob at time itime(k)
c
      parameter (lth=400)
      dimension ibf(lth),irdta(46,28,8),miss(8),itime(8)
    9 continue
      do 16 irpt=1,2
      bufferin(iun,1)(ibf,ibf(lth))
      if(unit(iun))12,13,14
   14 stop 14
   12 continue
      do 15 k=1,4
      is=88*(k-1)+1
      ioff=60*(is-1)
      kk=k+4*(irpt-1)
c     iday=ibf(is)
      call gbyte(ibf,iday,ioff,60)
c     itime(kk)=ibf(is+1)
      call gbyte(ibf,itime(kk),ioff+60,60)
c     call gbyte(ibf(is+2),miss(kk),0,1)
      call gbyte(ibf,miss(kk),ioff+120,1)
c     call gbytes(ibf(is+2),irdta(1,1,kk),1,4,0,1288)
      call gbytes(ibf,irdta(1,1,kk),ioff+121,4,0,1288)
   15 continue
   16 continue
      bufferin(iun,1)(ibf,ibf(lth))
      if(unit(iun))17,18,17
   17 stop 17
   18 return
   13 continue
      iday=99999
      return
      end
EOF
 
cft77 -e h tsrc.f
 
segldr tsrc.o -L /lib,/usr/lib,/usr/local/lib -l ncarm,ncaro
a.out
netug FLNM=fort.16 flnm=GATE.olr DF=tr dt=tr
ja -s
