
      subroutine lineut(fields,utkmx,htutkmx,it,ihtsc)
c
c Make line plots at current time (it) and selected locations
c (field on x-axis, zp/ht on y-axis):
c
      include 'tigcmloc.h'
      dimension fields(imx,kmx,jmx,nfget), utkmx(ntms,kmx,nfplt,nloc),
     +  htutkmx(ntms,kmx,nloc),yaxht(kmx)
      dimension vp(4),pltzp(kmx)
      pointer (ppltht,pltht(1))
      character*56 toplab,histlab,lab56
      character*80 rec80
      character*16 xlab
      data vp /0.10,0.85,0.20,0.90/
c
      call agsetc ('LABEL/NAME.','T')
      call agseti ('LINE/NUMBER.', 100)
      call agsetf ('LINE/CHARACTER.', .025)
      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)
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)
      endif
c
c Location loop:
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  UT=',f4.1,' (',
     +      i2,',',i2,',',i2,')')") ut(it),(mtimes(i,it),i=1,3)
        elseif (gloc(1,l).ne.gmflag.and.gloc(2,l).eq.gmflag) then
          write(toplab,"('LAT= ',f6.2,' LON=ZONAL MEANS  UT=',f4.1,
     +      ' (',i2,',',i2,',',i2,')')") 
     +      gloc(1,l),ut(it),(mtimes(i,it),i=1,3)
        else
          write(toplab,"('LAT,LON = ',f6.2,',',f7.2,' UT=',f4.1,
     +      ' (',i2,',',i2,',',i2,')')") 
     +      gloc(1,l),gloc(2,l),ut(it),(mtimes(i,it),i=1,3)
        endif
        lentop = lenstr(toplab)
        call clearstr(rec80)
        write(rec80,"(a)") toplab(1:lenstr(toplab))
c
c Field loop:
c
        do 100 ip=1,nftot      
          if (ifplt(ip).le.0) goto 100
          if (ip.eq.ixfof2.or.ip.eq.ixhmf2) goto 100
          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)
              pltzp(k-izprange(1)+1) = utkmx(it,k,ifplt(ip),l)
            enddo
            if (logloc.gt.0.and.logterp(ip).gt.0)
     +        call log10f(pltzp,kmx,1.e-20,cpspval)
            call displa(2,1,1)
            call anotat(xlab(1:lenstr(xlab)),'ZP',0,lset,-1,l)
            call ezxy(pltzp,gcmzp(izprange(1)),nzp,toplab(1:lentop))
            do k=izprange(1),izprange(2)
              yaxht(k-izprange(1)+1) = htutkmx(it,k,l)
            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,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(lab56)
            write(lab56,"('MIN, MAX = ',2e12.4)") rmin,rmax
            call wrlab(lab56(1:lenstr(lab56)),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,pltzp,1,nzp,dum,
     +          gcmzp(izprange(1)),' ','LN(P0/P)',histvol(ivol),
     +          xlab,iframe,rec80,'tigcmloc',dirascii)
            endif
            write(6,"('lineut frame ',i3,' field ',a,' ',a)")
     +        iframe,xlab(1:lenstr(xlab)),toplab(1:lentop)
          else
c
c Height on y-axis:
c
            pltzp(:) = utkmx(it,:,ifplt(ip),l)
            yaxht(:) = htutkmx(it,:,l)
            call intloc(pltzp,yaxht,kmx,htscale,nhtscale,logterp(ip),
     +        pltht,1,1,nhtscale,ier,cpspval,0)
            if (logloc.gt.0.and.logterp(ip).gt.0)
     +        call log10f(pltht,nhtscale,1.e-20,cpspval)
            call displa(2,1,1)
            call anotat(xlab(1:lenstr(xlab)),'HEIGHT (KM)',0,lset,-1,l)
            call ezxy(pltht,htscale,nhtscale,toplab(1:lentop))
            call fminmax(pltht,nhtscale,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(lab56)
            write(lab56,"('MIN, MAX = ',2e12.4)") rmin,rmax
            call wrlab(lab56(1:lenstr(lab56)),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,'tigcmloc',dirascii)
            endif
            write(6,"('lineut frame ',i3,' field ',a,' ',a,
     +        ' (htscale)')")
     +        iframe,xlab(1:lenstr(xlab)),toplab(1:lentop)
          endif
 100    continue
c
c End location loop:
      enddo
      if (ihtsc.gt.0) call hpdeallc(ppltht,ier,1)
c
      return
      end
