testSpline_prg Program

program~~testspline_prg~~UsesGraph program~testspline_prg testSpline_prg module~kinds_mod kinds_mod module~kinds_mod->program~testspline_prg module~plplotlib_mod plplotlib_mod module~kinds_mod->module~plplotlib_mod module~array_mod array_mod module~kinds_mod->module~array_mod module~spline_mod spline_mod module~kinds_mod->module~spline_mod module~text_mod text_mod module~kinds_mod->module~text_mod module~time_mod time_mod module~kinds_mod->module~time_mod module~plplotlib_mod->program~testspline_prg module~array_mod->program~testspline_prg module~array_mod->module~plplotlib_mod module~array_mod->module~spline_mod module~spline_mod->program~testspline_prg plplot plplot plplot->module~plplotlib_mod module~text_mod->module~plplotlib_mod module~time_mod->module~text_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~text_mod iso_c_binding iso_c_binding iso_c_binding->module~time_mod
Help


Test program for Spline_mod

Calls

program~~testspline_prg~~CallsGraph program~testspline_prg testSpline_prg proc~testnewspline testNewSpline program~testspline_prg->proc~testnewspline proc~testsplinex testSplineX program~testspline_prg->proc~testsplinex cubicspline_t cubicspline_t proc~testnewspline->cubicspline_t proc~testsplinex->cubicspline_t proc~xylim xylim proc~testsplinex->proc~xylim proc~subplot subplot proc~testsplinex->proc~subplot linearspline_t linearspline_t proc~testsplinex->linearspline_t proc~ticks ticks proc~testsplinex->proc~ticks proc~figure figure proc~testsplinex->proc~figure proc~setup setup proc~testsplinex->proc~setup interface~mixval mixval proc~testsplinex->interface~mixval proc~show show proc~testsplinex->proc~show proc~labels labels proc~testsplinex->proc~labels proc~plot plot proc~testsplinex->proc~plot plwind plwind proc~xylim->plwind pladv pladv proc~subplot->pladv plvasp plvasp proc~subplot->plvasp plssub plssub proc~subplot->plssub plvpor plvpor proc~subplot->plvpor plvsta plvsta proc~subplot->plvsta plbox plbox proc~ticks->plbox proc~figure->pladv proc~figure->plssub plbop plbop proc~figure->plbop pleop pleop proc~figure->pleop plsfnam plsfnam proc~setup->plsfnam plsetopt plsetopt proc~setup->plsetopt plsfam plsfam proc~setup->plsfam plfontld plfontld proc~setup->plfontld plinit plinit proc~setup->plinit plsdev plsdev proc~setup->plsdev plend plend proc~show->plend pllab pllab proc~labels->pllab plline plline proc~plot->plline plptex plptex proc~plot->plptex plssym plssym proc~plot->plssym
Help

Source Code


Variables

Type AttributesNameInitial
real(kind=wp), parameter, dimension(5,2):: x0 =reshape([-2.0_wp, -1.0_wp, 0.0_wp, 1.0_wp, 2.0_wp, 3.0_wp, 0.0_wp, -1.0_wp, 0.0_wp, 3.0_wp], [5, 2])
real(kind=wp), parameter, dimension(5):: t0 =[0.00_wp, 0.25_wp, 0.50_wp, 0.75_wp, 1.00_wp]

Subroutines

subroutine testNewSpline()

Arguments

None

subroutine testSplineX()

Arguments

None

Source Code

program testSpline_prg
	!! Test program for Spline_mod
	use kinds_mod
	use spline_mod
	use plplotlib_mod
	use array_mod
	implicit none
	
	real(wp),dimension(5,2),parameter::x0 = reshape( [ &
		& -2.0_wp,-1.0_wp, 0.0_wp,1.0_wp,2.0_wp , &
		&  3.0_wp, 0.0_wp,-1.0_wp,0.0_wp,3.0_wp & 
		& ],[5,2])
	
	real(wp),dimension(5),parameter::t0 = &
		& [ 0.00_wp,0.25_wp,0.50_wp,0.75_wp,1.00_wp]
	
	call testNewSpline
	call testSplineX
	
contains

	subroutine testNewSpline
		type(cubicSpline_t)::spline
		
		spline = cubicSpline_t(t0,x0)
	end subroutine testNewSpline

	subroutine testSplineX
		type(cubicSpline_t)::sf,sc
		type(linearSpline_t)::sl
		real(wp),dimension(:,:),allocatable::xl,xf,xc,xt
		real(wp)::t
		integer::N,k
		
		N = 100
		
		sl = linearSpline_t(t0,x0)
		sf = cubicSpline_t(t0,x0,'finiteDifference')
		sc = cubicSpline_t(t0,x0,'conventional')
		
		allocate( xl(N,2) , xf(N,2) , xc(N,2) , xt(N,2) )
		
		do k=1,N
			t = real(k-1,wp)/real(N-1,wp)
			xl(k,1:2) = sl%x(t)
			xf(k,1:2) = sf%x(t)
			xc(k,1:2) = sc%x(t)
			xt(k,1:2) = [4.0_wp*t-2.0_wp,(4.0_wp*t-2.0_wp)**2-1.0_wp]
		end do
		
		call setup(fileName='spline-%n.svg',figSize=[400,300])
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(xt(:,1)),mixval(xt(:,2)))
		
		call plot(xt(:,1),xt(:,2),lineStyle='-' ,lineColor='r',lineWidth=2.0_wp)
		call plot(xl(:,1),xl(:,2),lineStyle=':' ,lineColor='m',lineWidth=2.0_wp)
		call plot(xf(:,1),xf(:,2),lineStyle='-' ,lineColor='b',lineWidth=2.0_wp)
		call plot(xc(:,1),xc(:,2),lineStyle='--',lineColor='c',lineWidth=2.0_wp)
		call plot(x0(:,1),x0(:,2),lineStyle=''  ,markStyle='x',markColor='k')
		
		call ticks()
		call labels('x','y','Spline Test')
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(xt(:,1)),[-2.0_wp,2.0_wp])
		
		call plot(xl(:,1),xl(:,2)-xt(:,2),lineStyle=':' ,lineColor='m',lineWidth=2.0_wp)
		call plot(xt(:,1),xt(:,2)-xt(:,2),lineStyle='-' ,lineColor='r',lineWidth=2.0_wp)
		call plot(xf(:,1),xf(:,2)-xt(:,2),lineStyle='-' ,lineColor='b',lineWidth=2.0_wp)
		call plot(xc(:,1),xc(:,2)-xt(:,2),lineStyle='--',lineColor='c',lineWidth=2.0_wp)
		call plot(x0(:,1),x0(:,2)-x0(:,2),lineStyle=''  ,markStyle='x',markColor='k')
		
		call ticks()
		call labels('x','y','Spline Test')
		
		call show()
	end subroutine testSplineX

end program testSpline_prg