EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
objective_function.f90
Go to the documentation of this file.
1 subroutine objective_function(n,x,f)
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), intent(out) :: f
7 
8 real(kind=rk), dimension(2) :: fullx
9 integer :: mpi_rank,mpi_err
10 include 'mpif.h'
11 integer :: status(mpi_status_size)
12 
13 
14 call mpi_comm_rank(mpi_comm_world,mpi_rank,mpi_err)
15 
16 select case(mpi_rank)
17 case(0)
18  fullx(1) = x(1)
19  call mpi_send(fullx(1),1,mpi_double_precision,1,1,mpi_comm_world&
20  &,mpi_err)
21  call mpi_recv(fullx(2),1,mpi_double_precision,1,1,mpi_comm_world&
22  &,status,mpi_err)
23 case(1)
24  fullx(2) = x(1)
25  call mpi_recv(fullx(1),1,mpi_double_precision,0,1,mpi_comm_world&
26  &,status,mpi_err)
27  call mpi_send(fullx(2),1,mpi_double_precision,0,1,mpi_comm_world&
28  &,mpi_err)
29 case default
30  print*,'too many processes launched for the model. Error'
31  stop
32 end select
33 
34 ! Rosenbrock function
35 f = 100.*((fullx(2) - fullx(1)**2)**2) + (1. - fullx(1))**2
36 
37 end subroutine objective_function
subroutine objective_function(n, x, f)