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

put argument of random_seed should not be a fixed-size array #284

Open
Beliavsky opened this issue Jan 13, 2025 · 0 comments
Open

put argument of random_seed should not be a fixed-size array #284

Beliavsky opened this issue Jan 13, 2025 · 0 comments
Labels
rule A new rule for the linter

Comments

@Beliavsky
Copy link

The code

program main
implicit none
integer :: seeds(8)
integer, parameter :: dp=kind(1.0d0)
real(kind=dp) :: x
seeds = 0
call random_seed(put=seeds)
call random_number(x)
print*,x
end program main

compiles and runs with gfortran, but it is not portable, because the size of the seed used by random_number is platform-dependent. So the put argument should be an allocatable array whose size has been set with

call random_seed(size=size)
allocate(seeds(size))

So I suggest that Fortitude complain when the put argument is a fixed-size array.

@ZedThree ZedThree added the rule A new rule for the linter label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule A new rule for the linter
Projects
None yet
Development

No branches or pull requests

2 participants