EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
objective_gradient.f90
Go to the documentation of this file.
1 subroutine objective_gradient(n,x,g)
2 implicit none
3 integer, parameter :: rk = kind(1.0d0)
4 integer, intent(in) :: n
5 real(kind=rk), dimension(n), intent(in) :: x
6 real(kind=rk), dimension(n), intent(out) :: g
7 
8 ! Declare a few additional variables for this sample problem
9 integer :: i
10 real(rk) :: t1, t2
11 
12 
13 ! test function gradient
14 
15 t1 = x(2) - x(1)**2
16 g(1) = 2.d0*(x(1) - 1.d0) - 1.6d1*x(1)*t1
17 do 22 i=2, n-1
18  t2 = t1
19  t1 = x(i+1) - x(i)**2
20  g(i) = 8.d0*t2 - 1.6d1*x(i)*t1
21 22 continue
22  g(n) = 8.d0*t1
23 
24 end subroutine objective_gradient
subroutine objective_gradient(n, x, g)