
      subroutine lineuts(utkmx,htutkmx,ihtsc)
c
c Make line plots with field on x-axis, zp/ht on y-axis, with one curve
c   for each selected ut in mutlines (like lineut, except multiple lines
c   on each frame for each field)
c Locations may be lat,lon (locslt <= 0), or lat,slt (locslt > 0)
c
      include 'timesloc.h'
      dimension utkmx(ntms,kmx,nfplt,nloc),htutkmx(ntms,kmx,nloc),
     +  yaxht(kmx)
      dimension vp(4),pltzp(kmx,nutlines)
      pointer (pplthtut,plthtut(1)), (ppltht,pltht(1))
      character*56 toplab,histlab
      character*80 rec80,lab80,lab80a
      character*16 xlab
      character*1 alpha(26)
      data alpha/'A','B','C','D','E','F','G','H','I','J','K','L','M',
     +   'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'/ 
      data vp /0.10,0.85,0.20,0.90/
      data dum/0./
c
      call agsetc ('LABEL/NAME.','T')
      call agseti ('LINE/NUMBER.', 100)
c     call agsetf ('LINE/CHARACTER.', .025)
      call agsetf ('LINE/CHARACTER.', .020)
      call agseti ('LINE/MAX.',80)
      call agsetc ('LABEL/NAME.','L')
      call agseti ('LINE/NUMBER.', 100)
      call agsetf ('LINE/CHARACTER.', .025)
      call agsetc ('LABEL/NAME.','B')
      call agseti ('LINE/NUMBER.', -100)
      call agsetf ('LINE/CHARACTER.', .025)
      call agseti('INVERT.',1)
c
c lset=2 -> AG will use only fractional part of my set call:
c
      lset = 2
      call set(vp(1),vp(2),vp(3),vp(4),0.,1.,0.,1.,1)
      xmid = 0.5*(vp(1)+vp(2))
      call clearstr(histlab)
      write(histlab,"('HISTORY=',a)") 
     +  histvol(ivol)(1:lenstr(histvol(ivol)))
      lenhist = lenstr(histlab)
      if (ihtsc.le.0) then
        nzp = izprange(2)-izprange(1)+1
      else
        call alloc(ppltht,nhtscale)
        call alloc(pplthtut,nhtscale*nutlines)
      endif
c
c Location loop:
c Two top labels: first shows location, second shows ut's and slt's
c
      do l=1,nloc
        call clearstr(toplab)
        if (gloc(1,l).eq.gmflag.and.gloc(2,l).eq.gmflag) then
          write(toplab,"('GLOBAL MEANS')")
        elseif (gloc(1,l).ne.gmflag.and.gloc(2,l).eq.gmflag) then
          write(toplab,"('LAT= ',f6.2,' ZONAL MEANS')") gloc(1,l)
        else
          if (locslt.le.0) then ! at lat,lon
            write(toplab,"('LAT, LON = ',f6.2,', ',f7.2)")
     +        gloc(1,l),gloc(2,l)
          else ! at lat, fixed local time
            write(toplab,"('LAT, SLT = ',f6.2,', ',f7.2)")
     +        gloc(1,l),gloc(2,l)
          endif
        endif
        if (locslt.le.0) then
          lennam = lenstr(locname(l))
          if (lennam.gt.0) then
            lenlab = lenstr(toplab)
            write(toplab(lenlab+1:lenlab+lennam+3),"(' (',a,')')") 
     +        locname(l)(1:lennam)
          endif
        endif
        lentop = lenstr(toplab)
        call clearstr(rec80)
        write(rec80,"(a)") toplab(1:lenstr(toplab))
c
        call clearstr(lab80)
        write(lab80,"('(',a,'->',a,' = UT ')") alpha(1),alpha(nutlines)
        len = lenstr(lab80)+1
        do it=1,nutlines
          if (mutlines(2,it).le.9) then
            write(lab80(len+1:len+2),"(i1,',')") mutlines(2,it)
          else
            write(lab80(len+1:len+3),"(i2,',')") mutlines(2,it)
          endif
          len = lenstr(lab80)
        enddo
        len = lenstr(lab80)
        if (locslt.le.0) then
          write(lab80(len:len+7),"(') (SLT ')")
          len = len+6
          if (gloc(2,l).ne.gmflag) then
            do it=1,nutlines
              slt = fslt(dum,float(mutlines(2,it)),gloc(2,l),1)
              if (slt.le.9.) then
                write(lab80(len+1:len+4),"(f3.1,',')") slt
              else
                write(lab80(len+1:len+5),"(f4.1,',')") slt
              endif
              len = lenstr(lab80)
            enddo
          endif
        endif
        write(lab80(len:len),"(')')")
