lundi 31 janvier 2022

Same random numbers in each run in Fortran [duplicate]

I have the below Fortran code:

program Looops
  implicit none 
  
  integer, parameter:: PPPP = 3.1415     
  real*8 , Dimension(:) , allocatable  ::dkk25,dkk26,dkk27,dkk28 
  integer:: n_38
  
  Allocate(dkk25(40))
  Allocate(dkk26(40))
  Allocate(dkk27(40))
  Allocate(dkk28(40))

  call RANDOM_NUMBER(dkk25)
  call RANDOM_NUMBER(dkk26)
  dkk27(:) = sqrt(-2*log((dkk25(:))))*cos(2*pppp*(dkk26(:)))

  do n_38 = 1 , 40
    dkk28(n_38) = ((dkk27(n_38)-(sum(dkk27)/40))**2)/(40-1)
  end do
  
  print*,dkk25
end program Looops

In each run of this code I have same value of dkk25 and dkk26. I want to generate different random number in each run.




Aucun commentaire:

Enregistrer un commentaire