-
Notifications
You must be signed in to change notification settings - Fork 2
/
printer.f90
115 lines (94 loc) · 2.94 KB
/
printer.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
!
! Debugging-Helper: A nice interface to print whatever value you like to see.
module printer
interface p
module procedure printInteger, printReal, print2dMatrix, &
printVector
end interface
contains
! pointers:
subroutine printInteger(iValue)
integer :: iValue
print *, iValue
end subroutine
subroutine printReal(rValue)
real :: rValue
print *, rValue
end subroutine
subroutine print2dMatrix(mValue, arguments)
real, dimension(:,:), pointer :: mValue
character, optional :: arguments
integer :: dimX, dimY
integer :: m, n
dimX = ubound(mValue,1)
dimY = ubound(mValue,2)
if (present(arguments)) then
print *, "---- Verbose Mode -----"
print *, " Size Y: ", size(mValue,1)
print *, " Size X: ", size(mValue,2)
print *, "Lower bound: ", lbound(mValue)
print *, "Upper bound: ", ubound(mValue)
print *, ""
print *, "===== Show Matrix ====="
else
print *, "----- Normal Mode -----"
end if
do m=1,dimX
!write(*,'(f8.3)', advance ='no') "y(", m, ") = "
do n=1,dimY
write(*,'(f8.3)', advance='no') mValue(m,n)
end do
print *, ""
end do
print *, ""
end subroutine
subroutine printVector(vValue, arguments)
real, dimension(:), pointer :: vValue
character, optional :: arguments
integer :: dimY
integer :: m
dimY = ubound(vValue,1)
if (present(arguments)) then
print *, "---- Verbose Mode -----"
print *, "Lower bound: ", lbound(vValue)
print *, "Upper bound: ", ubound(vValue)
print *, ""
print *, "===== Show Vector ====="
else
print *, "----- Normal Mode -----"
end if
do m=1,dimY
print *, vValue(m)
end do
print *, ""
end subroutine
! pointers:
! subroutine print2dMatrixAlloc(aValue)
! integer, dimension(:,:), pointer :: aValue
! integer :: dimX, dimY
! integer :: m, n
!
! dimX = ubound(aValue,1)
! dimY = ubound(aValue,2)
!
! do m=1,dimY
! print *, ""
! !write(*,'(f8.3)', advance ='no') "y(", m, ") = "
! do n=1,dimX
! write(*,'(f8.3)', advance='no') aValue(m,n)
! end do
! end do
! end subroutine
!
! subroutine printVectorAlloc(vValue)
! real, dimension(:), pointer :: vValue
! integer :: dimY
! integer :: m
!
! dimY = ubound(vValue,1)
!
! do m=1,dimY
! print *, vValue(m)
! end do
! end subroutine
end module