! F01EF_P0W_F Example Program Text
! Mark 28.3 Release. NAG Copyright 2022.
Module f01ef_p0w_fe_mod
! F01EF_P0W_F Example Program Module:
! Parameters and User-defined Routines
! nin: the input channel number
! nout: the output channel number
! .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Accessibility Statements ..
Private
Public :: f
! .. Parameters ..
Integer, Parameter, Public :: nin = 5, nout = 6
Contains
Subroutine f(ad_handle,iflag,n,x,fx,iuser,ruser)
! .. Scalar Arguments ..
Type (c_ptr), Intent (Inout) :: ad_handle
Integer, Intent (Inout) :: iflag
Integer, Intent (In) :: n
! .. Array Arguments ..
Real (Kind=nag_wp), Intent (Out) :: fx(n)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (In) :: x(n)
Integer, Intent (Inout) :: iuser(*)
! .. Intrinsic Procedures ..
Intrinsic :: cos
! .. Executable Statements ..
fx(1:n) = cos(x(1:n))
Return
End Subroutine f
End Module f01ef_p0w_fe_mod
Program f01ef_p0w_fe
! F01EF_P0W_F Example Main Program
! .. Use Statements ..
Use f01ef_p0w_fe_mod, Only: f, nin, nout
Use iso_c_binding, Only: c_ptr
Use nagad_library, Only: f01ef_p0w_f
Use nag_library, Only: nag_wp, x04caf
! .. Implicit None Statement ..
Implicit None
! .. Local Scalars ..
Type (c_ptr) :: ad_handle
Integer :: i, ierr, ifail, iflag, lda, n
Character (1) :: uplo
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:,:)
Real (Kind=nag_wp) :: ruser(1)
Integer :: iuser(1)
! .. Executable Statements ..
Write (nout,*) 'F01EF_P0W_F Example Program Results'
Write (nout,*)
Flush (nout)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Read (nin,*) uplo
lda = n
Allocate (a(lda,n))
! Read A from data file
If (uplo=='U' .Or. uplo=='u') Then
Read (nin,*)(a(i,i:n),i=1,n)
Else
Read (nin,*)(a(i,1:i),i=1,n)
End If
! Find f( A )
ifail = 0
Call f01ef_p0w_f(ad_handle,uplo,n,a,lda,f,iuser,ruser,iflag,ifail)
! Print solution
ierr = 0
Call x04caf(uplo,'N',n,n,a,lda,'Symmetric f(A)',ierr)
End Program f01ef_p0w_fe