2 ! PR 96843 - this was wrongly rejected.
3 ! Test case by William Clodius.
5 module test_shape_mismatch
6 ! Implements zero based bitsets of size up to HUGE(0_INT32).
7 ! The current code uses 32 bit integers to store the bits and uses all 32 bits.
8 ! The code assumes two's complement integers, and treats negative integers as
9 ! having the sign bit set.
12 iso_fortran_env
, only
: &
14 block_kind
=> int64
, &
22 integer, parameter :: &
23 block_size
= bit_size(0_block_kind
), &
24 block_shift
= int( ceiling( log( real(block_size
, dp
) )/log(2._dp
) ) )
35 type, abstract
:: bitset_t
37 integer(bits_kind
) :: num_bits
42 type, extends(bitset_t
) :: bitset_large
44 integer(block_kind
), private
, allocatable
:: blocks(:)
50 pure
module subroutine assign_log8_large( self
, alogical
)
51 !! Used to define assignment from an array of type LOG for bitset_t
52 type(bitset_large
), intent(out
) :: self
53 logical(int8
), intent(in
) :: alogical(:)
54 end subroutine assign_log8_large
60 pure
module subroutine assign_log8_large( self
, alogical
)
61 ! Used to define assignment from an array of type LOG for bitset_t
62 type(bitset_large
), intent(out
) :: self
63 logical(int8
), intent(in
) :: alogical(:)
65 integer(bits_kind
) :: blocks
66 integer(bits_kind
) :: log_size
67 integer(bits_kind
) :: index
69 log_size
= size( alogical
, kind
=bits_kind
)
70 self
% num_bits
= log_size
71 if ( log_size
== 0 ) then
75 blocks
= (log_size
-1)/block_size
+ 1
78 allocate( self
% blocks( blocks
) )
82 end subroutine assign_log8_large
84 end module test_shape_mismatch