I'm writing a Fortran program based on the first exercise in this book (page 34). The book is designed as an introduction to high performance computing. The first exercise asks the user to write code to estimate pi. Following what is provided by the authors, I have done this successfully.
program compute_pi
double precision :: x, delta_x, sum
!double precision :: S,E,MFLOPS
integer, parameter :: SLICES=10000000
sum = 0.d0 ; delta_x = 1.d0/SLICES
!call get_walltime(S)
do i=0,SLICES-1
x = (i+0.5)*delta_x
sum = sum + 4.d0 / (1.d0 + x*x)
enddo
pi = sum*delta_x
print *, pi
!call get_walltime(E)
!MFLOPS = R*N*2.d0/((E-S)*1.d6)
end program compute_pi
Next, I am trying to compute performance in MFlops/sec. In order to do this, I have followed the author's example on page 5 and wrote
program compute_pi
double precision :: x, delta_x, sum
double precision :: S,E,MFLOPS
integer, parameter :: SLICES=10000000
sum = 0.d0 ; delta_x = 1.d0/SLICES
call get_walltime(S)
do i=0,SLICES-1
x = (i+0.5)*delta_x
sum = sum + 4.d0 / (1.d0 + x*x)
enddo
pi = sum*delta_x
print *, pi
call get_walltime(E)
MFLOPS = R*N*2.d0/((E-S)*1.d6)
end program compute_pi
When I run the above code in Netbeans (the IDE I am using for Fortran), it returns
undefined reference to `get_walltime_'
I'm not sure why the reference is undefined.