2012-09-15 23 views
1

我最近開始學習Fortran 90以獲得它的樂趣,並且我想知道是否有任何簡單的方法來顯示執行我的代碼所用的時間。這只是簡單的循環,數到一百萬,我想看看需要多長時間才能做到這一點。fortran 90簡單的顯示時間的方法

如果有幫助,這裏是我使用的代碼:

program count 
    implicit none 
    integer :: i 

    do i=0,1000000 
     print*,i 
    end do 
end program count 

我使用gFortran作爲我的編譯器的Linux。我使用Geany作爲文本編輯器。

在此先感謝。

回答

2

在Fortran 90中或以後,使用SYSTEM_CLOCK固有子程序:

call system_clock(beginning, rate) 
result = do_computation() 
call system_clock(end) 
print *, "elapsed time: ", real(end - beginning)/real(rate)