EMPIRE DA  v1.9.1
Data assimilation codes using EMPIRE communication
 All Classes Files Functions Variables Pages
output_mat_tri.f90
Go to the documentation of this file.
1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 !!! Time-stamp: <2016-10-18 15:35:01 pbrowne>
3 !!!
4 !!! Subroutine to output triangular matrix
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 
29 subroutine output_mat_tri(n,A,filename,output_type)
30  use output_empire, only : unit_mat_tri,emp_e
31  implicit none
32  integer, parameter :: rk = kind(1.0d0)
33  integer, intent(in) :: n
34  real(kind=rk), intent(in), dimension(n*(n+1)/2) :: A
37  character(40), intent(in) :: filename
39  integer, intent(in) :: output_type
48 
49 
50  real(kind=rk), dimension(n*(n+1)/2) :: Aout
51  integer :: outunit=unit_mat_tri
52  logical :: opend
53  character(11) :: fm
54  integer :: err
55 
56  if(output_type .eq. 0) then
57  write(emp_e,*) 'Error in output_mat_tri. output_type = 0&
58  & unsupported. Stopping.'
59  stop '-4'
60  elseif(output_type .gt. 0) then
61  fm='unformatted'
62  else
63  fm='formatted'
64  end if
65 
66 
67 
68 
69  !ensure unit is not opened then open file=filename
70  do
71  inquire(unit=outunit,opened=opend)
72  if(.not. opend) then
73  open(outunit,file=filename,action='write',form=fm)
74  exit
75  else
76  outunit=outunit-1
77  end if
78  end do
79 
80  select case(abs(output_type))
81  case(1) ! standard packed format (TP)
82  call dtfttp('N','U',n,a,aout,err)
83  case(2) ! rectangular full packed format (TF)
84  aout = a
85  case default
86  write(emp_e,*) 'Error in output_mat_tri, unsupported output_type'
87  write(emp_e,*) 'output_type=',output_type,'. Stopping'
88  stop '-4'
89  end select
90 
91 
92  if(output_type .gt. 0) then
93  write(outunit) aout
94  else
95  write(outunit,*) aout
96  end if
97 
98  close(outunit)
99 
100 
101 end subroutine output_mat_tri
Module that stores the information about the outputting from empire.
subroutine output_mat_tri(n, A, filename, output_type)
subroutine to output triangluar matrix various formats