       subroutine dtelm6(ioutma,mrows,ncols,varnam,m)

c***********************************************************************
c      DTELM6.FOR: DaTa ELement - Matrix 6xNP
c      Written by Orlando Camargo Rodriguez
c      Faro, Sat Jul 27 19:38:34 WEST 2013
c***********************************************************************
c      Commands should be placed in columns 6-72!
c***********************************************************************

       include 'globli.for'

       character(len=8) varnam
       
       integer*1 i1bit
       integer*2 i2bit
       
       integer*4 i,n
       integer*4 ioutma
       integer*4 iflag
       integer*4 mint8,mint16,mint32,mint64
       integer*4 munt8,munt16,munt32,munt64
       integer*4 msingl,mdble,mimtrx
       integer*4 mrows,ncols
       
       real*8 m(np,6)
        
       mint8    =  1
       munt8    =  2
       mint16   =  3
       munt16   =  4
       mint32   =  5
       munt32   =  6
       msingl   =  7
       mdble    =  9
       mint64   = 12
       munt64   = 13
       mimtrx   = 14
       
       i1bit    = 0
       i2bit    = 6

c      8, 10 and 11 are not used...

       n = mrows*ncols
       
       iflag = 8*n + 56

!     --- Write the data element

!     --- array tag

      write(ioutma) mimtrx
      write(ioutma) iflag

!     --- array flags

      write(ioutma) munt32
      iflag = 8 
      write(ioutma) iflag
      
      write(ioutma) i2bit
      write(ioutma) i1bit
      write(ioutma) i1bit
      iflag = 0
      write(ioutma) iflag
      
!     --- dimensions array

      write(ioutma) mint32
      iflag = 8
      write(ioutma) iflag
      
      write(ioutma) mrows
      write(ioutma) ncols
      
!     --- array name

      write(ioutma) mint8
      iflag = 8
      write(ioutma) iflag

      write(ioutma) varnam

      write(ioutma) mdble
      iflag = 8*n
      write(ioutma) iflag

      do i = 1,ncols
      write (ioutma) m(i,1)
      write (ioutma) m(i,2)
      write (ioutma) m(i,3)
      write (ioutma) m(i,4)
      write (ioutma) m(i,5)
      write (ioutma) m(i,6)
      end do
     
      return 
      
      end
