!!****************************************************************************
!! Test modulu Quanc8FMM
!!****************************************************************************

module Funkce

	integer,parameter :: SP = selected_real_kind(4)
	integer,parameter :: DP = selected_real_kind(8)
	integer,parameter,public :: FP = SP	! pouzije se i v T_Quanc8FMM

contains

	function Integrand1(x) result(r)
		real(kind=FP),intent(in) :: x
		real(kind=FP) :: r
			! integrovana funkce	
		r = 1/((x-0.3)**2+0.01) + 1/((x-0.9)**2+0.04) - 6.0 
	end function Integrand1

	!~ function presne1(a,b) result(r)
		!~ real(kind=FP),intent(in) :: a,b
		!~ real(kind=FP) :: r
		!~ r = -cos(b)+cos(a)
	!~ end function presne1
	
!~ ! Integrand sinh(3x)/sinh(x)**3, limita pro x=0 je +Inf
	!~ function Integrand2(x) result(r)
		!~ real(kind=FP),intent(in) :: x
		!~ real(kind=FP) :: r
			!~ ! integrovana funkce, limita pro x=0 je +Inf	
		!~ r = sinh(3*x)/sinh(x)**3
	!~ end function Integrand2
	
	!~ function presne2(a,b) result(r)
		!~ real(kind=FP),intent(in) :: a,b
		!~ real(kind=FP) :: r
		!~ r = (4*b-3/tanh(b)) - (4*a-3/tanh(a))		
	!~ end function presne2


end module Funkce

!!======================== Program ===========================================

program T_Quanc8

use Funkce					! krome funkce zavadi i FP=SP|DP
use Quanc8FMM
use VstupVystup

integer :: nofun
real(FP) :: a,b,abserr,relerr,hodnota,errest,flag,ph

!..............................................................................
Print *,"Realna cisla na ",FP,"byte"		! zadane v modulu Funkce
print *,"-----------------------",char(10)
!..............................................................................

call cti_cislo("Spodni mez a = ",a)
call cti_cislo("Horni mez  b = ",b)
call cti_cislo("Pozadovana chyba abserr = ",abserr)
call cti_cislo("Pozadovana chyba relerr = ",relerr)

call Quanc8(Integrand1,a,b,abserr,relerr,hodnota,errest,nofun,flag)
! ph = presne2(a,b)

print *,char(10)//"Procedura Quanc8"
print "(a,es16.8)","Vypoctena hodnota integralu = ",hodnota
! print "(a,es16.8)","Presna hodnota integralu    = ",ph
print *
! print "(a,es16.8)","presna-vypoctena    = ",ph-hodnota
print "(a,es16.8)","odhad abs. chyby    = ",errest
print "(a,f16.3)", "flag                = ",flag
print "(a,i16)",   "vypoctu funkce      = ",nofun
print *

print *,"ENTER = konec"
read *

end program T_quanc8
