I am using the function system_clock
with Fortran90 (compiled with gfortran) in the following way :
! Variables for clock
integer count_0, count_1
integer count_rate, count_max
double precision time_init, time_final, elapsed_time
! Starting time
call system_clock(count_0, count_rate, count_max)
time_init = count_0*1.0/count_rate
.... Main code
! Ending time
call system_clock(count_1, count_rate, count_max)
time_final = count_1*1.0/count_rate
! Elapsed time
elapsed_time = time_final - time_init
! Write elapsed time
write(*,1003) int(elapsed_time),elapsed_time-int(elapsed_time)
1003 format(' Wall Clock = ',i0,f0.9)
I would like to know if I use correctly this function. Indeed, I didn't specify a value for count_rate
and count_max
but I guess there are default values. Moreover, It seems that I have to take into account the case where count_0
or count_1
are over count_max
values, doesn't it. As you can see, for pretty formatting, I have split the seconds and the decimal part of elapsed time.