fortran时间函数获得的数据的单位是什么? 例如cpu_time,date_and_time,system_clock 得到的数的单位是什么
2个回答
展开全部
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
摘自 http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gfortran/CPU_005fTIME.html
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
摘自 http://gcc.gnu.org/onlinedocs/gfortran/DATE_005fAND_005fTIME.html
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
摘自 http://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html
示例:
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
摘自 http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gfortran/CPU_005fTIME.html
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
摘自 http://gcc.gnu.org/onlinedocs/gfortran/DATE_005fAND_005fTIME.html
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
摘自 http://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
据,定义一个变量,如果有多列,需要多个变量来对应。程序如下
Program main
Real *8 a
a=0.d0
SUM=0.d0
Open(UNIT=2,FILE='***.txt',STATUS='OLD')
Do 10,i=1,1000 !(假设里面有1000个数,或者不足1000)
Read(2,*) a
SUM=SUM+a
10 Continue
Write(*,*) SUM !即最后的求和结果
end
Program main
Real *8 a
a=0.d0
SUM=0.d0
Open(UNIT=2,FILE='***.txt',STATUS='OLD')
Do 10,i=1,1000 !(假设里面有1000个数,或者不足1000)
Read(2,*) a
SUM=SUM+a
10 Continue
Write(*,*) SUM !即最后的求和结果
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询