EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
output_spatial_rmse.f90
Go to the documentation of this file.
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 !!! Time-stamp: <2016-10-18 15:36:02 pbrowne>
3 !!!
4 !!! Subroutine to output RMSE
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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 subroutine output_spatial_rmse(mean)
30  use output_empire, only : unit_spatial_rmse,emp_e
31  use pf_control
32  use timestep_data
33  use sizes
34  use comms, only : comm_version,pf_ens_rank
35  implicit none
36  integer, parameter :: rk = kind(1.0d0)
37  real(kind=rk), dimension(state_dim), intent(in) :: mean
38  real(kind=rk), dimension(state_dim) :: se
39  real(kind=rk), dimension(state_dim) :: truth
40  real(kind=rk) :: mse,rmse
41  integer :: ios
42 
43  character(256) :: filename
44 
45  call get_truth(truth)
46 
47  se = (mean-truth)**2
48  mse = sum(se)/real(state_dim)
49  rmse = sqrt(mse)
50 
51  if(pf%timestep .eq. 0) then
52 
53  select case(comm_version)
54  case(1)
55  write(filename,'(A)') trim(pf%rmse_filename)
56  case(2)
57  write(filename,'(A)') trim(pf%rmse_filename)
58  case(3)
59  write(filename,'(A,A,i0)') trim(pf%rmse_filename),'.',pf_ens_rank
60  case default
61  write(emp_e,*) 'ERROR in output_spatial_rmse: comm_version ',comm_version,' &
62  &is not supported'
63  write(emp_e,*) 'Stopping'
64  stop '-23'
65  end select
66 
67 
68  open(unit_spatial_rmse,file=trim(filename),iostat=ios,action='write',status='replace')
69  if(ios .ne. 0) then
70  write(emp_e,*) 'PARTICLE FILTER DATA ERROR!!!!! Cannot open &
71  &file ',filename
72  write(emp_e,*) 'Very strange that I couldnt open it. Im goin&
73  &g to stop now.'
74  stop
75  end if
76  end if
77 
78  write(unit_spatial_rmse,'(es24.16)') rmse
79 
80  if(tsdata%completed_timesteps .eq. tsdata%total_timesteps) close(unit_spatial_rmse)
81 end subroutine output_spatial_rmse
Module containing EMPIRE coupling data.
Definition: comms.f90:57
Module that stores the information about the outputting from empire.
Module that stores the information about the timestepping process.
Module that stores the dimension of observation and state spaces.
Definition: sizes.f90:29
subroutine get_truth(x)
Subroutine to read truth from the file written by save_truth .
Definition: data_io.f90:87
module pf_control holds all the information to control the the main program
Definition: pf_control.f90:29
subroutine output_spatial_rmse(mean)
subroutine to output RMSEs