问题
I am trying to compile the following code with gfortran
program perm_field
implicit double precision(a-h,o-z)
parameter (pi=3.14159)
allocatable :: perm(:),alog_perm_all(:),u(:),xi(:),&
perm_zone(:),alog_perm(:)
integer :: seed(2)
external dgemm
open(unit=1,file='input.dat')
open(unit=3,file='random_log_perm.dat',access='append')
open(unit=31,file='random_log_perm_initial.dat',access='append')
open(unit=4,file='isim.dat')
open(unit=7,file='random_log_perm_updated.dat')
open(unit=5,file='kalman_index.dat')
open(unit=6,file='nsim.dat')
open(unit=8,file='perm_zone.dat')
open(unit=111,file='perm.dat')
read(4,*) isim
seed(1)=isim;
call random_seed(put=seed(1:2))
call random_number(u)
But this is giving me error
call random_seed(put=seed(1:2))
1
Error: Size of 'put' argument of 'random_seed' intrinsic at (1) too small (2/8)
It had worked with ifort, but I need to compile it using gfortran now. What might be the problem and how to solve this issue?
回答1:
Reading the documentation on random_seed(). It states that put
must be larger than or equal to the number returned by size
.
So on my system a very quick test says seed
should be at least 12.
program seed_test
implicit none
integer n
n = 0
call random_seed(size=n)
write(*,*) 'n = ', n
end program seed_test
When I compile and run it:
$ gfortran -o seed_test seed_test.f90
$ ./seed_test
n = 12
$
According to your error it must be at least 8.
来源:https://stackoverflow.com/questions/29987816/gfortran-compilation-error-size-of-put-argument-of-random-seed-intrinsic-at