Program g10zafe
! G10ZAF Example Program Text
! Mark 28.7 Release. NAG Copyright 2022.
! .. Use Statements ..
Use nag_library, Only: g10zaf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: rss
Integer :: i, ifail, lwt, n, nord
Character (1) :: weight
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: wt(:), wtord(:), x(:), xord(:), &
y(:), yord(:)
Integer, Allocatable :: iwrk(:)
! .. Executable Statements ..
Write (nout,*) 'G10ZAF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the problem size
Read (nin,*) weight, n
If (weight=='W' .Or. weight=='w') Then
lwt = n
Else
lwt = 0
End If
Allocate (x(n),y(n),iwrk(n),wt(lwt),xord(n),yord(n),wtord(n))
! Read in data
If (lwt>0) Then
Read (nin,*)(x(i),y(i),wt(i),i=1,n)
Else
Read (nin,*)(x(i),y(i),i=1,n)
End If
! Reorder data
ifail = 0
Call g10zaf(weight,n,x,y,wt,nord,xord,yord,wtord,rss,iwrk,ifail)
! Display results
Write (nout,99999) 'Number of distinct observations = ', nord
Write (nout,99998) 'Residual sum of squares = ', rss
Write (nout,*)
Write (nout,*) ' X Y WT'
Write (nout,99997)(xord(i),yord(i),wtord(i),i=1,nord)
99999 Format (1X,A,I6)
99998 Format (1X,A,F13.5)
99997 Format (5X,F13.5,5X,F13.5,5X,F13.5)
End Program g10zafe