CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

Elapsed time

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 19, 2005, 12:53
Default Elapsed time
  #1
Pam
Guest
 
Posts: n/a
It should be a simple question for experts, but as a beginner I need to ask. How can I get the total elapsed rum time of my computational code in FORTRAN with g77 compiler. I used "mclock", but it is just good for cpu time, not the real elapsed time in seconds. Also, RTC() command is not recognized by this compiler. Anyone can help me on this. Thank you.
  Reply With Quote

Old   April 19, 2005, 12:55
Default Re: Elapsed time
  #2
Pam
Guest
 
Posts: n/a
I forgot to say LINUX is the OS of my computer, if important.
  Reply With Quote

Old   April 19, 2005, 13:35
Default Re: Elapsed time
  #3
Harish
Guest
 
Posts: n/a
use dtime() at the beginning and ending of your code and subtract the results.

-H
  Reply With Quote

Old   April 20, 2005, 08:13
Default Re: Elapsed time
  #4
Pam
Guest
 
Posts: n/a
Thanks, but g77 does not DTIME() command either. Any clue?
  Reply With Quote

Old   April 20, 2005, 09:26
Default Re: Elapsed time
  #5
Tom
Guest
 
Posts: n/a
Hi,

It is a rather dirty work around, but can't you include MPI? MPI has some subroutines for performance measurements.

Tom
  Reply With Quote

Old   April 20, 2005, 10:43
Default Re: Elapsed time
  #6
Tom (different one)
Guest
 
Posts: n/a
If your program is called myprog type

time myprog

This will print out the elapsed cpu time (user and system).
  Reply With Quote

Old   April 20, 2005, 11:05
Default Re: Elapsed time
  #7
Harish
Guest
 
Posts: n/a
Compile the code as g77 -ff90 ..........

Try etime() if dtime() does not work

-H
  Reply With Quote

Old   April 20, 2005, 11:10
Default Re: Elapsed time
  #8
Pam
Guest
 
Posts: n/a
Tom, how can I get this subroutine?
  Reply With Quote

Old   April 20, 2005, 11:19
Default Re: Elapsed time
  #9
Pam
Guest
 
Posts: n/a
Thanks Tom. It worked, but I thought that there would be a more sophosticated way to do this.
  Reply With Quote

Old   April 20, 2005, 12:07
Default Re: Elapsed time
  #10
Tom (different one)
Guest
 
Posts: n/a
Another way of doing this is to use, assuming your version of g77 supports it, the f90 subroutine cpu_time; e.g. add the line

call cpu_time(start_time)

at the start of the code and

call cpu_time(end_time)

print*,'cpu time is ',end_time-cpu_time

at the end of your code then compile with the -ff90 option. The cpu_time from this should be the same as that printed under user time as I suggested in my earlier post.
  Reply With Quote

Old   April 20, 2005, 13:08
Default Re: Elapsed time
  #11
Pam
Guest
 
Posts: n/a
I added this and tried to compile my program as:

g77 -ff90 myprog myprog.f and also g77 -o -ff90 myprog myprog.f

but the message is:

Invalid decleration of or reference to symbol 'cpu_time' , which means the subroutine "cpu_time" cannot be found. Have you ever tried yourself this with g77 ? And linux OS?

Pam
  Reply With Quote

Old   April 20, 2005, 14:10
Default Re: Elapsed time
  #12
Tom
Guest
 
Posts: n/a
Yes (I tried it before posting). The problem is likely to be that you've got an old version of g77/gcc installed on your computer. I've just tried it again and it actually works without the -ff90 flag on my home machine! Check the version of your compiler (type g77 --version) mine is 3.3.4

You can download the latest version of g77/gcc (you need to be root to install it) form http://www.gnu.org/software/gcc/gcc.html

You could also try replacing, for example, "call cpu_time(x)" by by "call second(x)"
  Reply With Quote

Old   April 20, 2005, 18:56
Default Re: Elapsed time
  #13
Pam
Guest
 
Posts: n/a
The version of mine is 3.3.1 (linux). I will try the new version asap, but in the meantime, I tries this second(x). It worked but it is not the equivalent to "time myprog" ie. elapsed time, it just gives "cpu time" times 1e-4.
  Reply With Quote

Old   April 21, 2005, 04:43
Default Re: Elapsed time
  #14
Tom (different one)
Guest
 
Posts: n/a
seconds and cpu_time are supposed to be the same function so I'm not too sure why it's not giving the right answer? Also, now I'm back at work I've tested the commands on our version of g77 (gcc 3.2.2 - so it appears to be older than yours!).

You could also try downloading g95 or gfortran which gives you access to other f90 programming features as well as cpu_time (for noncommercial use you can also download the intel f90 compiler).
  Reply With Quote

Old   April 22, 2005, 22:06
Default Re: Elapsed time
  #15
Mani
Guest
 
Posts: n/a
The easiest way would be to use a Fortran90 compiler. However, if you need to use g77 and nothing in fortran seems to work, there is a very simple way to make it work with a C function called from fortran. Here's a short example:

///////////////////////////////////////////// // paste into file ctim.c and compile by // gcc -c ctim.c /////////////////////////////////////////////

#include <sys/time.h> #include <sys/resource.h>

double ctim_(void) { struct rusage rusage; double utime,stime;

getrusage(0,&rusage); utime = (rusage.ru_utime.tv_sec

+1e-6*rusage.ru_utime.tv_usec); stime = (rusage.ru_stime.tv_sec

+1e-6*rusage.ru_stime.tv_usec); return(utime +stime); }

/////////////////////////////////////////////

ccccccccccccccccccccccccccccccccccccccccccccc c paste into file test.f and compile by c g77 test.f ctim.o ccccccccccccccccccccccccccccccccccccccccccccc

program test

implicit none

integer i,j

double precision x,t,ctim

external ctim

t = ctim()

x = 0d0

do i=1,10000

do j=1,10000

x=exp(x)-1d0

enddo

enddo

t = ctim()

print *,t,' sec'

end
  Reply With Quote

Old   April 22, 2005, 22:09
Default Re: Elapsed time
  #16
Mani
Guest
 
Posts: n/a
what a mess! got mangled. let me know if you want the files.
  Reply With Quote

Old   April 23, 2005, 10:44
Default Re: Elapsed time
  #17
Pam
Guest
 
Posts: n/a
Thank you. Would you send the files to meh201@yahoo.com

Regards. Pam
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 28 May 28, 2015 13:37
Time step size and max iterations per time step pUl| FLUENT 27 May 12, 2015 20:04
Problems with simulating TurbFOAM barath.ezhilan OpenFOAM 13 July 16, 2009 05:55
Computational time sunnysun OpenFOAM Running, Solving & CFD 5 March 16, 2009 04:32
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 00:36


All times are GMT -4. The time now is 15:02.