EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
sir_filter.f90
Go to the documentation of this file.
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 !!! Time-stamp: <2016-05-18 10:32:25 pbrowne>
3 !!!
4 !!! Subroutine to perform SIR filter
5 !!! Copyright (C) 2014 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 subroutine sir_filter
29  use timestep_data
30  use comms
31  use sizes
32  use pf_control
33  implicit none
34  include 'mpif.h'
35  integer :: k,particle!,tag
36  real(kind=kind(1.0d0)), dimension(state_dim) :: zeros
37  real(kind=kind(1.0d0)), dimension(pf%count) :: w
38  real(kind=kind(1.0d0)), dimension(state_dim,pf%count) :: fpsi,normaln,betan
39  real(kind=kind(1.0d0)), dimension(obs_dim) :: y
40  real(kind=kind(1.0d0)), dimension(obs_dim,pf%count) :: y_Hfpsi,Hfpsi
41  ! integer, dimension(mpi_status_size) :: mpi_status
42  ! integer :: mpi_err
43  zeros = 0.0d0
44 
45  !get the model to provide f(x)
46  call send_all_models(state_dim,pf%count,pf%psi,1)
47 
48 
49  !draw from a Gaussian for the random noise
50  call normalrandomnumbers2d(0.0d0,1.0d0,state_dim,pf%count,normaln)
51 
52  !compute the relaxation term Qkgain, the intermediate
53  !term kgain and apply correlation to noise
54  call qhalf(pf%count,normaln,betan)
55 
56 
57  call get_observation_data(y,pf%timestep)
58  !this is the analysis step.
59 
60 
61  call recv_all_models(state_dim,pf%count,fpsi)
62 
63 
64  !update the new state and weights based on these terms
65  !$omp parallel do
66  DO k = 1,pf%count
67  call update_state(pf%psi(:,k),fpsi(:,k),zeros,betan(:,k))
68  end DO
69  !$omp end parallel do
70 
71 
72 
73 
74  call h(obs_dim,pf%count,pf%psi,hfpsi,pf%timestep)
75 
76  !$omp parallel do
77  do k = 1,pf%count
78  y_hfpsi(:,k) = y - hfpsi(:,k)
79  end do
80  !$omp end parallel do
81 
82  call innerr_1(obs_dim,pf%count,y_hfpsi,w,pf%timestep)
83 
84  do k = 1,pf%count
85  particle = pf%particles(k)
86  pf%weight(particle) = 0.5*w(k)
87  end do
88 
89  call resample
90 
91 
93 end subroutine sir_filter
subroutine normalrandomnumbers2d(mean, stdev, n, k, phi)
generate two dimensional Normal random numbers
Definition: gen_rand.f90:109
subroutine send_all_models(stateDim, nrhs, x, tag)
subroutine to send all the model states to the models
Definition: comms.f90:945
subroutine resample
Subroutine to perform Universal Importance Resampling.
Definition: resample.f90:28
Module containing EMPIRE coupling data.
Definition: comms.f90:57
subroutine sir_filter
Subroutine to perform SIR filter (Sequential Importance Resampling)
Definition: sir_filter.f90:28
Module that stores the information about the timestepping process.
subroutine update_state(state, fpsi, kgain, betan)
Subroutine to update the state.
subroutine recv_all_models(stateDim, nrhs, x)
subroutine to receive all the model states from the models after
Definition: comms.f90:993
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 h(obsDim, nrhs, x, hx, t)
subroutine to take a full state vector x and return H(x) in observation space.
module pf_control holds all the information to control the the main program
Definition: pf_control.f90:29
subroutine timestep_data_set_is_analysis
subroutine to define if the current ensemble is an analysis
subroutine get_observation_data(y, t)
Subroutine to read observation from a file .
subroutine qhalf(nrhs, x, Qx)
subroutine to take a full state vector x and return in state space.