Advertisement
zrhans

data-time.f95

Sep 28th, 2014
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. !Exemplo de utilizacao das funcoes intrinsicas srand e rand
  2. !
  3. ! Determina o valor da semente chamando srand
  4.  
  5. real    :: t1=0., t2=0.
  6. integer :: zeros = 0, uns = 0
  7. real    :: aleat = -90.23,cpu
  8.  
  9.         character(8)  :: date
  10.               character(10) :: time
  11.               character(5)  :: zone
  12.               integer,dimension(8) :: values
  13.               ! using keyword arguments
  14.               call date_and_time(date,time,zone,values)
  15.               call date_and_time(DATE=date,ZONE=zone)
  16.               call date_and_time(TIME=time)
  17.               call date_and_time(VALUES=values)
  18.               print '(a,2x,a,2x,a)', date, time, zone
  19.               print '(8i5)', values
  20.  
  21.  
  22.  
  23. ! inicio do progcessamento
  24. call cpu_time(t1)
  25. !
  26. call random_seed()
  27. ! Gera 10 valores
  28. do i=1,3000
  29.     aleat= aleat*i
  30.     call cpu_time(aleat)
  31.     cpu = aleat
  32.     call random_number(aleat)
  33.    
  34.     if (nint(aleat).eq.0) then
  35.         zeros = zeros + 1
  36.     else
  37.         uns = uns + 1
  38.     endif
  39.    
  40. enddo
  41.     print*,'zeros: ',zeros,' uns: ',uns
  42.     print*,modulo(zeros,uns)
  43.  
  44.  
  45. call cpu_time(t2)
  46. print '(/60("_")/)'
  47. print*,'Executado em: ',t2-t1,' segundos'
  48. stop
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement