EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
output_empire.f90
Go to the documentation of this file.
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 !!! Time-stamp: <2016-10-17 12:19:06 pbrowne>
3 !!!
4 !!! Module that stores information about outputting from empire
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 
32  use, intrinsic :: iso_fortran_env, only : stderr=>error_unit,stdout=>output_unit
33  implicit none
34  integer,parameter :: emp_e=stderr
35  integer,parameter :: emp_o=stdout
36  integer,parameter :: unit_nml=10
37  integer,parameter :: unit_obs=11
39  integer,parameter :: unit_truth=12
41  integer,parameter :: unit_weight=13
43  integer,parameter :: unit_mean=14
45  integer,parameter :: unit_state=15
47  integer,parameter :: unit_ens_rmse=16
49  integer,parameter :: unit_mat_tri=17
51  integer,parameter :: unit_spatial_rmse=18
53  integer,parameter :: unit_variance=19
55  integer,parameter :: unit_hist_read=20
57  integer,parameter :: unit_hist_write=21
59  integer,parameter :: unit_hist_readt=22
61  integer,parameter :: unit_hist_readp=23
63  integer,parameter :: unit_traj_read=24
65  integer,parameter :: unit_traj_write=24
67  integer,parameter :: unit_vardata=25
68 
69 contains
70 
87  subroutine open_emp_o(id_num)
88  implicit none
89  integer, intent(in) :: id_num
90  character(14) :: filename
91  character(10) :: basename
92  logical :: opend
93  character(3), parameter :: msnul='nul'
94  character(9), parameter :: unixnul='/dev/null'
95  character(10), parameter :: emp_out_name='empire.nml'
96  logical :: file_exists
97  integer :: ios
98 
99  namelist/empire_output/basename
100 
101  inquire(file=emp_out_name,exist=file_exists)
102  if(file_exists) then
103  open(unit_nml,file=emp_out_name,iostat=ios,action='read'&
104  &,status='old',form='formatted')
105  if(ios .ne. 0) then
106  print*,'Cannot open ',emp_out_name
107  stop 'open_emp_o ERROR'
108  end if
109  read(unit_nml,nml=empire_output,iostat=ios)
110  close(unit_nml)
111  if(ios .ne. 0) basename ='emp.out'
112  else
113  basename = 'emp.out'
114  end if
115 
116  select case(basename)
117  case(msnul)
118  filename = msnul
119  case(unixnul)
120  filename = unixnul
121  case default
122  !define filename appropriately
123  write(filename,'(A,A,i0)') trim(basename),'.',id_num
124  end select
125 
126  print*,"this process' output will henceforth be directed to ",filename
127 
128  inquire(unit=emp_o,opened=opend)
129  if(opend) then
130  close(emp_o)
131  end if
132 
133  open(emp_o,file=filename,action='write',status='replace'&
134  &,form='formatted')
135 
136  inquire(unit=emp_e,opened=opend)
137  if(opend) then
138  close(emp_e)
139  end if
140  write(filename,'(A,i0)') 'emp.err.',id_num
141  open(emp_e,file=filename,action='write',status='replace'&
142  &,form='formatted')
143 
144  end subroutine open_emp_o
145 
146 
148  subroutine close_emp_o()
149  close(emp_o)
150  close(emp_e)
151  end subroutine close_emp_o
152 End Module output_empire
153 
154 
155 
subroutine close_emp_o()
subroutine to close the output file
Module that stores the information about the outputting from empire.
subroutine open_emp_o(id_num)
subroutine to open the file for outputting