2 ! { dg-options "-fbounds-check" }
4 ! Contributed by Juergen Reuter
5 ! Check that pr65548 is fixed and that the ICE is gone, when bounds-check
11 integer, dimension(:), allocatable
:: map
12 real, dimension(:), allocatable
:: weight
14 procedure
:: init
=> selector_init
19 subroutine selector_init (selector
, weight
)
20 class(selector_t
), intent(out
) :: selector
21 real, dimension(:), intent(in
) :: weight
24 logical, dimension(:), allocatable
:: mask
26 allocate (mask (size (weight
)), source
= weight
/= 0)
29 allocate (selector
%map (n
), &
30 source
= pack ([(i
, i
= 1, size (weight
))], mask
))
31 allocate (selector
%weight (n
), &
32 source
= pack (weight
/ s
, mask
))
34 allocate (selector
%map (1), source
= 1)
35 allocate (selector
%weight (1), source
= 0.)
37 end subroutine selector_init
44 procedure
:: get_mass
=> flavor_get_mass
49 type(flavor_t
), dimension(:,:), allocatable
:: flv
53 class(phs_config_t
), pointer :: config
=> null ()
54 real, dimension(:), allocatable
:: m_in
59 elemental
function flavor_get_mass (flv
) result (mass
)
61 class(flavor_t
), intent(in
) :: flv
63 end function flavor_get_mass
65 subroutine phs_base_init (phs
, phs_config
)
66 class(phs_t
), intent(out
) :: phs
67 class(phs_config_t
), intent(in
), target
:: phs_config
68 phs
%config
=> phs_config
69 allocate (phs
%m_in (phs
%config
%n_in
), &
70 source
= phs_config
%flv(:phs_config
%n_in
, 1)%get_mass ())
71 end subroutine phs_base_init
78 real, dimension(:,:), allocatable
:: val
80 procedure
:: make
=> t_make
81 generic
:: get_int
=> get_int_array
, get_int_element
82 procedure
:: get_int_array
=> t_get_int_array
83 procedure
:: get_int_element
=> t_get_int_element
88 subroutine t_make (this
)
89 class(t
), intent(inout
) :: this
90 real, dimension(:), allocatable
:: int
91 allocate (int (0:this
%n
-1), source
=this
%get_int())
94 pure
function t_get_int_array (this
) result (array
)
95 class(t
), intent(in
) :: this
96 real, dimension(this
%n
) :: array
97 array
= this
%val (0:this
%n
-1, 4)
98 end function t_get_int_array
100 pure
function t_get_int_element (this
, set
) result (element
)
101 class(t
), intent(in
) :: this
102 integer, intent(in
) :: set
104 element
= this
%val (set
, 4)
105 end function t_get_int_element
110 character(32), dimension(:), allocatable
:: md5
112 procedure
:: init
=> t2_init
117 subroutine t2_init (this
)
118 class(t2
), intent(inout
) :: this
119 character(32), dimension(:), allocatable
:: md5
120 allocate (md5 (this
%n
), source
=this
%md5
)
121 if (md5(1) /= "tst ") call abort()
122 if (md5(2) /= " ") call abort()
123 if (md5(3) /= "fooblabar ") call abort()
124 end subroutine t2_init
133 type(selector_t
) :: sel
135 type(phs_config_t
) :: phs_config
139 call sel
%init([2., 0., 3., 0., 4.])
141 if (any(sel
%map /= [1, 3, 5])) call abort()
142 if (any(abs(sel
%weight
- [2., 3., 4.] / 9.) > 1E-6)) call abort()
145 allocate (phs_config
%flv (phs_config
%n_in
, 1))
146 call phs_base_init (phs
, phs_config
)
148 if (any(abs(phs
%m_in
- [42.0, 42.0]) > 1E-6)) call abort()
151 allocate (o
%val(0:1,4))
155 allocate(o2
%md5(o2
%n
))
158 o2
%md5(3) = "fooblabar"