Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !Exemplo de utilizacao das funcoes intrinsicas srand e rand
- !
- ! Determina o valor da semente chamando srand
- real :: t1=0., t2=0.
- integer :: zeros = 0, uns = 0
- real :: aleat = -90.23,cpu
- character(8) :: date
- character(10) :: time
- character(5) :: zone
- integer,dimension(8) :: values
- ! using keyword arguments
- call date_and_time(date,time,zone,values)
- call date_and_time(DATE=date,ZONE=zone)
- call date_and_time(TIME=time)
- call date_and_time(VALUES=values)
- print '(a,2x,a,2x,a)', date, time, zone
- print '(8i5)', values
- ! inicio do progcessamento
- call cpu_time(t1)
- !
- call random_seed()
- ! Gera 10 valores
- do i=1,3000
- aleat= aleat*i
- call cpu_time(aleat)
- cpu = aleat
- call random_number(aleat)
- if (nint(aleat).eq.0) then
- zeros = zeros + 1
- else
- uns = uns + 1
- endif
- enddo
- print*,'zeros: ',zeros,' uns: ',uns
- print*,modulo(zeros,uns)
- call cpu_time(t2)
- print '(/60("_")/)'
- print*,'Executado em: ',t2-t1,' segundos'
- stop
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement