fcn Subroutine

public pure subroutine fcn(beta, xplusd, ifixb, ifixx, ideval, f, fjacb, fjacd, istop)

User-supplied subroutine for evaluating the model.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: beta(:)
real(kind=wp), intent(in) :: xplusd(:,:)
integer, intent(in) :: ifixb(:)
integer, intent(in) :: ifixx(:,:)
integer, intent(in) :: ideval
real(kind=wp), intent(out) :: f(:,:)
real(kind=wp), intent(out) :: fjacb(:,:,:)
real(kind=wp), intent(out) :: fjacd(:,:,:)
integer, intent(out) :: istop

Source Code

   pure subroutine fcn(beta, xplusd, ifixb, ifixx, ideval, f, fjacb, fjacd, istop)
   !! User-supplied subroutine for evaluating the model.

      integer, intent(in) :: ideval, ifixb(:), ifixx(:, :)
      real(kind=wp), intent(in) :: beta(:), xplusd(:, :)
      real(kind=wp), intent(out) :: f(:, :), fjacb(:, :, :), fjacd(:, :, :)
      integer, intent(out) :: istop

      istop = 0

      ! Calculate model
      if (mod(ideval, 10) /= 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) /= 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) /= 0) then
         fjacd(:, 1, 1) = beta(1)*beta(2)*exp(beta(2)*xplusd(:, 1))
      end if

   end subroutine fcn