Program g01gc_t1w_fe
! G01GC_T1W_F Example Program Text
! Mark 27.3 Release. NAG Copyright 2021.
! .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nagad_library, Only: g01gc_t1w_f, nagad_t1w_set_derivative, &
nagad_t1w_w_rtype, x10aa_t1w_f, x10ab_t1w_f, &
Assignment (=)
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Type (c_ptr) :: ad_handle
Type (nagad_t1w_w_rtype) :: df, p, rlamda, tol, x
Real (Kind=nag_wp) :: dfr, dpdd, dpdr, dpdx, rr, xr
Integer :: i, ifail, maxit, n
! .. Executable Statements ..
Write (nout,*) 'G01GC_T1W_F Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Write (nout,99999) 'x', 'df', 'rlamda', 'p', 'p''', 'df''', 'rlamda'''
99999 Format (1X,A5,A8,A10,A6,A11,A11,A11)
tol = 0.0E0_nag_wp
maxit = 100
! Create AD configuration data object
ifail = 0
Call x10aa_t1w_f(ad_handle,ifail)
Do i = 1, n
Read (nin,*) xr, dfr, rr
x = xr
df = dfr
rlamda = rr
Call nagad_t1w_set_derivative(x,1.0_nag_wp)
! Calculate probability
ifail = 0
Call g01gc_t1w_f(ad_handle,x,df,rlamda,tol,maxit,p,ifail)
dpdx = p%tangent
x = xr
df = dfr
rlamda = rr
Call nagad_t1w_set_derivative(df,1.0_nag_wp)
ifail = 0
Call g01gc_t1w_f(ad_handle,x,df,rlamda,tol,maxit,p,ifail)
dpdd = p%tangent
x = xr
df = dfr
rlamda = rr
Call nagad_t1w_set_derivative(rlamda,1.0_nag_wp)
ifail = 0
Call g01gc_t1w_f(ad_handle,x,df,rlamda,tol,maxit,p,ifail)
dpdr = p%tangent
Write (nout,99998) x%value, df%value, rlamda%value, p%value, dpdx, &
dpdd, dpdr
End Do
99998 Format (1X,4(F7.2,1X),1P,3E10.2)
! Remove computational data object
Call x10ab_t1w_f(ad_handle,ifail)
End Program g01gc_t1w_fe