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

NAG FL Interface Introduction
Example description
    Program e02zafe

!     E02ZAF Example Program Text

!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: e02zaf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, iadres, ifail, m, nadres, npoint, &
                                          px, py
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: lamda(:), mu(:), x(:), y(:)
      Integer, Allocatable             :: adres(:), point(:)
!     .. Executable Statements ..
      Write (nout,*) 'E02ZAF Example Program Results'

!     Skip heading in data file
      Read (nin,*)

      Read (nin,*) m
      Read (nin,*) px, py
      nadres = (px-7)*(py-7)
      npoint = m + nadres
      Allocate (adres(nadres),lamda(px),mu(py),x(m),y(m),point(npoint))

!     Read data points and intercepts of panel sides

      Read (nin,*)(x(i),y(i),i=1,m)

      If (px>8) Then
        Read (nin,*) lamda(5:(px-4))
      End If

      If (py>8) Then
        Read (nin,*) mu(5:(py-4))
      End If

!     Sort points into panel order

      ifail = 0
      Call e02zaf(px,py,lamda,mu,m,x,y,point,npoint,adres,nadres,ifail)

!     Output points in panel order

      Do i = 1, nadres
        Write (nout,*)
        Write (nout,99999) 'Panel', i
        iadres = m + i

loop:   Do
          iadres = point(iadres)

          If (iadres<=0) Then
            Exit loop
          End If

          Write (nout,99998) x(iadres), y(iadres)
        End Do loop

      End Do

99999 Format (1X,A,I4)
99998 Format (1X,2F7.2)
    End Program e02zafe