Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time difference

Status
Not open for further replies.

fanta2

Technical User
Apr 10, 2005
78
CA
How can I determine how much time a programme needs for running?
like

starttime = day/hour/min
.
.
code
.
.stoptime= da/hour/min
timedifference = stoptime - starttime

can anyone help me the effective method to evaluate the time difference?
 
Hello fanta2
Try this (the result is in seconds):

Program ttt

integer*4 ihr,imin,isec,i100th
real*8 time,time1,time2

call gettim(ihr,imin,isec,i100th)
time1 = 60.*(60.*ihr+imin) + isec + i100th/100.

c ......
c code
c ......

call gettim(ihr,imin,isec,i100th)
time2 = 60.*(60.*ihr+imin) + isec + i100th/100.

time = time2-time1

write(*,'(1x,f12.2)') time

end

Best wishes
GulliPe
 
Ok thanks it works well but what will happen if the execution time is greater than 24 hours.
 
In the Salford documentation I found this example for an intrinsic function cpu_time:

Code:
real time1, time2
call cpu_time(time1)
...
...
! process
...
...
call cpu_time(time2)
print*,'processing time: ',time2-time1,' seconds'
end
Negative value of time denotes error condition. I could not check if there are any limits as to the time (I do not have such monsters running for days on end ;-)) .

Norbert
 
Thanks - it works great. It gives me the time difference in seconds. I think I can convert the time to minutes or hours if necessary :)
 
One more question - does the cpu_time function return the time elapsed from the start of the programme until the line of code for cpu_time?
 
I do not know - and the docs are unclear of this - what cpu time actually is. I did not check on this, just taking the differtence in seconds was okay for me - I never worked out, what cpu_time=0 might be. But taking time1 immediately after program start and time2 immediately before stop should come as close as could be to total elapsed time.

Norbert

 
There is
Code:
SUBROUTINE SECONDS_SINCE_1980@(DR)
REAL(KIND=2) DR
in Salford FTN95 RTL.
Salford FTN95 said:
...should be used when making timings which straddle midnigt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top