41 integer,
parameter :: rk = kind(1.0d0)
42 real(kind=rk),
dimension(pf%count) :: alpha,c
43 real(kind=rk),
dimension(pf%count) :: epsiloni,epsilon_n,epsilon_p,gammai,ce,win,wsolve
44 real(kind=rk),
dimension(pf%nens) :: csorted
45 real(kind=rk),
dimension(pf%nens) :: weight_an
46 real(kind=rk) :: cmax,xs1,xs2
47 integer :: particle,i,mpi_err,rc
48 real(kind=rk) :: percentage,randc
49 real(kind=rk),
dimension(obs_dim) :: y
50 real(kind=rk),
dimension(obs_dim,pf%count) :: Hfpsi
51 real(kind=rk),
dimension(obs_dim,pf%count) :: y_Hfpsin1
52 real(kind=rk),
dimension(state_dim,pf%count) :: fpsi
53 real(kind=rk),
dimension(state_dim) :: psimean
54 real(kind=rk),
dimension(state_dim,pf%count) :: kgain
55 real(kind=rk),
dimension(state_dim,pf%count) :: betan
56 real(kind=rk),
dimension(state_dim,pf%count) :: statev
59 real(kind=rk),
parameter :: pi = 4.0D0*atan(1.0d0)
61 real(kind=rk),
dimension(pf%count) :: weight_temp2
64 integer :: ensemble_comm
65 real(kind=rk) :: gammaitemp
72 if(comm_version .eq. 1 .or. comm_version .eq. 2)
then
73 ensemble_comm = pf_mpi_comm
74 elseif(comm_version .eq. 3)
then
75 ensemble_comm = pf_ens_comm
77 write(emp_e,*)
'EMPIRE VERSION ',comm_version,
' NOT SUPPORTED IN propos&
79 write(emp_e,*)
'THIS IS AN ERROR. STOPPING'
92 call
h(obs_dim,pf%count,fpsi,hfpsi,pf%timestep)
96 particle = pf%particles(i)
97 y_hfpsin1(:,i) = y - hfpsi(:,i)
101 c(i) = 2.0*pf%weight(particle) + w
106 call mpi_allgatherv(c,pf%count,mpi_double_precision,csorted,gblcount&
107 &,gbldisp,mpi_double_precision,ensemble_comm,mpi_err)
111 cmax = csorted(pf%nens)
118 call
k(y_hfpsin1,kgain)
127 gammai(i) = ddot(state_dim,statev(:,i),1,statev(:,i),1)
128 if(comm_version .eq. 3)
then
131 call mpi_allreduce(gammaitemp,gammai(i),1,mpi_double_precision,mpi_sum&
132 &,pf_member_comm,mpi_err)
138 win(i) = (-gammai(i)/state_dim_g)*exp(-gammai(i)/state_dim_g)*exp(-ce(i)/state_dim_g)
140 if(ce(i) .eq. 0.0)
then
141 wsolve(i) = -(gammai(i)/state_dim_g)
143 epsilon_n(i) = (-state_dim_g/gammai(i))*wsolve(i) - 1
148 epsilon_p(i) = (-state_dim_g/gammai(i))*wsolve(i) - 1
154 if(comm_version .eq. 1 .or. comm_version .eq. 2)
then
155 call random_number(randc)
157 if(pf_member_rank .eq. 0)
then
158 call random_number(randc)
160 call mpi_scatter(randc,1,mpi_double_precision,randc,1&
161 &,mpi_double_precision,0,pf_member_rank,mpi_err)
163 if(randc .ge. 0.5)
then
164 epsiloni(i) = epsilon_p(i)
166 epsiloni(i) = epsilon_n(i)
173 alpha(i) = 1.0 + epsiloni(i)
177 call
phalf(pf%count,statev,betan)
181 particle = pf%particles(i)
182 weight_an(particle) = 0.0
183 if(alpha(i) .eq. 0.0)
then
184 alpha(i) = alpha(i) + 1.0e-16
186 weight_an(particle) = gammai(i)*epsiloni(i)-state_dim_g*log(alpha(i))+c(i)
187 weight_an(particle) = 0.5*weight_an(particle)
188 if(alpha(i) .eq. 1.0e-16)
then
189 weight_an(particle) = 0.5*cmax
191 pf%Weight(particle) = weight_an(particle)
195 call
update_state(pf%psi(:,i),fpsi(:,i),kgain(:,i),sqrt(alpha(i))*betan(:,i))
196 psimean = psimean + pf%psi(:,i)
200 weight_temp2 = -huge(1.0d0)
202 weight_temp2(i) = pf%weight(pf%particles(i))
206 call mpi_allgatherv(weight_temp2,pf%count,mpi_double_precision,pf%weight,gblcount&
207 &,gbldisp,mpi_double_precision,ensemble_comm,mpi_err)
210 pf%weight = exp(-pf%weight+maxval(pf%weight))
211 pf%weight = pf%weight/sum(pf%weight)
212 pf%weight = -log(pf%weight)
subroutine normalrandomnumbers2d(mean, stdev, n, k, phi)
generate two dimensional Normal random numbers
subroutine send_all_models(stateDim, nrhs, x, tag)
subroutine to send all the model states to the models
subroutine phalf(nrhs, x, Px)
subroutine to take a full state vector x and return in state space.
Module containing EMPIRE coupling data.
subroutine equivalent_weights_filter_zhu
subroutine to do the new scheme equal weights last time-step
Module that stores the information about the outputting from empire.
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
subroutine lambertw(K, X, W)
subroutine to implement the lambertw function see https://en.wikipedia.org/wiki/Lambert_W_function ...
Module that stores the dimension of observation and state spaces.
subroutine diagnostics
Subroutine to give output diagnositics such as rank histograms.
subroutine h(obsDim, nrhs, x, hx, t)
subroutine to take a full state vector x and return H(x) in observation space.
subroutine innerhqht_plus_r_1(y, w, t)
subroutine to compute the inner product with
module pf_control holds all the information to control the the main program
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 .
A module for random number generation from the following distributions:
recursive subroutine quicksort_d(a, na)
subroutine to sort using the quicksort algorithm
subroutine k(y, x)
Subroutine to apply to a vector y in observation space where .