Home > Archive > Fortran > July 2006 > timer function calls in Fortran77
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
timer function calls in Fortran77
|
|
| daniela 2006-07-28, 8:01 am |
| Hi all,
I am new to Fortran and am trying to use Fortran77 function calls to
retrieve the time from my machine.
I could not easily find out information on what calls to use.
Is there any online documentation or any documentation you could point
me at?
Many thanks for your help
Daniela
| |
| Ian Bush 2006-07-28, 8:01 am |
| daniela wrote:
> Hi all,
>
> I am new to Fortran and am trying to use Fortran77 function calls to
> retrieve the time from my machine.
> I could not easily find out information on what calls to use.
>
> Is there any online documentation or any documentation you could point
> me at?
>
In FORTRAN 77 there are no time related intrinsic subprograms at all.
Your implementation may supply some, though.
In Fortran 95 there are, and this is another reason to sue the more
modern standard rather then the quite antiquated version you are using,
Ian
| |
| michael@athenavisual.com 2006-07-28, 8:01 am |
| Here is an example in Fortran 95
! called in Chicago, IL on July 28, 2006
!---------------------------------------
Integer :: dT(8)
Character (len=10) :: time, date, zone
Call date_and_time (date, time, zone, dT)
Write(6,*)
Write(6,'(2X,A10)')trim(date) ! date is assigned the value "20060728"
Write(6,'(2X,A10)')trim(time) ! time is assigned the value
"063921.640"
Write(6,'(2X,I10)')dT(1) ! Year
Write(6,'(2X,I10)')dT(2) ! Month
Write(6,'(2X,I10)')dT(3) ! Day
Write(6,'(2X,I10)')dT(4) ! Time Zone
Write(6,'(2X,I10)')dT(5) ! Hour
Write(6,'(2X,I10)')dT(6) ! Minutes
Write(6,'(2X,I10)')dT(7) ! Seconds
Write(6,'(2X,I10)')dT(8) ! Milliseconds
End
Cheers
Michael
| |
| Tim Prince 2006-07-28, 8:01 am |
| daniela wrote:
> Hi all,
>
> I am new to Fortran and am trying to use Fortran77 function calls to
> retrieve the time from my machine.
> I could not easily find out information on what calls to use.
Most f77 compilers include partial implementations of DATE_AND_TIME and
CPU_TIME which work just like the later standard versions, except for no
keyword and limited optional argument capability. If you are sticking
strictly to f77 for whatever reasons, you have none available.
| |
|
|
|
| Ian Bush wrote:
> daniela wrote:
>
>
> In FORTRAN 77 there are no time related intrinsic subprograms at all.
> Your implementation may supply some, though.
>
> In Fortran 95 there are, and this is another reason to sue the more
> modern standard rather then the quite antiquated version you are using,
>
> Ian
>
And in case you are not aware of it, Fortran 95 is a superset of Fortran
77 (give or take a couple of quibbles), so you lose nothing by switching.
JA
| |
| Dylan Sung 2006-07-30, 7:59 am |
|
"Leif Harcke" <lharcke@stanfordalumni.org> wrote in message
news:pan.2006.07.29.07.02.23.436996@stanfordalumni.org...
> On Fri, 28 Jul 2006 04:06:55 -0700, daniela wrote:
>
> http://gcc.gnu.org/onlinedocs/gcc-3...-Functions.html
>
>
I'm using Lepsch's Force 2.08 which implements g77 as the compiler, and the
above table of intrinsic functions has
CALL Date_and_Time(Date, Time, Zone, Values)
as the subroutine call, which I've written as
c234567890123456789012345678901234567890
1234567890123456789
CALL Date_and_Time(Date, Time, Zone, Values)
print*,date,time,zone,values
end
however during compiling, the following error is noted
C:\f77progs\date.f: In program `MAIN__':
C:\f77progs\date.f:1:
CALL Date_and_Time(Date, Time, Zone, Values)
^
Reference to intrinsic `DATE_AND_TIME' at (^) invalid -- one or more
arguments have incorrect type
After declaring the data types
character date*8, time*9, zone*5
integer values
CALL Date_and_Time(Date, Time, Zone, Values)
print*,date,time,zone,values
end
The error became
CALL Date_and_Time(Date, Time, Zone, Values)
^
Too many arguments passed to intrinsic `DATE_AND_TIME' at (^)
Is this because this intrinsic is a library function that needs to be
linked? If so, what's the library that contains it?
Cheers,
Dyl.
| |
|
| > character date*8, time*9, zone*5
> integer values
> CALL Date_and_Time(Date, Time, Zone, Values)
> print*,date,time,zone,values
> end
>
> The error became
>
> CALL Date_and_Time(Date, Time, Zone, Values)
> ^
> Too many arguments passed to intrinsic `DATE_AND_TIME' at (^)
The message error is far from helpful, but the error is due to the fact
that the last argument of date_and_time, values, must be of dn array of
dimension >= 8. See the doc at
http://gcc.gnu.org/onlinedocs/gcc-3...-Intrinsic.html
--
FX
| |
| Dylan Sung 2006-07-30, 7:59 am |
|
"FX" <coudert@alussinan.org> wrote in message
news:eai3ed$2rlt$1@nef.ens.fr...
>
> The message error is far from helpful, but the error is due to the fact
> that the last argument of date_and_time, values, must be of dn array of
> dimension >= 8. See the doc at
> http://gcc.gnu.org/onlinedocs/gcc-3...-Intrinsic.html
>
> --
> FX
Thanks, I forgot to do that bit... Here it is all again. And the results.
c234567890123456789012345678901234567890
1234567890
character date*8, time*9, zone*5
integer values(8)
CALL Date_and_Time(Date, Time, Zone, Values)
print*,date,time,zone,values
open(1,file='data-time.txt')
write(1,*)date,time,zone,values
close(1)
stop
end
c234567890123456789012345678901234567890
1234567890
Results:
20060730122235.00+0100 2006 7 30 60 12 22 35 0
Cheers,
Dyl.
| |
| John Harper 2006-07-30, 7:01 pm |
| In article <1154084815.505145.192710@i42g2000cwa.googlegroups.com>,
daniela <d.strat@dage-group.com> wrote:
>Hi all,
>
>I am new to Fortran and am trying to use Fortran77 function calls to
>retrieve the time from my machine.
>I could not easily find out information on what calls to use.
>
>Is there any online documentation or any documentation you could point
>me at?
Probably, but in Fortran 77 there was no standard way to do it.
Most vendors supplied their own. So you will _either_ have to look in
your compiler-vendor's documentation (you didn't tell us which compiler
you used on what system, but it makes a difference) _or_ use f95.
In f95 there are 3 standard subroutines that will tell you:
DATE_AND_TIME giving the date and "wall clock" time
CPU_TIME giving the amount of "processor" time your program has used on
some systems, the amount of "wall clock" time it has used on others, in
spite of its name :-(, and vendors' documentation sometimes does not
make it clear which :-[ so you have to do some experiments.
SYSTEM_CLOCK which counts "ticks" of the system clock.
Metcalf et al. Fortran 95/2003 Explained, and Adams et al. Fortran 95
Handbook, both explain this. The full details are longer than I would
wish to post here.
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
|
|
|
|
|