Fortran中ssystem_clock函数与CPU_TIME函数不同,对于多线程情况,不会出现重复计算CPU运行时间,是真正的计算时间统计,是衡量程序代码性能的工具之一。
system_clock(count,count_rate,count_max)
count是从世界协调时间1970/1/1
8:0:0开始至当前时间点的时间差值,单位是秒。
如:
1970/1/1 8:0:0
count=0
2017/4/8 12:0:0
count=1491624000
count_rate是指处理器时钟数
count_max是count能达到的最大数,即count在0~count_max之间,但count达到count_max的下一秒,就溢满归0。
count_max=2147483647 对应2038/1/19 11:14:7
program Main
implicit none
integer :: t1, t2, time_cal
call system_clock(t1)
!主体程序
call system_clock(t2)
time_cal=t2-t1
write(*,*) " The program's calculation time is", time_cal,
"seconds"
stop " Calculation is over "
end program Main
subroutine
Time_unit_Conversion(day,hour,minute,second)
implicit none
integer(kind=4) :: icount3,icount4
integer(kind=4) :: day,hour,minute,second
integer(kind=4) ::
time_Diff1,time_Diff2,time_Diff3
icount3=1492571647
icount4=1491654857
time_Diff1=icount3-icount4
day=time_Diff1/86400
time_Diff2=mod(time_Diff1,86400)
hour=time_Diff2/3600
time_Diff3=mod(time_Diff2,3600)
minute=time_Diff3/60
second=mod(time_Diff3,60)
print*,day,hour,minute,second
return
end subroutine
Time_unit_Conversion
新浪简介
|
About Sina
|
广告服务
|
联系我们
|
招聘信息
|
网站律师
|
SINA English
|
产品答疑