      program formatagrid
C program to structure an ascii grid for MODFLOW formatted input
C reads a matrix, then assigns correct formatting and write result 
      parameter(nrowmax=200,ncolmax=200)
C
      real*8 deltax,deltay
      real*8 floatarrayx,floatarrayy
      integer nrows,ncols
      dimension floatarrayx(ncolmax)
      dimension floatarrayy(ncolmax)
      character*10 ch1,ch2,ch3,ch4,ch5,ch6,ch7
C
C assume redirection is used for I/O 
C
      read(*,*)nrows,ncols
      read(*,*)deltay,deltax
C build deltay and deltax vectors
      do 1001 irow=1,nrows
        floatarrayy(irow) = deltay
 1001 continue
      do 1002 jcol=1,ncols
        floatarrayx(jcol) = deltax
 1002 continue
      write(*,*)'irow value ',irow
      write(*,*)'jcol value ',jcol
      write(*,*)'nrows :',nrows
      write(*,*)'ncols :',ncols
      write(*,*)'spacing between rows    :',deltay
      write(*,*)'spacing between columns :',deltax
C typical formatting directives for 1Darray reader
C 234567890123456789012345678901234567890123456789012345678901234567890
      ch1='       11'
      ch2='      1.00'
      ch3=' (10G10.3)'
      ch4='          '
      ch5='         0'
      ch6='     DELR-'
      ch7='         1'
      write(*,*)ch1 // ch2 // ch3 // ch4 // ch5 // ch6 // ch7
C write the boundary array
      write(*,9001)(floatarrayy(irow),irow=1,nrows)
C typical formatting directives for 1Darray reader
C 234567890123456789012345678901234567890123456789012345678901234567890
      ch1='       11'
      ch2='      1.00'
      ch3=' (10G10.3)'
      ch4='          '
      ch5='         0'
      ch6='     DELC-'
      ch7='         1'
      write(*,*)ch1 // ch2 // ch3 // ch4 // ch5 // ch6 // ch7
      write(*,9001)(floatarrayx(jcol),jcol=1,ncols)
      stop
 9001 format(10(1x,g9.3))
 9002 format(10(1x,i2))
      end
