fcn Subroutine

public pure subroutine fcn(n, m, np, nq, ldn, ldm, ldnp, beta, xplusd, ifixb, ifixx, ldifx, ideval, f, fjacb, fjacd, istop)

User-supplied subroutine for evaluating the model.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(in) :: m
integer, intent(in) :: np
integer, intent(in) :: nq
integer, intent(in) :: ldn
integer, intent(in) :: ldm
integer, intent(in) :: ldnp
real(kind=wp), intent(in) :: beta(np)
real(kind=wp), intent(in) :: xplusd(ldn,m)
integer, intent(in) :: ifixb(np)
integer, intent(in) :: ifixx(ldifx,m)
integer, intent(in) :: ldifx
integer, intent(in) :: ideval
real(kind=wp), intent(out) :: f(ldn,nq)
real(kind=wp), intent(out) :: fjacb(ldn,ldnp,nq)
real(kind=wp), intent(out) :: fjacd(ldn,ldm,nq)
integer, intent(out) :: istop

Source Code

   pure subroutine fcn(n, m, np, nq, ldn, ldm, ldnp, beta, xplusd, ifixb, ifixx, &
                       ldifx, ideval, f, fjacb, fjacd, istop)
   !! User-supplied subroutine for evaluating the model.
      integer, intent(in) :: ideval, ldifx, ldm, ldn, ldnp, m, n, np, nq
      integer, intent(in) :: ifixb(np), ifixx(ldifx, m)
      real(kind=wp), intent(in) :: beta(np), xplusd(ldn, m)
      real(kind=wp), intent(out) :: f(ldn, nq), fjacb(ldn, ldnp, nq), fjacd(ldn, ldm, nq)
      integer, intent(out) :: istop

      istop = 0

      ! Calculate model
      if (mod(ideval, 10) .ne. 0) then
         f(:, 1) = beta(1)*exp(beta(2)*xplusd(:, 1))
      end if

      ! Calculate model partials with respect to `beta`
      if (mod(ideval/10, 10) .ne. 0) then
         fjacb(:, 1, 1) = exp(beta(2)*xplusd(:, 1))
         fjacb(:, 2, 1) = beta(1)*xplusd(:, 1)*exp(beta(2)*xplusd(:, 1))
      end if

      ! Calculate model partials with respect to `delta`
      if (mod(ideval/100, 10) .ne. 0) then
         fjacd(:, 1, 1) = beta(1)*beta(2)*exp(beta(2)*xplusd(:, 1))
      end if

   end subroutine fcn