The Newton finish's Jacobian: halo's analytic one, then the active eclipse rows (central differences, see eval_rows).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nlesolver_type), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x |
halo's scaled variables |
|
| real(kind=wp), | intent(out), | dimension(:) | :: | g |
the Jacobian's nonzeros |
subroutine newton_grad(me, x, g) class(nlesolver_type),intent(inout) :: me real(wp),dimension(:),intent(in) :: x !! halo's scaled variables real(wp),dimension(:),intent(out) :: g !! the Jacobian's nonzeros real(wp),dimension(:),allocatable :: jac, ks, jr integer,dimension(:),allocatable :: first_nz integer :: k, j, o, i logical :: ok select type (me) type is (eclipse_newton_type) call me%d%mission%compute_jacobian_stm(x, jac) ! (also puts x in the segments) g(1:me%d%nnz_halo) = jac allocate(ks(size(me%d%rows)), jr(sum(me%d%rows%ncol)), first_nz(size(me%d%rows))) o = 0 do k = 1, size(me%d%rows) first_nz(k) = o o = o + me%d%rows(k)%ncol end do call eval_rows(me%d, ks, jr, ok=ok, only=me%mask) j = me%d%nnz_halo do k = 1, size(me%active) i = me%active(k) g(j+1:j+me%d%rows(i)%ncol) = jr(first_nz(i)+1:first_nz(i)+me%d%rows(i)%ncol) j = j + me%d%rows(i)%ncol end do class default error stop 'newton_grad: invalid class' end select end subroutine newton_grad