方式一:
real timebegin,timeend
call cpu_time(timebegin)
.......................
call cpu_time(timeend)
write(*,*) ' The block of codes wastes ',timeend-timebegin,' seconds'
注:CPU_TIME得到的时间是多个cpu的总时间,因此假如正好有两个CPU在并行工作,则CPU_TIME获得的时间是两个CPU时间的和,实际运行时间是其返回值的一半。
方式二:
use IFPort
real*8 timebegin,timeend
timebegin=RTC( )
..........................
timeend=RTC( )
write(*,*) 'The block of codes wastes ',timeend-timebegin,'seconds'
注:最后获得的是程序块的运行时间。
方式三:
integer timebegin,timeend
call system_clock(timebegin)
...............................
call system_clock(timeend)
write(*,*) 'The whole program wastes ',timeend-timebegin,'secon‘
方式四:
real*8 timebegin,timeend // real*8 表示双精度
timebegin=omp_get_wtime()
.......................................
timeend=omp_get_wtime()
write(*,*) 'The whole program wastes ',timeend-timebegin,'seconds'