39 integer,
parameter :: rk = kind(1.0d0)
40 integer,
intent(in) :: t
41 real(kind=rk),
dimension(obs_dim),
intent(out) :: y
43 character(14) :: filename
45 write(filename,
'(A,i7.7)')
'obs_ts_',tsdata%next_ob_timestep
47 open(unit_obs,file=filename,iostat=ios,action=
'read',status=
'old',form=
'unformatted')
49 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file ',filename
50 write(emp_e,*)
'Check it exists. I need a lie down.'
66 integer,
parameter :: rk = kind(1.0d0)
67 real(kind=rk),
dimension(obs_dim),
intent(in) :: y
69 character(14) :: filename
71 write(filename,
'(A,i7.7)')
'obs_ts_',pf%timestep
73 open(unit_obs,file=filename,iostat=ios,action=
'write',status=
'replace',form=
'unformatted')
75 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file ',filename
76 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop now.'
93 integer,
parameter :: rk = kind(1.0d0)
94 real(kind=rk),
dimension(state_dim),
intent(out) :: x
96 if(pf%timestep .eq. 0)
then
97 print*,
'opening pf_truth'
98 open(unit_truth,file=
'pf_truth',iostat=ios,action=
'read')
100 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file pf_truth'
101 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop now.'
106 call
flush(unit_truth)
108 if(tsdata%completed_timesteps .eq. tsdata%total_timesteps)
then
110 print*,
'closing pf_truth'
123 integer,
parameter :: rk = kind(1.0d0)
124 real(kind=rk),
dimension(state_dim),
intent(in) :: x
126 if(pf%timestep .eq. 0)
then
127 print*,
'opening pf_truth'
128 open(unit_truth,file=
'pf_truth',iostat=ios,action=
'write',status=
'replace')
130 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file pf_truth'
131 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop now.'
135 write(unit_truth,*) x
136 call
flush(unit_truth)
138 if(tsdata%completed_timesteps .eq. tsdata%total_timesteps)
then
140 print*,
'closing pf_truth'
156 real(kind=kind(1.0D0)),
dimension(state_dim) :: mean,mtemp
157 integer :: ios,particle,mpi_err
158 character(20) :: filename
161 if(pf%timestep .eq. 0)
then
163 if(pf%output_weights)
then
164 write(filename,
'(A,i2.2)')
'ensemble_weights_',pfrank
165 open(unit_weight,file=filename,iostat=ios,action=
'write',status=
'replace')
167 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file pf_out'
168 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop now.'
175 if(pf%output_weights)
then
176 write(unit_weight,
'(i6.6,A)',advance=
'no') pf%timestep,
' '
177 do ios = 1,pf%count-1
178 write(unit_weight,
'(i6.6,A,e21.15,A)',advance=
'no') pf%particles(ios),
' ',pf&
179 &%weight(pf%particles(ios)),
' '
181 write(unit_weight,
'(i6.6,A,e21.15)',advance=
'yes') pf%particles(pf%count),
' ',pf&
182 &%weight(pf%particles(pf%count))
183 call
flush(unit_weight)
185 if(tsdata%completed_timesteps .eq. tsdata%total_timesteps)
close(unit_weight)
188 if(pf%use_mean .and. pf_ens_rank .eq. 0)
then
189 if(pf%timestep .eq. 0)
then
190 open(unit_mean,file=
'pf_mean',iostat=ios,action=
'write',status=
'replace')
192 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file pf_mean'
193 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop now.'
199 if(pf%use_mean .or. (pf%use_spatial_rmse .and. .not. pf%gen_data))
then
201 do particle = 1,pf%count
204 mtemp(:) = mtemp(:) + pf%psi(:,particle)/
real(pf%nens)
207 call mpi_allreduce(mtemp,mean,state_dim,mpi_double_precision,mpi_sum&
208 &,pf_ens_comm,mpi_err)
212 if(pf%use_mean .and. pf_ens_rank .eq. 0)
then
213 write(unit_mean,*) mean(:)
214 call
flush(unit_mean)
215 if(tsdata%completed_timesteps .eq. tsdata%total_timesteps)
close(unit_mean)
218 if(pf_ens_rank .eq. 0 .and. pf%use_spatial_rmse .and. .not. pf%gen_data) call
output_spatial_rmse(mean)
222 if(comm_version .ne. 3)
then
224 &,pf%timestep,tsdata%is_analysis)
235 integer,
parameter :: rk = kind(1.0d0)
236 real(kind=rk),
dimension(state_dim),
intent(in) :: state
238 character(256),
intent(in) :: filename
242 open(unit_state,file=trim(filename),iostat=ios,action=
'write',status=
'replace'&
243 &,form=
'unformatted')
245 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file '&
247 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop&
249 stop
'EMPIRE ERROR in SAVE_STATE'
251 write(unit_state) state
262 integer,
parameter :: rk = kind(1.0d0)
263 real(kind=rk),
dimension(state_dim),
intent(out) :: state
265 character(256),
intent(in) :: filename
269 open(unit_state,file=trim(filename),iostat=ios,action=
'read',status=
'old',form=
'un&
272 write(emp_e,*)
'PARTICLE FILTER DATA ERROR!!!!! Cannot open file '&
274 write(emp_e,*)
'Very strange that I couldnt open it. Im going to stop&
278 read(unit_state) state
subroutine save_observation_data(y)
Subroutine to save observation to a file Uses pftimestep to determine which observation to save...
subroutine default_get_observation_data(y, t)
Subroutine to read observation from a file Uses pftimestep to determine which observation to read...
Module containing EMPIRE coupling data.
module to deal with generating and outputting pf matrix
Module that stores the information about the outputting from empire.
Module that stores the information about the timestepping process.
subroutine save_truth(x)
Subroutine to save truth to a file .
Module that stores the dimension of observation and state spaces.
subroutine read_matrix_pf_information
subroutine to read namelist to control this output
subroutine matrix_pf_output(root, comm, n, m, x, time, is_analysis)
subroutine to generate and output matrix Pf
subroutine output_from_pf
subroutine to output data from the filter
subroutine get_state(state, filename)
subroutine to read the state vector from a named file as an unformatted fortran file ...
subroutine get_truth(x)
Subroutine to read truth from the file written by save_truth .
subroutine output_variance(mean)
subroutine to output ensemble variance
module pf_control holds all the information to control the the main program
subroutine save_state(state, filename)
subroutine to save the state vector to a named file as an unformatted fortran file ...
subroutine output_spatial_rmse(mean)
subroutine to output RMSEs