program grid
use sep
implicit none
real,allocatable,dimension(:,:)::data
integer::i,n2,n1=2,f,j,nx,ny
real:: dy,dx
logical:: add
call sep_init()
call from_param('nx',nx,176)
call from_param('ny',ny,13)
call from_param('dy',dy,140.)
call from_param('dx',dx,10.)
call from_param('add',add,.false.)
n2=nx*ny
call to_history('n1',n1);call to_history('d1',1.);call to_history('o1',0.)
call to_history('n2',n2);call to_history('d2',1.);call to_history('o2',0.)
call to_history('n3',1);call to_history('d3',1.);call to_history('o3',0.)
call to_history('esize',4)
call sep_close()
write(0,*) 'nx,ny',nx,ny
write(0,*) 'n2,n1',n2,n1
write(0,*) 'dx,dy',dx,dy
write(0,*) 'add',add
allocate(data(n1,n2));data=0.

if (add) call sep_read(data)
f=1
do i=1,ny
   do j=1,nx
      data(1,f)=data(1,n1)+(j-1)*dx
      data(2,f)=data(2,n1)+(i-1)*dy
      f=f+1
   end do
end do

call sep_write(data)
end program grid
