! f90 fortran program
! install: sudo apt-get install gfortran
! compile: gfortran -o Appendix4_test1 Appendix4_test1.f90 -Ofast
! OSX before compile run:
! PATH=Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

function wallisSeries() result(pi)
  ! "real(8)" 8-byte real (double in C), "real(16)" 16-byte real (long double in C)
  real(8) :: pi
  real(8) :: num
  integer :: ITERATIONS = 100000000

  pi = 1.0
  do i = 1,ITERATIONS
    num = 4.0*i*i
    pi = pi*num/(num - 1)
  end do
  pi = 2*pi
end function

program hello
  real(8) :: wallisSeries
  print *, "Calc done:", wallisSeries()
end program hello
