EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
inner_products.f90
Go to the documentation of this file.
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 !!! Time-stamp: <2015-09-09 11:47:54 pbrowne>
3 !!!
4 !!! Collection of inner product wrappers
5 !!! Copyright (C) 2015 Philip A. Browne
6 !!!
7 !!! This program is free software: you can redistribute it and/or modify
8 !!! it under the terms of the GNU General Public License as published by
9 !!! the Free Software Foundation, either version 3 of the License, or
10 !!! (at your option) any later version.
11 !!!
12 !!! This program is distributed in the hope that it will be useful,
13 !!! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 !!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 !!! GNU General Public License for more details.
16 !!!
17 !!! You should have received a copy of the GNU General Public License
18 !!! along with this program. If not, see <http://www.gnu.org/licenses/>.
19 !!!
20 !!! Email: p.browne @ reading.ac.uk
21 !!! Mail: School of Mathematical and Physical Sciences,
22 !!! University of Reading,
23 !!! Reading, UK
24 !!! RG6 6BB
25 !!!
26 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27 
28 
36 subroutine innerr_1(n,c,y,w,t)
37  !subroutine to take an observation vector y and return w = y^T R^(-1) y
38 
39  use comms
40  implicit none
41  include 'mpif.h'
42  integer, parameter :: rk=kind(1.0d+0)
43  integer, intent(in) :: n
44  integer, intent(in) :: c
45  integer, intent(in) :: t
46  real(kind=rk), dimension(n,c), intent(in) :: y
47  real(kind=rk), dimension(n,c) :: v
48  real(kind=rk), dimension(c), intent(out) :: w
49  real(kind=rk), dimension(c) :: wtemp
50  real(kind=rk) :: ddot
51  integer :: i
52  integer :: mpi_err
53 
54  call solve_r(n,c,y,v,t)
55 
56  w = 0.0_rk
57 
58  do i = 1,c
59  w(i) = ddot(n,y(:,i),1,v(:,i),1)
60  end do
61 
62  if(comm_version .eq. 3) then
63  !need to perform the sum across all parts of the observation vector
64  wtemp = w
65  call mpi_allreduce(wtemp,w,c,mpi_double_precision,mpi_sum&
66  &,pf_member_comm,mpi_err)
67  end if
68 
69 end subroutine innerr_1
70 
71 
76 subroutine innerhqht_plus_r_1(y,w,t)
77  !subroutine to take an observation vector y and return w = y^T (HQH^T+R)^(-1) y
78  use comms
79  use sizes
80  implicit none
81  include 'mpif.h'
82  integer, parameter :: rk=kind(1.0d+0)
83  real(kind=rk), dimension(obs_dim), intent(in) :: y
84  real(kind=rk), dimension(obs_dim) :: v
85  real(kind=rk), intent(out) :: w
86  real(kind=rk) :: wtemp,ddot
87  integer, intent(in) :: t
88  integer :: mpi_err
89 
90  call solve_hqht_plus_r(obs_dim,y,v,t)
91 
92  w = 0.0_rk
93 
94  w = ddot(obs_dim,y,1,v,1)
95 
96 
97  if(comm_version .eq. 3) then
98  !need to perform the sum across all parts of the observation vector
99  wtemp = w
100  call mpi_allreduce(wtemp,w,1,mpi_double_precision,mpi_sum&
101  &,pf_member_comm,mpi_err)
102  end if
103 
104 
105 end subroutine innerhqht_plus_r_1
subroutine solve_r(obsDim, nrhs, y, v, t)
subroutine to take an observation vector y and return v in observation space.
Module containing EMPIRE coupling data.
Definition: comms.f90:57
Module that stores the dimension of observation and state spaces.
Definition: sizes.f90:29
subroutine innerr_1(n, c, y, w, t)
subroutine to compute the inner product with
subroutine innerhqht_plus_r_1(y, w, t)
subroutine to compute the inner product with
subroutine solve_hqht_plus_r(obsdim, y, v, t)
subroutine to take an observation vector y and return v in observation space.