Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generation of different random number

Status
Not open for further replies.

Am_Ine

Programmer
Jan 13, 2020
4
DZ
hi every one,

in a random numbers generation subroutine written with fortran
i get the same random number in each copilation and i want different number in each compilation
to generate differente random numbers each compilation , i have use the function'' init_random-seed()'' but it doesn't works with me
i get :
/tmp/cc4kPuvl.o: In function `MAIN__':
main.f95:(.text+0x18): undefined reference to `init_random_seed_'
collect2: error: ld returned 1 exit status

does any one know how to fix that?
 
Hi, this is a code for FORTRAN 90, it will give you 10 random numbers, you can play with the loop.

program aleatorio
implicit none
integer :: i
real :: x

call random_number (x)
write(*,*) x !prints out just ONE random number

do i=1,10 !prints out ten random numbers
call random_number (x)
write(*,*)x
enddo

endprogram aleatorio

I hope this works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top