CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

fortran 95 random_seed() -help!!

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 11, 2011, 02:57
Default fortran 95 random_seed() -help!!
  #1
New Member
 
Demetri
Join Date: Nov 2011
Posts: 1
Rep Power: 0
Apollion is on a distinguished road
Hello everone!So i am writing this code where I am producoing random numbers from a generator through a subroutine.Then I call the subroutine and pass them through a Gaussian distribution.I have problem with my seed subroutine: my program compiles but when i try to execute it complain that "Random_seed(): PUT array too small" i have no idea what does this means!

Here is my subroutine:
subroutine setSEED (seed)
implicit none

real*8:: x
integer, dimension(2), intent(inout):: seed
if (seed(1) == 0.0) &
seed = floor(1000*secnds(0.0)) +(/0, 37 /) <--- this is where it complains
call random_seed(put=seed) <---...and here

end subroutine setSEED

and my gaussian distribution :

Real*8 Function gasdev(idum)
implicit none
integer, intent(inout) :: idum
integer, save::iset
real*8:: fac,rsq,v1,v2
real*8, dimension(2) :: x
real*8, save :: gset
!data iset/0/
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

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

....AND MY MAIN PROGRAM:

program mainprog

implicit none

real*8::angle,gasdev,number
integer::i
integer, dimension(2) :: seed = 0

open(299,FILE='gauss.dat',STATUS='REPLACE')

call setSEED(seed)

Do i=1,10,1


angle=gasdev(seed)
print*,"angle=gasdev =",angle
write(299,*),angle


end do

close(299,STATUS="KEEP")
end program mainprog


Do you guys think can help me?its so frustrating!!!thank you all!!!
Apollion is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran Compiler-CFX12.1 Araz CFX 12 November 2, 2014 13:46
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 hawk Main CFD Forum 1 April 12, 2005 22:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 20:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 16:16
Why Favoring Fortran over C/C++? Zi-Wei Chiou Main CFD Forum 35 September 26, 2001 09:34


All times are GMT -4. The time now is 12:26.