subroutine c_splot3D(pname,X1,X2,Y,xmin,xmax,ymin,ymax,nosurface,wlines,nlines)
integer :: i,j,Nx1,Nx2,count,Nl
character(len=*) :: pname
real(8),dimension(:) :: X1
real(8),dimension(:) :: X2
complex(8),dimension(size(X1),size(X2)) :: Y
real(8),optional :: xmin,xmax,ymin,ymax
integer,optional :: nlines
logical,optional :: wlines,nosurface
logical :: nosurface_
real(8) :: X1min,X1max
real(8) :: X2min,X2max
character(len=12) :: minx,miny,maxx,maxy
character(len=:),allocatable :: fname,dname
fname=get_filename(reg(pname))
dname=get_filepath(reg(pname))
nosurface_=.false.;if(present(nosurface))nosurface_=nosurface
Nx1=size(X1) ; Nx2=size(X2)
Nl=5; if(present(nlines))Nl=nlines
open(619,file=dname//"re_"//fname)
open(719,file=dname//"im_"//fname)
if(present(wlines))then
open(620,file=dname//"re_"//fname//"_withlines")
open(720,file=dname//"im_"//fname//"_withlines")
endif
do i=1,Nx1
count=mod(i,Nl)
do j=1,Nx2
write(619,*)X1(i),X2(j),dreal(Y(i,j))
write(719,*)X1(i),X2(j),dimag(Y(i,j))
if(present(wlines).AND.count==0)write(620,*)X1(i),X2(j),dreal(Y(i,j))
if(present(wlines).AND.count==0)write(720,*)X1(i),X2(j),dimag(Y(i,j))
enddo
write(619,*)""
write(719,*)""
if(present(wlines))then
write(620,*)""
write(620,*)""
write(720,*)""
write(720,*)""
endif
enddo
close(619)
close(719)
X1min=minval(X1);if(present(xmin))X1min=xmin
X1max=maxval(X1);if(present(xmax))X1max=xmax
X2min=minval(X2);if(present(ymin))X2min=ymin
X2max=maxval(X2);if(present(ymax))X2max=ymax
write(minx,"(f12.4)")X1min
write(maxx,"(f12.4)")X1max
write(miny,"(f12.4)")X2min
write(maxy,"(f12.4)")X2max
if(present(wlines))then
close(620)
close(720)
endif
!Re:
open(10,file=pname//"_re_map.gp")
write(10,*)"set title 'Re_"//fname//"'"
write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//minx//":"//maxx//"]"
write(10,*)"set yrange ["//miny//":"//maxy//"]"
write(10,*)"splot 're_"//trim(fname)//"'"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 're_"//fname//".png'"
write(10,*)"#rep"
close(10)
!Im
open(10,file=pname//"_im_map.gp")
write(10,*)"set title 'Im_"//fname//"'"
write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//minx//":"//maxx//"]"
write(10,*)"set yrange ["//miny//":"//maxy//"]"
write(10,*)"splot 'im_"//fname//"'"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 'im_"//fname//".png'"
write(10,*)"#rep"
close(10)
!
if(nosurface_)return
!Re
open(10,file=pname//"_re_surface.gp")
write(10,*)"set title 'Re_"//(fname)//"'"
write(10,*)"unset key"
write(10,*)"unset grid"
write(10,*)"set view 50,10,1,1"
write(10,*)"splot 're_"//(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 're_"//str(pname)//"_withlines' with lines"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 're_"//(fname)//".png'"
write(10,*)"#rep"
close(10)
!Im
open(10,file=pname//"_im_surface.gp")
write(10,*)"set title 'Im_"//(fname)//"'"
write(10,*)"set nokey"
write(10,*)"set grid"
write(10,*)"set view 50,10,1,1"
write(10,*)"splot 'im_"//(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 'im_"//str(pname)//"_withlines' with lines"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 'im_"//(fname)//".png'"
write(10,*)"#rep"
close(10)
end subroutine c_splot3D