Problem with time function

1 view
Skip to first unread message

Stanley Williams

unread,
Aug 14, 2009, 11:44:21 AM8/14/09
to gg...@googlegroups.com
The only time function that appears to work is secnds. The test program
follows. Below the code is the results I had when I ran the program. Any
suggestions to make all functions work correctly would be appreciated.

program test2
INTEGER FUNCTION secnds
INTEGER FUNCTION time
REAL FUNCTION etime
dimension tarray(2), x2(2)
real iss
iss = 0
ix1 = secnds(iss)
write(6,*)' INTEGER FUNCTION secnds'
write(6,*)' ix1=', ix1,' secnds(iss)=',iss
ihr = ix1/3600
imin = (ix1 - ihr*3600)/60
isec = ix1 - (ihr*3600 +imin*60)
write(6,*)' IHR=',ihr,' IMIN=',imin,' ISEC=',isec
write(6,*)' '
c
tarray(1) = 0.0
tarray(2) = 0.0
x2 = etime(tarray)
write(6,*)' REAL FUNCTION etime'
write(6,*)' x2(1)=',x2(1),' x2(2)=',x2(2)
write(6,*)' tarray(1)=',tarray(1),' tarray(2)=',tarray(2)
write(6,*)' '
c
c
ix3 = time*1
jx1 = ix3/3600 ! hour
jx2 = (ix3 - 3600*jx1)/60 ! minute
jx3 = ix3 - (jx1*3600 + jx2*60) ! seconds
write(6,*)' INTTEGER FUNCTION time'
write(6,*)' ix3 =',ix3
write(6,*)' ix3 =',ix3,' jx1=',jx1,' HR jx2=',jx2,' min jx3=',jx3
1,' sec'
end

>a.out
INTEGER FUNCTION secnds
ix1= 36898 secnds(iss)= 0.
IHR= 10 IMIN= 14 ISEC= 58

REAL FUNCTION etime
x2(1)= 0.0014800001 x2(2)= 0.0014800001
tarray(1)= 0.000391 tarray(2)= 0.001089

INTTEGER FUNCTION time
ix3 = 0
ix3 = 0 jx1= 0 HR jx2= 0 min jx3= 0 sec
>


Jimmy

unread,
Aug 16, 2009, 11:04:15 AM8/16/09
to gg...@googlegroups.com
What Fortran system did you use - INTEGER FUNCTION 'secnds' etc properly
fails to compile when using g95 for Fortran 95. The time functions seem to
work okay on my PC using g95-MinGW.exe. For your test of 'etime' the
answers don't look wrong: x2 should be a scalar so in your case x2(1) is set
equal to x2(2). Your 'time' doesn't work because g95 for Fortran 95
requires that your 'time*1' is replaced by time()*1 . Hope this helps a
bit.

Jimmy.

Stan

unread,
Aug 17, 2009, 1:16:07 PM8/17/09
to gg95
It is old fashioned f77. Similar to main.f. The only function that
works for me is secnds. The others fail as illustrated in the print
below a.out.

Stan

Jimmy

unread,
Aug 18, 2009, 4:48:34 AM8/18/09
to gg...@googlegroups.com
Okay, my previous comments below still apply. The Unix time should appear as
something like 1250584185 when ix3 = time*1 is replaced by ix3 = time()*1.
G95 is a great Fortran 95 compiler and I would recommend translating old
code into Fortran 95 where not unduly onerous or error prone.
Reply all
Reply to author
Forward
0 new messages