c subroutine rduars(flnm,lu,iseclim,mxpts, + satut,satlat,satlon,satalt,npts,iydsat,ier) c c Read uars sat attitude file from file flnm on unit lu, limited to times c between iseclim(1) and iseclim(2). c (adapted 2/94 from ~/uars/timessat/rdapprox.f) c c On input: c flnm = mss path to sat file c lu = fort logical unit to which flnm may be attached c iseclim(2) = ut limits within which to read sat data (seconds) c mxpts = dimension of sat data c On output: c satut,satlat,satlon,satalt have been defined up to npts c npts = number of points read c iydsat = year-day of sat data c ier = 0 if no errors c character*(*) flnm character*80 rec80,errmsg,flnm1,disk logical isopen,exists dimension satut(mxpts),satlat(mxpts),satlon(mxpts),satalt(mxpts), + iseclim(2) data irw/1/ save irw c c Get sat attitude file from mss: c (if not already obtained in previous call) c ier = 0 len = lenstr(flnm) inquire(lu,opened=isopen) if (isopen) then inquire(lu,name=flnm1) if (flnm1(1:lenstr(flnm1)).ne.flnm(1:lenstr(flnm))) then close(lu) isopen = .false. endif endif if (.not.isopen) then call getvol(flnm,"/usr/tmp/TIGCM",lu,isopen,iier) if (iier.ne.0) then write(6,"('>>> rduars: error ',i3,' from getms')") iier ier = 1 return endif endif if (irw.gt.0) then c c 4 line header (get iydsat from first line): c read(lu,"(28x,i5,16x,i4)",end=901) iyear,iday iydsat = (iyear-iyear/1900*1900)*1000+iday do ii=1,3 read(lu,"(a)",end=901) rec80 enddo endif c c Read data between times iseclim(1) and iseclim(2): c (Time limits from input are in seconds (iseclim), and sat time on file c is in msec) c npts = 0 irec = 0 do ii=1,100000 read(lu,"(i9,3f8.2)",end=901) msec,rlat,rlon,ralt irec = irec+1 isatsec = msec/1000 ! msec to sec if (isatsec.lt.iseclim(1)) goto 100 if (isatsec.gt.iseclim(2)) goto 200 npts = npts+1 if (npts.eq.1) irec0 = irec if (npts.gt.mxpts) then write(6,"('>>> rduars: reached mxpts=',i6, + ' -- returning')") mxpts ier = 1 return endif satlat(npts) = rlat satlon(npts) = rlon if (satlon(npts).ge.180.) satlon(npts) = satlon(npts) - 360. satalt(npts) = ralt satut(npts) = float(isatsec)/3600. 100 continue enddo 901 write(6,"('rduars: EOF on file ',a,' npts = ',i5)") + flnm(1:len),npts rewind lu irw = 1 return 200 continue write(6,"(' ')") write(6,"('rduars returning with npts=',i4)") npts write(6,"(' iseclim=',2i10,' satut(1),(npts)=',2f8.4)") + iseclim,satut(1),satut(npts) write(6,"(' satlat,lon (1st)=',f6.2,f7.2, + ' satlat,lon (last)=',f6.2,f7.2)") satlat(1),satlon(1), + satlat(npts),satlon(npts) write(6,"(' irec0=',i5,' irecn=',i5)") irec0,irec-1 rewind lu irw = 0 return end