gfortran compilation error: Size of 'put' argument of 'random_seed' intrinsic at (1) too small [duplicate]

孤人 提交于 2021-01-24 07:38:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!