FLASH-X
Doxygen Generated Documentation From Interface Source Code
ut_printMatrix.F90
Go to the documentation of this file.
1!! NOTICE
2!! Copyright 2022 UChicago Argonne, LLC and contributors
3!!
4!! Licensed under the Apache License, Version 2.0 (the "License");
5!! you may not use this file except in compliance with the License.
6!!
7!! Unless required by applicable law or agreed to in writing, software
8!! distributed under the License is distributed on an "AS IS" BASIS,
9!! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10!! See the License for the specific language governing permissions and
11!! limitations under the License.
12!!
41
42subroutine ut_printMatrix (fileUnit, &
43 title, &
44 rowMinMatrix, rowMaxMatrix, &
45 colMinMatrix, colMaxMatrix, &
46 rowMinPrint , rowMaxPrint, &
47 colMinPrint , colMaxPrint, &
48 matrix )
49
51
52 implicit none
53
54 integer, intent (in) :: fileUnit
55 character (len=*), intent (in) :: title
56 integer, intent (in) :: rowMinMatrix, rowMaxMatrix
57 integer, intent (in) :: colMinMatrix, colMaxMatrix
58 integer, intent (in) :: rowMinPrint , rowMaxPrint
59 integer, intent (in) :: colMinPrint , colMaxPrint
60 real, intent (in) :: matrix (rowMinMatrix : rowMaxMatrix , colMinMatrix : colMaxMatrix)
61
62 integer :: block
63 integer :: col, colBeg, colEnd
64 integer :: nColBlocks, nColTotal
65 integer :: row
66
67 integer, parameter :: nColPerBlock = 10
68!
69!
70! ...Print out the title.
71!
72!
73 write (fileUnit,'(/)')
74 write (fileUnit,'(a)') title
75 write (fileUnit,'(/)')
76!
77!
78! ...Check, if printing index ranges are ok.
79!
80!
81 if (rowMaxPrint > rowMaxMatrix .or. rowMinPrint < rowMinMatrix) then
82 call Driver_abort("ut_printMatrix: Matrix row printing range out of bounds")
83 end if
84
85 if (colMaxPrint > colMaxMatrix .or. colMinPrint < colMinMatrix) then
86 call Driver_abort("ut_printMatrix: Matrix column printing range out of bounds")
87 end if
88
89 if (rowMinPrint > rowMaxPrint .or. colMinPrint > colMaxPrint) then
90 call Driver_abort("ut_printMatrix: No matrix printing range!")
91 end if
92!
93!
94! ...Everything ok. Start the printing.
95!
96!
97 nColTotal = colMaxPrint - colMinPrint + 1
98 nColBlocks = nColTotal / nColPerBlock
99!
100!
101! ...Print all full column blocks.
102!
103!
104 colEnd = colMinPrint - 1
105
106 do block = 1,nColBlocks
107
108 colBeg = colEnd + 1
109 colEnd = colEnd + nColPerBlock
110
111 write (fileUnit,'(/,1x,10i14)') (col , col = colBeg , colEnd)
112 write (fileUnit,'(/)')
113
114 do row = rowMinPrint ,rowMaxPrint
115 write (fileUnit,'(i6,10es14.6)') row, (matrix(row,col), col = colBeg , colEnd)
116 end do
117
118 end do
119!
120!
121! ...Print remaining partial column block (if any).
122!
123!
124 colBeg = colEnd + 1
125
126 if (colBeg > colMaxPrint) return
127
128 write (fileUnit,'(/,1x,10i14)') (col , col = colBeg , colMaxPrint)
129 write (fileUnit,'(/)')
130
131 do row = rowMinPrint ,rowMaxPrint
132 write (fileUnit,'(i6,10es14.6)') row, (matrix(row,col), col = colBeg , colMaxPrint)
133 end do
134!
135!
136! ...Ready!
137!
138!
139 return
140end subroutine ut_printMatrix
subroutine ut_printMatrix(fileUnit, title, rowMinMatrix, rowMaxMatrix, colMinMatrix, colMaxMatrix, rowMinPrint, rowMaxPrint, colMinPrint, colMaxPrint, matrix)