Obtaining clock time using Fortran

to get the current time in Fortran, we can use “system_clock” built-in function. To do this, take a look at the code below.

integer::count_0,count_rate,count_max, walltime, tstart,tend
call system_clock(count_0,count_rate,count_max)
tstart=count_0/count_rate
write(*,*) 'begin (system_clock)',tstart

To find out how long your program has run, add a similar line and save the time to, for example “t_end” variable, and get the difference. It will give the duration time in seconds.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: