On Thu, Apr 28, 2005 at 05:11:11PM +0100, V Nyirongo
wrote:> Dear all,
>
> Am new on this list but need help:
>
> I have a fortran code which I compile into a dynamic library (on Solaris).
>
> My probem is that when I call this code soon after starting R, it runs ok.
> But it doesn't for the second time without exiting R first. In this
code I
> have to generate some random numbers. The problem is not about setting the
> seed.
>
> Anyone with an idea what might be going on?
>
> Thanks,
> Vysaul.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
Dear Vysaul,
You can call srand to set the seed.
implicit none
integer i,seed,time
seed=time()*2-13
call srand(seed)
print*,rand(0)
do 10 i= 1, 10
print*, rand(0)
10 continue
end
At least g77 can support srand and rand
Good luck.
--
Yours Sincerely
Shusong Jin
==============================================================Add: Meng Wah
Complex, RM518 Email: jinss at hkusua.hku.hk
Dept. of Statistics Tel: (+852)28597942
and Actuarial Science fax: (+852)28589041
The Univ. of Hong Kong
Pokfulam Road, Hong Kong