C--------------------------------------------------------------------------
      subroutine tgrf3d_elvis(
     >   inumx,ntr,ilxfot,xarry,datx,
     >   tvec,datf,elvis_title,
     >   xlab,xun,tlab,tun,flab,fun)
C
C  dmc -- elvis plotting interface -- Aug 2004
C
      use conplot
      use trgraf_elvis, only: elvis_check

      implicit NONE
C
      integer inumx                     ! no. of x pts
      integer ntr                       ! no. of t pts
      logical ilxfot                    ! .TRUE. if x varies in t
C
      real xarry(inumx)                 ! x -- if no t variation
      real datx(inumx,ntr)              ! x -- with t variation
C
      real tvec(ntr)                    ! timebase (or other variable)
C
      real datf(inumx,ntr)              ! data to plot
C
      character*(*) elvis_title         ! title label
      character*(*) xlab,tlab,flab      ! x, t, data labels
      character*(*) xun,tun,fun         ! x, t, data units labels
C
C-------------------------------------------------------------
C  real*8 buffers
C
      real*8, dimension(:,:), allocatable :: xr8,fr8
      real*8, dimension(:), allocatable :: timer8
C
      integer j
      integer it,id
      integer istat
      real*8 plotloc(2), lbloc(2)
      real*8 width, height, h
      real*8 timeval
C
      include 'ELVIS_H'
C-------------------------------------------------------------
C
      if(do_elvis) then
         istat = ef_free()
         allocate(xr8(inumx,ntr),fr8(inumx,ntr),timer8(ntr))
C
         timer8=tvec
         fr8=datf
         if(ilxfot) then
            xr8=datx
         else
            do it=1,ntr
               xr8(1:inumx,it)=xarry
            enddo
         endif
C
         istat = ef_graphwindowcreate(wname, 1, 1)
         call trgraf_gname_get(gname)
         istat = ef_graphcreate(gname, E_SURFACE)
         istat = ef_graphwindowaddgraph(wname, gname, 0, 0)
C 
         do it=1,ntr
            call trgraf_dname_get(dname)
            id = ef_fxtdatasetcreate(dname, inumx, 
     >         xr8(1:inumx,it), fr8(1:inumx,it), timer8(it))
            istat = ef_graphaddfxdatasetid(gname, id)
         enddo
C
         istat = ef_graphSetXLabel(gname,trim(xlab)//' '//trim(xun))
         istat = ef_graphSetYLabel(gname,trim(flab)//' '//trim(fun))
         istat = ef_graphSetIndexLabel(gname,
     >      trim(tlab)//' '//trim(tun))
C
         call trgraf_sname_get(sname)
         istat = ef_graphSetTitle(trim(gname),trim(elvis_title),
     >        trim(sname))
C
         istat = ef_graphWindowDisplay(wname)
         call elvis_check(istat,'tgrf3d_elvis->ef_graphWindowDisplay')
C
         deallocate(xr8,fr8,timer8)
      endif
      return
      end
