fortran时间函数获得的数据的单位是什么?例如cpu_time,date_and_time,system_clock 得到的数的单位是什么

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 03:34:28
fortran时间函数获得的数据的单位是什么?例如cpu_time,date_and_time,system_clock 得到的数的单位是什么

fortran时间函数获得的数据的单位是什么?例如cpu_time,date_and_time,system_clock 得到的数的单位是什么
fortran时间函数获得的数据的单位是什么?例如cpu_time,date_and_time,system_clock 得到的数的单位是什么

fortran时间函数获得的数据的单位是什么?例如cpu_time,date_and_time,system_clock 得到的数的单位是什么
cpu_time返回的是一个浮点型,表示当前CPU运行时间(以秒计)
示例:
program test_cpu_time
real ::start,finish
call cpu_time(start)
!put code to test here
call cpu_time(finish)
print '("Time = ",f6.3," seconds.")',finish-start
end program test_cpu_time
date_and_time稍微复杂,但包括很多信息,包括日期,时间,时区,最后一个参数是一个大小为8的整型数组,记录了年,月,日,时区差(以分钟计),小时,分钟,秒,毫秒.
program test_time_and_date
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
end program test_time_and_date
system_clock用于决定处理器时钟周期.count_rate用于决定每秒CPU的时钟计数,
PROGRAM test_system_clock
INTEGER ::count,count_rate,count_max
CALL SYSTEM_CLOCK(count,count_rate,count_max)
WRITE(*,*) count,count_rate,count_max
END PROGRAM