Program T_conrec

!! Test procedury Conrec pro kresbu isolinii

use std_type
use japi
use japigraf
use rgbcolor


integer :: dimX=100, dimY=100
real(kind=DP) :: OdX=-1.5_DP, DoX=1.5_DP, OdY=-1.5_DP, DoY=1.5_DP

type(ViewPortInfo) :: infVP
integer :: i,j
real(kind=DP) :: dx, dy
real(kind=DP),dimension(:),allocatable :: x,y
real(kind=DP),dimension(:,:),allocatable :: d
integer,parameter :: hladinZ = 7
!real(kind=DP),dimension(hladinZ) :: z = (/1.0/)
real(kind=DP),dimension(hladinZ) :: z = (/0.0,0.25,0.5,1.0,1.5,2.0,2.25/)


if (JapigrafVer<"2.4") then
	print *,"Vyzaduje Japigraf ver.2.4 nebo vetsi"
	read *
	Stop
end if

dx = (DoX-OdX)/(dimX-1)
allocate(x(dimX))
do i=1,dimX
	x(i)=OdX+(i-1)*dx
end do

dy = (DoY-OdY)/(dimY-1)
allocate(y(dimY))
do i=1,dimY
	y(i)=OdY+(i-1)*dy
end do

allocate(d(dimX,dimY))
do i=1,dimX
	do j=1,dimY
		d(i,j) = FunZ(x(i),y(j))
	end do
end do


call StartJapi()	
	
call NastavStdGraf(infVP,OdX,DoX,OdY,DoY,"Test conroc",.true.,.true.,&
				 KrokX=1.5_DP, KrokY=1.5_DP,DilkuX=5,DilkuY=5,&
				 Nadpis="Test procedury Conroc",&
				 PopisX="X", PopisY="Y",&
				 Grid = .true.)

call conrec(infVP,x,y,d,z)

call StartStdMenu(infVP)

call StopJapi()


contains

function FunZ(x,y) result(z)
	real(kind=DP),intent(in) :: x,y
	real(kind=DP) :: z
	
	!z = x*x + y*y
	real(kind=DP),parameter :: cons=0.842
	
	z = 1.0/((x**2+(y-cons)*(y+cons))**2+(x*(y-cons)+x*(y-cons))**2)
end function FunZ


end program T_conrec
