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

NAG FL Interface Introduction
Example description
    Program g13agfe

!     G13AGF Example Program Text

!     Mark 30.3 Release. nAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g13agf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: c
      Integer                          :: ifail, npar, nst, nuv, nwa
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: anexr(:), anx(:), par(:), st(:),     &
                                          wa(:)
      Integer                          :: mr(7)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: max
!     .. Executable Statements ..
      Write (nout,*) 'G13AGF Example Program Results'
      Write (nout,*)

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

!     Read in the problem size etc
      Read (nin,*) nuv, c

!     Read in the orders
      Read (nin,*) mr(1:7)

!     Calculate NPAR and various array lengths
      npar = mr(1) + mr(3) + mr(4) + mr(6)
      nst = mr(4)*mr(7) + mr(5)*mr(7) + mr(2) + mr(3) + max(mr(1),mr(6)*mr(7))
      nwa = 4*npar + 3*nst

      Allocate (st(nst),anx(nuv),anexr(nuv),wa(nwa),par(npar))

!     Read in parameter estimates
      Read (nin,*) par(1:npar)

!     Read in state set from G13AEF, G13AFF or previous call to G13AGF
      Read (nin,*) st(1:nst)

!     Read in new observations to update state set
      Read (nin,*) anx(1:nuv)

!     Update state set
      ifail = 0
      Call g13agf(st,nst,mr,par,npar,c,anx,nuv,anexr,wa,nwa,ifail)

!     Display results
      Write (nout,*) 'The updated state set array now holds the values'
      Write (nout,99999) st(1:nst)
      Write (nout,*)
      Write (nout,99998) 'The residuals corresponding to the', nuv
      Write (nout,*) 'values used to update the system are'
      Write (nout,99999) anexr(1:nuv)

99999 Format (1X,8F8.4)
99998 Format (1X,A,I3,A)
    End Program g13agfe