rand0.f90 679 B

123456789101112131415161718192021222324252627
  1. program rand0
  2. ! rand0.f90
  3. ! This file creates a random vector of size n and stores it in rand0.dat
  4. ! Author: Sebastien Duminil
  5. implicit none
  6. integer n,i,init(4)
  7. real(kind=8),allocatable,dimension(:) ::x
  8. integer*4,dimension(3) ::timearray
  9. real ::rand
  10. call itime(timearray) ! Get the current time
  11. i = rand ( timearray(1)+timearray(2)+timearray(3) )
  12. open(unit=20,file='inputfile.dat',status='old')
  13. read(20,*)init
  14. n=init(1)
  15. close(20)
  16. allocate(x(n))
  17. do i=1,n
  18. x(i)=rand(0);
  19. enddo
  20. open(unit=10,file='rand0.dat',status='unknown')
  21. do i=1,n
  22. write(unit=10,FMT=*) x(i)
  23. enddo
  24. close(10)
  25. deallocate(x)
  26. end program rand0