Results 1 to 4 of 4
Hello,
I have a fortran code, which I run on a multi-user Linux server. Since there are multiple users working on this server, I want to know, How much cpu ...
- 12-31-2011 #1Just Joined!
- Join Date
- Dec 2011
- Posts
- 1
How to compute CPU time for a particular process?
Hello,
I have a fortran code, which I run on a multi-user Linux server. Since there are multiple users working on this server, I want to know, How much cpu time does my application takes to complete? Although I am able to calculate CPU clock time, I also need to know the total CPU time required for entire simulation to get completed. Is there any command or code, with help of which this can be achieved?
Thanks
Regards
Rakesh Patil
- 12-31-2011 #2Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
Hi rakeshp,
Don't know if it helps you.
When I wanna know the process time of a process I use the bash command "ps -ef" it will list all processes with their start time, used cpu time, PID, Parent PID and so on.
Don't know if there's a fortran code for it.
- 12-31-2011 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
See man time. The time command runs commands for you and produces 3 times, like so (with bash):
producing:Code:time burn 10
The burn is a (local) example, you can use almost any command in its place. So if you compile your Fortran code and have the final executable on file a.out, then you would use:Code:real 0m10.727s user 0m9.877s sys 0m0.000s
If you are using a csh family shell, the name, time, is the same , but output differs in format:Code:time ./a.out
Best wishes ... cheers, drlCode:time burn 10 9.868u 0.004s 0:10.53 93.6% 0+0k 0+0io 0pf+0w
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 12-31-2011 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
If you wanted to time sections of your code in modern Fortran, say Fortran-90, you could use some standard library routines, such as cpu_time on file one.f90:
then using:Code:program main real :: my_sum, t1, t2, harvest(1000000) write(6,*) " Hello, world from fortran." call cpu_time(t1) call random_number(harvest) my_sum = sum ( harvest ) call cpu_time(t2) call a( t2-t1 ) end subroutine a ( t ) real :: t write(6,*) " The time taken for code is ", t write(6,fmt="(a,f6.2)") " The time taken for code is ", t return end
produces:Code:gfortran one.f90 ./a.out
This was done in the context:Code:Hello, world from fortran. The time taken for code is 3.60019989E-02 The time taken for code is 0.04
Example adapted from Modern Fortran Explained, Metcalf, et al, Oxford 2011, page 181.Code:OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64 Distribution : Debian GNU/Linux 5.0.8 (lenny) gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2
Best wishes ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote