fortran 中时间问题的操作
(2014-03-17 22:41:08)| 分类: fortran |
time、ctime、ltime 和 gmtime:获取系统时间
这些例程具有以下函数:
|
标准版本:获取以整数表示的系统时间(自 GMT 1970 年 1 月 1 日 0 时起至今的秒数) VMS 版本:获取以字符表示的系统时间 (hh:mm:ss) |
|
|
将系统时间转换为 ASCII 字符串。 |
|
|
将系统时间分解成当地时间的月份、日期等等。 |
|
|
将系统时间分解成 GMT 时间的月份、日期等等。 |
time:获取系统时间
time() 函数的调用方式如下所示:
|
INTEGER*4
time n |
|||
|
返回值 |
INTEGER(4) |
输出 |
自 GMT 1970 年 1 月 1 日 0:0:0 时起至今的时间(秒) |
| |
INTEGER(8) |
输出 |
在 64 位环境中,time |
函数
示例:在操作系统中使用的
demo% cat ttime.f
INTEGER*4 n, time
n = time()
write(*,*) ’Seconds since 0 1/1/70 GMT = ’, n
end
demo% f95 ttime.f
demo% a.out
Seconds since 0 1/1/70 GMT = 913240205
demo%
|
ctime:将系统时间转换为字符
函数
该函数的调用方式如下所示:
|
CHARACTER ctime*24 string |
|||
|
stime |
INTEGER*4 |
输入 |
通过 |
|
返回值 |
character*24 |
输出 |
以字符串表示的系统时间。ctime |
下面的示例中显示了
示例:ctime():
demo% cat tctime.f
character*24 ctime, string
INTEGER*4 n, time
n = time()
string = ctime( n )
write(*,*) ’ctime: ’, string
end
demo% f95 tctime.f
demo% a.out
ctime: Wed Dec 9 13:50:05 1998
demo%
|
ltime:将系统时间分解成月份、日期等(当地时间)
该子例程的调用方式如下所示:
|
call
ltime( |
|||
|
stime |
INTEGER*4 |
输入 |
通过 |
|
tarray |
INTEGER*4(9) |
输出 |
当地系统时间,包括年份、月份、日期等 |
有关
demo% cat tltime.f
integer*4 stime, tarray(9), time
stime = time()
call ltime( stime, tarray )
write(*,*) ’ltime: ’, tarray
end
demo% f95 tltime.f
demo% a.out
ltime: 25 49 10 12 7 91 1 223 1
demo%
|
gmtime:将系统时间分解成月份、日期等 (GMT)
该例程将系统时间分解成 GMT 时间的月份、日期等。
此子例程的调用方式如下所示:
|
call
gmtime( |
|||
|
stime |
INTEGER*4 |
输入 |
通过 |
|
tarray |
INTEGER*4(9) |
输出 |
GMT 系统时间,包括年份、月份、日期等 |
demo% cat tgmtime.f
integer*4 stime, tarray(9), time
stime = time()
call gmtime( stime, tarray )
write(*,*) ’gmtime: ’, tarray
end
demo% f95t tgmtime.f
demo% a.out
gmtime: 12 44 19 18 5 94 6 168 0
demo%
|
下面是
|
1 2 3 4 5 |
秒 (0 - 61) 分钟 (0 - 59) 小时 (0 - 23) 一个月中的天数 (1 - 31) 自一月起的月份 (0 - 11) |
6 7 8 9 |
年份-1900 星期几(星期日= 0) 一年中的天数 (0 - 365) 夏令时,如果实行夏令时,则为 1。 |

加载中…