O que há de errado com meu gerador de números aleatórios no Fortran 95, por favor?
Este é um módulo gerador de números randon que eu uso para compilar junto com meu programa principal (não listado aqui). Quando tento compilar meu módulo gerador de números aleatórios para ver se funciona, recebo a seguinte mensagem:
na linha 61: chamar random_seed (put = seed) Erro: tamanho do argumento 'put' de 'random_seed' intrínseco muito pequeno <4/12>
O que isso significa? Como posso corrigir isso?
module random_angle
contains
0
integer Function random_integer (N) ! return a random integer between 1 and N
integer, intent(in) :: N
real*8 :: x
call random_number(x)
random_integer = floor(real(N)*x)+1
end function random_integer
Real*8 Function gasdev() ! ch7.pg.280:gaussian distribution function using ran1 as random # generator
implicit none
! integer, intent(inout) :: idum
integer, save::iset
real*8:: fac,rsq,v1,v2
real*8, dimension(2) :: x
real*8, save :: gset
! if (idum.lt.0) iset=0
if (iset.eq.0) then
rsq = 0.0
do while (rsq > 1.0.or.rsq==0)
call random_number(x)
v1=2.*x(1)-1
v2=2.*x(2)-1
rsq=v1**2+v2**2
! print *, v1, v2,rsq
end do
fac=sqrt(-2.*log(rsq)/rsq)
gset=v1*fac
gasdev=v2*fac
iset=1
else
gasdev=gset
iset=0
endif
return
end Function gasdev
real*8 function NormalRandom (average, stddev)
implicit none
real*8, intent(in):: average, stddev
NormalRandom = average + stddev*gasdev()
end function NormalRandom
subroutine setSEED (seed)
implicit none
real*8:: x
integer, dimension(4), intent(inout):: seed
if (seed(1) == 0.0) &
seed = floor(1000*secnds(0.0)) +(/0, 37, 74, 111 /)
call random_seed( put=seed)
end subroutine setSEED
end module random_angle