Skip to content

Commit

Permalink
fix(warnings): Wconversion with gfortran-13.2 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
praynaud committed Feb 22, 2024
1 parent 1668540 commit d254282
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/rngff/linear_congruential_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ elemental subroutine next_int32(self, harvest)
call self%next(tmp)
negative = tmp >= 0.5 ! Use the "first bit" of tmp as a sign
tmp = 2*tmp - merge(1, 0, negative) ! Drop the "first bit" of tmp
harvest = tmp * huge(harvest) * merge(-1, 1, negative)
harvest = int(tmp * huge(harvest) * merge(-1, 1, negative), kind=int32)
end subroutine

elemental subroutine next_int64(self, harvest)
Expand All @@ -63,7 +63,7 @@ elemental subroutine next_int64(self, harvest)
call self%next(tmp)
negative = tmp >= 0.5 ! Use the "first bit" of tmp as a sign
tmp = 2*tmp - merge(1, 0, negative) ! Drop the "first bit" of tmp
harvest = tmp * huge(harvest) * merge(-1, 1, negative)
harvest = int(tmp * real(huge(harvest), kind=real64) * merge(-1, 1, negative), kind=int64)
end subroutine

elemental subroutine next_real32(self, harvest)
Expand All @@ -84,7 +84,7 @@ elemental subroutine next_real32(self, harvest)

z = self%seeds_(1) - self%seeds_(2)
if (z<1) z = z + m(1) - 1
harvest = z * over_m1
harvest = real(z * over_m1, kind=real32)
if (harvest >= 1) harvest = 0
end subroutine

Expand Down
4 changes: 2 additions & 2 deletions test/sanity_checks_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pure function get_distribution_int32(samples, num_bins) result(distribution)
samples_in_bin = 0
bin_width = (real(huge(samples)) / num_bins) * 2
do i = 1, size(samples)
bin = floor(samples(i)/bin_width + huge(samples)/bin_width) + 1
bin = floor(samples(i)/bin_width + real(huge(samples), kind=real32)/bin_width) + 1
samples_in_bin(bin) = samples_in_bin(bin) + 1
end do
distribution = real(samples_in_bin, kind(distribution)) / size(samples)
Expand All @@ -283,7 +283,7 @@ pure function get_distribution_int64(samples, num_bins) result(distribution)
samples_in_bin = 0
bin_width = (real(huge(samples)) / num_bins) * 2
do i = 1, size(samples)
bin = floor(samples(i)/bin_width + huge(samples)/bin_width) + 1
bin = floor(real(samples(i), kind=real32)/bin_width + real(huge(samples), kind=real32)/bin_width) + 1
samples_in_bin(bin) = samples_in_bin(bin) + 1
end do
distribution = real(samples_in_bin, kind(distribution)) / size(samples)
Expand Down

0 comments on commit d254282

Please sign in to comment.