PROGRAM nag_spline_1d_ex02 ! Example Program Text for nag_spline_1d ! NAG fl90, Release 4. NAG Copyright 2000. ! .. Use Statements .. USE nag_examples_io, ONLY : nag_std_in, nag_std_out USE nag_spline_1d, ONLY : nag_spline_1d_comm_wp => nag_spline_1d_comm_dp & , nag_spline_1d_lsq_fit, nag_spline_1d_intg, nag_deallocate ! .. Implicit None Statement .. IMPLICIT NONE ! .. Intrinsic Functions .. INTRINSIC KIND ! .. Parameters .. INTEGER, PARAMETER :: wp = KIND(1.0D0) ! .. Local Scalars .. INTEGER :: m, p REAL (wp) :: integral, theta TYPE (nag_spline_1d_comm_wp) :: spline ! .. Local Arrays .. REAL (wp), ALLOCATABLE :: f(:), lambda(:), wt(:), x(:) ! .. Executable Statements .. WRITE (nag_std_out,*) 'Example Program Results for nag_spline_1d_ex02' READ (nag_std_in,*) ! Skip heading in data file READ (nag_std_in,*) m, p ALLOCATE (x(m),f(m),wt(m),lambda(p-8)) ! Allocate storage READ (nag_std_in,*) x READ (nag_std_in,*) f READ (nag_std_in,*) wt READ (nag_std_in,*) lambda ! Fit spline and output residual norm. CALL nag_spline_1d_lsq_fit(x,f,lambda,spline,wt=wt,theta=theta) WRITE (nag_std_out,'(/1X,A,E12.4)') 'Residual sum of squares = ', theta ! Evaluate spline integral over region of definition. integral = nag_spline_1d_intg(spline) WRITE (nag_std_out,'(/1X,A,E12.4)') 'Spline integral = ', integral DEALLOCATE (x,f,wt,lambda) ! Deallocate storage CALL nag_deallocate(spline) ! Free structure allocated by NAG fl90 END PROGRAM nag_spline_1d_ex02