2 ! Tests the fix for PR4164656 in which the call to a%a%scal failed to compile.
4 ! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>
7 integer, parameter :: longndig=12
8 integer, parameter :: long_int_k_ = selected_int_kind(longndig)
9 integer, parameter :: dpk_ = kind(1.d0)
10 integer, parameter :: spk_ = kind(1.e0)
15 type :: base_sparse_mat
16 integer, private :: m, n
17 integer, private :: state, duplicate
18 logical, private :: triangle, unitd, upper, sorted
20 procedure, pass(a) :: get_nzeros
21 end type base_sparse_mat
24 function get_nzeros(a) result(res)
26 class(base_sparse_mat), intent(in) :: a
29 character(len=20) :: name='base_get_nzeros'
30 logical, parameter :: debug=.false.
32 end function get_nzeros
33 end module base_mat_mod
37 type, extends(base_sparse_mat) :: s_base_sparse_mat
39 procedure, pass(a) :: s_scals
40 procedure, pass(a) :: s_scal
41 generic, public :: scal => s_scals, s_scal
42 end type s_base_sparse_mat
43 private :: s_scals, s_scal
45 type, extends(s_base_sparse_mat) :: s_coo_sparse_mat
48 integer, allocatable :: ia(:), ja(:)
49 real(spk_), allocatable :: val(:)
51 procedure, pass(a) :: get_nzeros => s_coo_get_nzeros
52 procedure, pass(a) :: s_scals => s_coo_scals
53 procedure, pass(a) :: s_scal => s_coo_scal
54 end type s_coo_sparse_mat
55 private :: s_coo_scals, s_coo_scal, s_coo_get_nzeros
57 subroutine s_scals(d,a,info)
59 class(s_base_sparse_mat), intent(inout) :: a
60 real(spk_), intent(in) :: d
61 integer, intent(out) :: info
64 character(len=20) :: name='s_scals'
65 logical, parameter :: debug=.false.
67 ! This is the base version. If we get here
68 ! it means the derived class is incomplete,
69 ! so we throw an error.
71 end subroutine s_scals
74 subroutine s_scal(d,a,info)
76 class(s_base_sparse_mat), intent(inout) :: a
77 real(spk_), intent(in) :: d(:)
78 integer, intent(out) :: info
81 character(len=20) :: name='s_scal'
82 logical, parameter :: debug=.false.
84 ! This is the base version. If we get here
85 ! it means the derived class is incomplete,
86 ! so we throw an error.
90 function s_coo_get_nzeros(a) result(res)
92 class(s_coo_sparse_mat), intent(in) :: a
95 end function s_coo_get_nzeros
98 subroutine s_coo_scal(d,a,info)
101 class(s_coo_sparse_mat), intent(inout) :: a
102 real(spk_), intent(in) :: d(:)
103 integer, intent(out) :: info
105 Integer :: err_act,mnm, i, j, m
106 character(len=20) :: name='scal'
107 logical, parameter :: debug=.false.
109 do i=1,a%get_nzeros()
111 a%val(i) = a%val(i) * d(j)
113 end subroutine s_coo_scal
115 subroutine s_coo_scals(d,a,info)
118 class(s_coo_sparse_mat), intent(inout) :: a
119 real(spk_), intent(in) :: d
120 integer, intent(out) :: info
122 Integer :: err_act,mnm, i, j, m
123 character(len=20) :: name='scal'
124 logical, parameter :: debug=.false.
127 do i=1,a%get_nzeros()
128 a%val(i) = a%val(i) * d
130 end subroutine s_coo_scals
131 end module s_base_mat_mod
136 class(s_base_sparse_mat), pointer :: a
138 procedure, pass(a) :: s_scals
139 procedure, pass(a) :: s_scal
140 generic, public :: scal => s_scals, s_scal
141 end type s_sparse_mat
143 module procedure s_scals, s_scal
146 subroutine s_scal(d,a,info)
149 class(s_sparse_mat), intent(inout) :: a
150 real(spk_), intent(in) :: d(:)
151 integer, intent(out) :: info
153 character(len=20) :: name='csnmi'
154 logical, parameter :: debug=.false.
156 call a%a%scal(d,info)
158 end subroutine s_scal
160 subroutine s_scals(d,a,info)
163 class(s_sparse_mat), intent(inout) :: a
164 real(spk_), intent(in) :: d
165 integer, intent(out) :: info
167 character(len=20) :: name='csnmi'
168 logical, parameter :: debug=.false.
171 call a%a%scal(d,info)
173 end subroutine s_scals
177 class (s_sparse_mat), pointer :: a
178 type (s_sparse_mat), target :: b
179 type (s_base_sparse_mat), target :: c
183 call a%scal (1.0_spk_, info)
184 if (info .ne. 700) call abort