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

Measuring an Execution Time - f90

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 2, 2008, 18:14
Default Measuring an Execution Time - f90
  #1
su
Guest
 
Posts: n/a
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.

thanx
  Reply With Quote

Old   July 2, 2008, 18:32
Default Re: Measuring an Execution Time - f90
  #2
jinwon park
Guest
 
Posts: n/a
You can use the "CALL CPU_TIME(..)" in a line. The usage can be found by googling.
  Reply With Quote

Old   July 3, 2008, 05:13
Default Re: Measuring an Execution Time - f90
  #3
su
Guest
 
Posts: n/a
is there any example on line? couldn't find any!
  Reply With Quote

Old   July 3, 2008, 07:21
Default Re: Measuring an Execution Time - f90
  #4
saygin
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   July 3, 2008, 09:47
Default Re: Measuring an Execution Time - f90
  #5
su
Guest
 
Posts: n/a
Many thanks for your reply. Consider the following code. Say the follwoing is user1.f90 (the main peogram)

PROGRAM test

USE SAMPLE

IMPLICIT NONE

save

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'

END DO

END PROGRAM test

------------:-

And I have a separate file called: SAMPLE.f90

--------:

MODULE SAMPLE

INTEGER, DIMENSION (10) :: K

INTEGER :: I

real :: time_spent, time_end, time_begin

END MODULE SAMPLE

--------------------

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.

  Reply With Quote

Old   July 3, 2008, 11:10
Default Re: Measuring an Execution Time - f90
  #6
jinwon park
Guest
 
Posts: n/a
.... REAL begin_time, end_time ...

CALL CPU_TIME(begin_time)

DO WHILE(t < tfinal)

...

ENDDO

CALL CPU_TIME(end_time)

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

  Reply With Quote

Old   July 4, 2008, 03:44
Default Re: Measuring an Execution Time - f90
  #7
saygin
Guest
 
Posts: n/a
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.

  Reply With Quote

Old   July 4, 2008, 05:14
Default Re: Measuring an Execution Time - f90
  #8
su
Guest
 
Posts: n/a
The time is working now BUT not the use statement! Shall I switch to a different compiler? Or keep trying

  Reply With Quote

Old   July 4, 2008, 07:02
Default Re: Measuring an Execution Time - f90
  #9
saygin
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   July 4, 2008, 07:07
Default Re: Measuring an Execution Time - f90
  #10
saygin
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   July 4, 2008, 07:46
Default Re: Measuring an Execution Time - f90
  #11
su
Guest
 
Posts: n/a
working without the USE !
  Reply With Quote

Old   July 4, 2008, 08:21
Default Re: Measuring an Execution Time - f90
  #12
saygin
Guest
 
Posts: n/a
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.

  Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple floating objects CKH OpenFOAM Running, Solving & CFD 14 February 20, 2019 10:08
calculation diverge after continue to run zhajingjing OpenFOAM 0 April 28, 2010 05:35
Restarting interDyMFoam hsieh OpenFOAM Bugs 4 January 25, 2009 16:19
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15:09
unsteady calcs in FLUENT Sanjay Padhiar Main CFD Forum 1 March 31, 1999 13:32


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