NAG Library Manual, Mark 30.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program s21bgfe

!     S21BGF Example Program Text

!     Mark 30.3 Release. nAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, s21bgf, x01aaf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: dm, dn, f, phi, pi
      Integer                          :: ifail, ix
!     .. Intrinsic Procedures ..
      Intrinsic                        :: real
!     .. Executable Statements ..
      Write (nout,*) 'S21BGF Example Program Results'

      Write (nout,*)
      Write (nout,*) '    DN     PHI    DM      S21BGF'
      Write (nout,*)

      pi = x01aaf(pi)

data: Do ix = 1, 3
        phi = real(ix,kind=nag_wp)*pi/6.0E0_nag_wp
        dm = real(ix,kind=nag_wp)*0.25E0_nag_wp
        dn = ((-1.0E0_nag_wp)**(ix+1))*real(ix,kind=nag_wp)*0.1E0_nag_wp

        ifail = -1
        f = s21bgf(dn,phi,dm,ifail)

        If (ifail<0) Then
          Exit data
        End If

        Write (nout,99999) dn, phi, dm, f
      End Do data

99999 Format (1X,3F7.2,F12.4)
    End Program s21bgfe