-
Notifications
You must be signed in to change notification settings - Fork 0
/
printing.f90
153 lines (146 loc) · 5.73 KB
/
printing.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
!
! Mostly to be used for debugging - produces a reasonably tidy printout of
! a matrix.
!
module printing
use accuracy
implicit none
private
public print_matrix
public rcsid_printing
interface print_matrix
module procedure print_complex_matrix
module procedure print_real_matrix
!*qd module procedure print_quad_complex_matrix
!*qd module procedure print_quad_matrix
end interface ! print_matrix
!
character(len=clen), save :: rcsid_printing = "$Id: printing.f90,v 1.2 2021/09/29 13:43:22 ps Exp $"
!
integer(ik), parameter :: page_width = 196_ik ! Max. width of the printout
contains
subroutine print_complex_matrix(m,w,f)
complex(rk), intent(in) :: m(:,:) ! Matrix to be printed
integer(ik), intent(in) :: w ! Field width
character(len=*), intent(in) :: f ! Format to use for number conversion
!
integer(ik) :: nr, nc ! number of rows and columns in the matrix
integer(ik) :: cpp ! columns per page of the output
integer(ik) :: cs, ce ! starting and ending columns
integer(ik) :: cc, rc ! column and row being processed now
character(len=200) :: fmt_head ! Format for the header
character(len=200) :: fmt_line ! Format for the data line
!
nr = size(m,dim=1)
nc = size(m,dim=2)
!
if (w<6) stop 'printing%print_complex_matrix - logic error 1'
cpp = (page_width-6) / (3+2*w)
if (cpp<1) stop 'printing%print_complex_matrix - logic error 2'
!
write (fmt_head,"('(6x,',i0,'(4x,i6,',i0,'x))')") cpp, 3+2*w-10
write (fmt_line,"('(i6,',i0,'(2x,',a,',1x,',a,'))')") cpp, f, f
!
pages: do cs=1,nc,cpp
ce = min(nc,cs+cpp-1)
write (out,fmt=trim(fmt_head)) (cc,cc=cs,ce)
rows: do rc=1,nr
write (out,fmt=trim(fmt_line)) rc,(m(rc,cc),cc=cs,ce)
end do rows
write (out,"()")
end do pages
end subroutine print_complex_matrix
subroutine print_quad_complex_matrix(m,w,f)
complex(xrk), intent(in) :: m(:,:) ! Matrix to be printed
integer(ik), intent(in) :: w ! Field width
character(len=*), intent(in) :: f ! Format to use for number conversion
!
integer(ik) :: nr, nc ! number of rows and columns in the matrix
integer(ik) :: cpp ! columns per page of the output
integer(ik) :: cs, ce ! starting and ending columns
integer(ik) :: cc, rc ! column and row being processed now
character(len=200) :: fmt_head ! Format for the header
character(len=200) :: fmt_line ! Format for the data line
!
nr = size(m,dim=1)
nc = size(m,dim=2)
!
if (w<6) stop 'printing%print_quad_complex_matrix - logic error 1'
cpp = (page_width-6) / (3+2*w)
if (cpp<1) stop 'printing%print_quad_complex_matrix - logic error 2'
!
write (fmt_head,"('(6x,',i0,'(4x,i6,',i0,'x))')") cpp, 3+2*w-10
write (fmt_line,"('(i6,',i0,'(2x,',a,',1x,',a,'))')") cpp, f, f
!
pages: do cs=1,nc,cpp
ce = min(nc,cs+cpp-1)
write (out,fmt=trim(fmt_head)) (cc,cc=cs,ce)
rows: do rc=1,nr
write (out,fmt=trim(fmt_line)) rc,(m(rc,cc),cc=cs,ce)
end do rows
write (out,"()")
end do pages
end subroutine print_quad_complex_matrix
subroutine print_real_matrix(m,w,f)
real(rk), intent(in) :: m(:,:) ! Matrix to be printed
integer(ik), intent(in) :: w ! Field width
character(len=*), intent(in) :: f ! Format to use for number conversion
!
integer(ik) :: nr, nc ! number of rows and columns in the matrix
integer(ik) :: cpp ! columns per page of the output
integer(ik) :: cs, ce ! starting and ending columns
integer(ik) :: cc, rc ! column and row being processed now
character(len=200) :: fmt_head ! Format for the header
character(len=200) :: fmt_line ! Format for the data line
!
nr = size(m,dim=1)
nc = size(m,dim=2)
!
if (w<8) stop 'printing%print_real_matrix - logic error 1'
cpp = (page_width-6) / (3+w)
if (cpp<1) stop 'printing%print_real_matrix - logic error 2'
!
write (fmt_head,"('(6x,1x,',i0,'(3x,i6,',i0,'x))')") cpp, 1+w-9
write (fmt_line,"('(i6,1x,',i0,'(1x,',a,'))')") cpp, f
!
pages: do cs=1,nc,cpp
ce = min(nc,cs+cpp-1)
write (out,fmt=trim(fmt_head)) (cc,cc=cs,ce)
rows: do rc=1,nr
write (out,fmt=trim(fmt_line)) rc,(m(rc,cc),cc=cs,ce)
end do rows
write (out,"()")
end do pages
end subroutine print_real_matrix
subroutine print_quad_matrix(m,w,f)
real(xrk), intent(in) :: m(:,:) ! Matrix to be printed
integer(ik), intent(in) :: w ! Field width
character(len=*), intent(in) :: f ! Format to use for number conversion
!
integer(ik) :: nr, nc ! number of rows and columns in the matrix
integer(ik) :: cpp ! columns per page of the output
integer(ik) :: cs, ce ! starting and ending columns
integer(ik) :: cc, rc ! column and row being processed now
character(len=200) :: fmt_head ! Format for the header
character(len=200) :: fmt_line ! Format for the data line
!
nr = size(m,dim=1)
nc = size(m,dim=2)
!
if (w<8) stop 'printing%print_real_matrix - logic error 1'
cpp = (page_width-6) / (3+w)
if (cpp<1) stop 'printing%print_real_matrix - logic error 2'
!
write (fmt_head,"('(6x,1x,',i0,'(3x,i6,',i0,'x))')") cpp, 1+w-9
write (fmt_line,"('(i6,1x,',i0,'(1x,',a,'))')") cpp, f
!
pages: do cs=1,nc,cpp
ce = min(nc,cs+cpp-1)
write (out,fmt=trim(fmt_head)) (cc,cc=cs,ce)
rows: do rc=1,nr
write (out,fmt=trim(fmt_line)) rc,(m(rc,cc),cc=cs,ce)
end do rows
write (out,"()")
end do pages
end subroutine print_quad_matrix
end module printing