CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   Measuring an Execution Time - f90 (

su July 2, 2008 17:14

Measuring an Execution Time - f90
how can I Measuring an Execution Time in fortran, f90, in a PC. Is there any command can I write in my code in order to see how many min, sec, hours that I need to get results.


jinwon park July 2, 2008 17:32

Re: Measuring an Execution Time - f90
You can use the "CALL CPU_TIME(..)" in a line. The usage can be found by googling.

su July 3, 2008 04:13

Re: Measuring an Execution Time - f90
is there any example on line? couldn't find any!

saygin July 3, 2008 06:21

Re: Measuring an Execution Time - f90
place "CALL CPU_TIME (time_begin)" at the very beginning of the code, and place "CALL CPU_TIME (time_end)" where you want to calculate the CPU time. So; time_spent = time_end - time_begin in seconds.

su July 3, 2008 08:47

Re: Measuring an Execution Time - f90
Many thanks for your reply. Consider the following code. Say the follwoing is user1.f90 (the main peogram)





DO I = 1,5

CALL CPU_TIME (time_begin)

K(I) = 2*I

time_spent = time_end - time_begin

CALL CPU_TIME (time_end)

print*, 'Time of operation was ', time_spent, ' seconds'




And I have a separate file called: SAMPLE.f90





real :: time_spent, time_end, time_begin



Am running this in a PC using a PC compiler (only no linux or unix)and it is not working at all for the use statement and not for the cpu time.

How can I solve this problem, am still new to fortran 95/90. is the USE done with unix ONLY ?

Thanks for your help.

jinwon park July 3, 2008 10:10

Re: Measuring an Execution Time - f90
.... REAL begin_time, end_time ...

CALL CPU_TIME(begin_time)

DO WHILE(t < tfinal)



CALL CPU_TIME(end_time)

PRINT*,' ' PRINT*,'total computing time: ',(end_time-begin_time),'sec.'

saygin July 4, 2008 02:44

Re: Measuring an Execution Time - f90
you can apply USE and CPU_TIME declarations in f90, your code should have worked. check out your compiler's help documents, it might apply slightly different declarations. also, put the cpu time built-in fuctions outside of the do-loop, unless you do want to measure the time for each and every iteration operation. and you should have calculated the time_spent after obtaining time_end.

su July 4, 2008 04:14

Re: Measuring an Execution Time - f90
The time is working now BUT not the use statement! Shall I switch to a different compiler? Or keep trying

saygin July 4, 2008 06:02

Re: Measuring an Execution Time - f90
cpu_time may vary i think, but use statement have to be a standard declaration for f90. perhaps you haven't added the module file to the project before compilation.

saygin July 4, 2008 06:07

Re: Measuring an Execution Time - f90
wait a moment, how can it works without the use statement? if cpu_time works then use statements must be working also. you are missing some point, it is better to examine details before asking i think.

su July 4, 2008 06:46

Re: Measuring an Execution Time - f90
working without the USE !

saygin July 4, 2008 07:21

Re: Measuring an Execution Time - f90
there is an "implicit none" statement in your main file, therefore every variable have to be declared beforehand. use statement or your module is working obviously. if you couldn't see the variables in debugging screen it is because they are global variables, and you can see the assigned values to them by writing down variable's names in debugging screen explicitly.

All times are GMT -4. The time now is 04:48.