c
c Field loop:
c
        do 100 ip=1,nftot      
          if (ifplt(ip).le.0) goto 100
          if (ip.ge.ixui.and.ip.le.ixwi.and.ionvel.eq.2.and.
     +       (gloc(1,l).eq.zmflag.or.gloc(2,l).eq.zmflag)) then
            write(6,"('>>> lineut: zonal or global mean',
     +        ' ion drifts with efield not available')")
            goto 100
          endif
          lenflab = lenstr(labshort(ip))
          call clearstr(xlab)
          if (logloc.gt.0.and.logterp(ip).gt.0) then
            write(xlab,"('LOG10 ',a)") labshort(ip)(1:lenflab)
          else
            write(xlab,"(a)") labshort(ip)(1:lenflab)
          endif
c
c Zp on y-axis:
c
          if (ihtsc.le.0) then
            do k=izprange(1),izprange(2)
              yaxht(k-izprange(1)+1) = 0.
            enddo
            do it=1,nutlines
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c 3/4/94: temp for CSU Lidar comparison:
c         lidar wind is single component with +NE (away from radar),
c           and -SW (toward radar) (must have both u,v flagged)
c See also ht below
c
c             if (ip.ne.ixu.and.ip.ne.ixv) then ! not special case
                do k=izprange(1),izprange(2)
                  pltzp(k-izprange(1)+1,it) = utkmx(it,k,ifplt(ip),l)
                enddo
                do k=izprange(1),izprange(2)
                  yaxht(k-izprange(1)+1) = yaxht(k-izprange(1)+1)+
     +              htutkmx(it,k,l)
                enddo
c             else
c               if (ip.eq.ixu) then
c                 do k=izprange(1),izprange(2)
c                   pltzp(k-izprange(1)+1,it) = 
c    +                (1./sqrt(2.))*utkmx(it,k,ifplt(ip),l)+
c    +                (1./sqrt(2.))*utkmx(it,k,ifplt(ixv),l)
c                 enddo
c               else ! ixv
c                 do k=izprange(1),izprange(2)
c                   pltzp(k-izprange(1)+1,it) = 
c    +                (1./sqrt(2.))*utkmx(it,k,ifplt(ip),l)+
c    +                (1./sqrt(2.))*utkmx(it,k,ifplt(ixu),l)
c                 enddo
c               endif 
c               call clearstr(xlab)
c               write(xlab,"('UN+VN (+NE,-SW)')")
c             endif
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
            enddo
            if (logloc.gt.0.and.logterp(ip).gt.0)
     +        call log10f(pltzp,kmx*nutlines,1.e-20,cpspval)
            call displa(2,1,1)
            call anotat(xlab(1:lenstr(xlab)),'ZP',0,lset,-1,l)
            call ezmxy(gcmzp(izprange(1)),pltzp,nzp,nutlines,nzp,
     +        lab80(1:lenstr(lab80)))
            call wrlablq(toplab(1:lentop),xmid,vp(4)+.07,.017)
            do k=izprange(1),izprange(2)
              yaxht(k-izprange(1)+1) = yaxht(k-izprange(1)+1) /
     +          float(nutlines)
            enddo
            rnd = 10.
            if (gcmzp(izprange(2))-gcmzp(izprange(1)).le.5.) rnd = 5.
            call altyax(nzp,yaxht,gcmzp(izprange(1)),rnd,6)
            call fminmax(pltzp,nzp*nutlines,rmin,rmax,cpspval)
            if (rmin.lt.0..and.rmax.gt.0.) then
              call getset(vl,vr,vb,vt, wl,wr,wb,wt, lty)
              call line(0.,wb,0.,wt)
            endif
            call clearstr(lab80a)
            write(lab80a,"('MIN, MAX = ',2e12.4)") rmin,rmax
            call wrlab(lab80a(1:lenstr(lab80a)),xmid,vp(3)-.11,.012)
            if (labels.gt.1) 
     +        call wrlab(histlab(1:lenhist),xmid,vp(3)-.15,.012)
            call frame
            iframe = iframe+1
            if (iwrascii.gt.0) then
              call wrascii(iwrascii,luascii,pltzp,1,nzp,dum,
     +          gcmzp(izprange(1)),' ','LN(P0/P)',histvol(ivol),
     +          xlab,iframe,rec80,'timesloc',dirascii)
            endif
            write(6,"('lineuts frame ',i3,' field ',a,' ',a)")
     +        iframe,labshort(ip)(1:lenflab),toplab(1:lentop)
          else
c
c Height on y-axis:
c
            do it=1,nutlines
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c 3/4/94: temp for CSU Lidar comparison:
c         lidar wind is single component with +NE (away from radar),
c           and -SW (toward radar) (must have both u,v flagged)
c See also zp above
c
c             if (ip.ne.ixu.and.ip.ne.ixv) then ! not special case
                pltzp(:,it) = utkmx(it,:,ifplt(ip),l)
c             else
c               if (ip.eq.ixu) then
c                 pltzp(:,it) = 
c    +              (1./sqrt(2.))*utkmx(it,:,ifplt(ip),l)+
c    +              (1./sqrt(2.))*utkmx(it,:,ifplt(ixv),l)
c               else
c                 pltzp(:,it) = 
c    +              (1./sqrt(2.))*utkmx(it,:,ifplt(ip),l)+
c    +              (1./sqrt(2.))*utkmx(it,:,ifplt(ixu),l)
c               endif
c               call clearstr(xlab)
c               write(xlab,"('UN+VN (+NE,-SW)')")
c             endif
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
              yaxht(:) = htutkmx(it,:,l)
              if ((ip.lt.ixui.or.ip.gt.ixwi).and.
     +             ip.ne.ixe5577.and.ip.ne.ixe6300.and.ip.ne.ixeo200) 
     +          then
                call intloc(pltzp(1,it),yaxht,kmx,htscale,nhtscale,
     +            logterp(ip),pltht,1,1,nhtscale,ier,cpspval,0)
                do k=1,nhtscale ! plthtut(nhtscale,nutlines)
                  plthtut((it-1)*nhtscale+k) = pltht(k)
                enddo
              elseif (ip.ge.ixui.and.ip.le.ixwi) then
c pointer in common allocated for: htions(ntms,nhtscale,3,nloc)
                do k=1,nhtscale
                  ix = (l-1)*3*nhtscale*ntms+(ip-ixui)*nhtscale*ntms+
     +                 (k-1)*ntms+it
                  plthtut((it-1)*nhtscale+k) = htions(ix)
                enddo
              elseif (ip.eq.ixe5577) then
c pointer in common allocated for: hte5577(ntms,nhtscale,nloc)
                do k=1,nhtscale
                  ix = (l-1)*nhtscale*ntms+(k-1)*ntms+it
                  plthtut((it-1)*nhtscale+k) = hte5577(ix)
                enddo
              elseif (ip.eq.ixe6300) then
c pointer in common allocated for: hte6300(ntms,nhtscale,nloc)
                do k=1,nhtscale
                  ix = (l-1)*nhtscale*ntms+(k-1)*ntms+it
                  plthtut((it-1)*nhtscale+k) = hte6300(ix)
                enddo
              elseif (ip.eq.ixeo200) then
c pointer in common allocated for: hteo200(ntms,nhtscale,nloc)
                do k=1,nhtscale
                  ix = (l-1)*nhtscale*ntms+(k-1)*ntms+it
                  plthtut((it-1)*nhtscale+k) = hteo200(ix)
                enddo
              else
                write(6,"('lineuts: unsupported ip=',i3)") ip
              endif
            enddo
            if (logloc.gt.0.and.logterp(ip).gt.0)
     +        call log10f(plthtut,nhtscale*nutlines,1.e-20,cpspval)
            call displa(2,1,1)
            call anotat(xlab(1:lenstr(xlab)),'HEIGHT (KM)',0,lset,-1,l)
            call ezmxy(htscale,plthtut,nhtscale,nutlines,nhtscale,
     +        lab80(1:lenstr(lab80)))
            call wrlablq(toplab(1:lentop),xmid,vp(4)+.07,.017)
            call fminmax(plthtut,nhtscale*nutlines,rmin,rmax,cpspval)
            if (rmin.lt.0..and.rmax.gt.0.) then
              call getset(vl,vr,vb,vt, wl,wr,wb,wt, lty)
              call line(0.,wb,0.,wt)
            endif
            call clearstr(lab80a)
            write(lab80a,"('MIN, MAX = ',2e12.4)") rmin,rmax
            call wrlab(lab80a(1:lenstr(lab80a)),xmid,vp(3)-.11,.012)
            call wrlab(histlab(1:lenhist),xmid,vp(3)-.15,.012)
            call frame
            iframe = iframe+1
            if (iwrascii.gt.0) then
              call wrascii(iwrascii,luascii,pltht,1,nhtscale,dum,
     +          htscale,' ','HEIGHT (KM)',histvol(ivol),
     +          xlab,iframe,rec80,'timesloc',dirascii)
            endif
            write(6,"('lineuts frame ',i3,' field ',a,' ',a,
     +        ' (htscale)')")
     +        iframe,labshort(ip)(1:lenflab),toplab(1:lentop)
          endif
 100    continue
c
c End location loop:
      enddo
      if (ihtsc.gt.0) then
        call hpdeallc(ppltht,ier,1)
        call hpdeallc(pplthtut,ier,1)
      endif
      call agseti('INVERT.',0)
c
      return
      end
