subroutine ReadOutputField
use mod_parameters
use mod_interpolation
implicit none
integer::i,j,k
real::x,y
logical::buildGrid
!buildGrid=.true.
if(doCIV2) then
print*,'We use the civ2 output grid'
endif
!if((m*n)==0) then
if(gridPatch=='n') then
gridPatch='none'
endif
if(gridPatch/='none') then
open(unit=9,file=trim(adjustl(gridPatch)),form='formatted',status='old',ACTION='READ' )
print*,'Open Patch grid: ',trim(adjustl(gridPatch))
read(9,*) mg,ng
nb_vec_patch=mg*ng
m=mg
n=ng
mgrid_patch=m
ngrid_patch=n
print*,mg,ng
allocate(VD(nb_vec_patch,15))
VD=0.
do i=1,(mg*ng)
read(9,*)VD(i,1:2)
print*,vd(i,1:2)
enddo
close(9)
! buildGrid=.false.
! else
! open(unit=13,file='interGrid',form='formatted',status='old',ACTION='READ',err=1000)
! print*,'Open file grid: ',trim(adjustl(gridfilename))
! read(13,*) mg,ng
! nb_vec_patch=mg*ng
! !print*,mg,ng
! allocate(VD(nb_vec_patch,9))
! VD=0.
! do i=1,(mg*ng)
! read(13,*)VD(i,1:2)
! enddo
! close(13)
! buildgrid=.false.
!1000 m=50
! n=50
!endif
!if(buildgrid) then
else
xmin_f=minx
xmax_f=maxx
ymin_f=miny
ymax_f=maxy
m=mgrid_patch
n=ngrid_patch
print*,'Building a regular grid m n',m,n,'minmax',xmin_f,xmax_f,ymin_f,ymax_f
! contruct a regular grid
! nb_vec_patch=np
nb_vec_patch=m*n
allocate(VD(nb_vec_patch,15))
VD=0.
k=0
do j=1,n
y=ymin_f+(j-1)*(ymax_f-ymin_f)/float(n-1)
do i=1,m
x=xmin_f+(i-1)*(xmax_f-xmin_f)/float(m-1)
k=k+1
VD(k,1)=x
VD(k,2)=y
! print*,x,y,ymin_f,float(n-1)
enddo
enddo
!VD(1:nb_vec_patch,1:2)= V(1:nb_vec_patch,1:2)
endif
end subroutine ReadOutputField