Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(warnings): Wconversion with gfortran-13.2 compilation #3

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading