      SUBROUTINE Domega1_write(casco_iter,kd,seckd,iter,delt,DomegaDxi,
     $                        lrvs,nr,nsteps)

C Include file for parameter statements
      include 'CASCO.DIM'
C Fixed global variables
      integer casco_iter
      integer kd, iter
      real    seckd
      real    delt
      integer lrvs(nndim)
      integer nr, nsteps
      real DomegaDxi(nrdim,nstepdim)

      integer kd0
      real    sec0
      SAVE   kd0, sec0

      character*120 fname
      character*10 citer
      integer istart, iend

      integer lun, i,n  
      real    dt

      lun = 51  

c     fname = 'domegadxi.out'

      if(ITER.eq.0) then 

	  write(*,*)'Domega_write: nsteps,nr ',nsteps,nr
	  write(*,*)'casco_iter ', casco_iter
          write(citer,'(i2.2)')casco_iter
          call cstring(citer,istart,iend)
          fname =  'domegadxi.'//citer(istart:iend)//'.out'
	  write(*,*)'Output file name ',fname 
	  open(lun,file=fname,status='unknown')
	  write(lun,*)nr

C  save time at start of run 
          kd0 = kd
          sec0 = seckd 

      elseif(ITER.gt.0) then
	  dt = (kd - kd0)*24*3600. + (seckd - sec0)
          write(lun,*)kd, seckd,dt,iter
          do i = 1,nr 
             n = lrvs(i)
             write(lun,*)n,DomegaDxi(i,iter)
          enddo
      elseif(ITER.eq.-1) then
	 close(lun)
      else 
	 write(*,*)'Domega_write  Error:  ITER < -1.  = ',ITER
	 stop
      endif

      RETURN
      END

      SUBROUTINE Domega2_write(casco_iter,DomegaDrho,lrvs,nr,ntbc)

C Include file for parameter statements
      include 'CASCO.DIM'
C Fixed global variables
      integer casco_iter
      integer lrvs(nndim)
      integer nr, ntbc
      real DomegaDrho(nrdim,ntbcdim)

      integer lun, i,n,j   

      character*120 fname
      character*10 citer
      integer istart, iend

      lun = 52  

        write(citer,'(i2.2)')casco_iter
        call cstring(citer,istart,iend)
        fname =  'domegadrho.'//citer(istart:iend)//'.out'

	  write(*,*)'Domega2_write: ntbc,nr ',ntbc,nr
	  write(*,*)'casco_iter ', casco_iter
	  write(*,*)'Output file name ',fname 
	  open(lun,file=fname,status='unknown')
	  write(lun,*)nr

	  do j = ntbc,1,-1 
             write(lun,*)j 
             do i = 1,nr 
                n = lrvs(i)
                write(lun,*)n,DomegaDrho(i,j)
             enddo
	  enddo
	  close(lun)

      RETURN
      END
