rand0.f90 652 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. implicit none
  5. integer n,i,init(4)
  6. real(kind=8),allocatable,dimension(:) ::x
  7. integer*4,dimension(3) ::timearray
  8. real ::rand
  9. call itime(timearray) ! Get the current time
  10. i = rand ( timearray(1)+timearray(2)+timearray(3) )
  11. open(unit=20,file='inputfile.dat',status='old')
  12. read(20,*)init
  13. n=init(1)
  14. close(20)
  15. allocate(x(n))
  16. do i=1,n
  17. x(i)=rand(0);
  18. enddo
  19. open(unit=10,file='rand0.dat',status='unknown')
  20. do i=1,n
  21. write(unit=10,FMT=*) x(i)
  22. enddo
  23. close(10)
  24. deallocate(x)
  25. end program rand0