Research Article

SPOT: A DSL for Extending Fortran Programs with Metaprogramming

Algorithm 15

The generated Fortran program with checkpointing code.
(1)program CalculatePI
(2)integer n, i
(3)integer start_i;
(4)real*8 t, x, pi, f, a
(5)f(a) = 4.d0 /(1.d0 + a*a)
(6)pi = 0.0d0
(7)n = 100000
(8)t = 1.0d0/n
(9)retrieveVariableReal(“pi”, pi);
(10)retrieveVariableInteger(“i”, start_i);
(11)do i =  start_i  ,  n
(12)x = t  *  (i    0.5d0)
(13)pi = pi + f(x)
(14)if  (MOD(i,5) == 0){
(15)saveVariableReal(“pi”, pi);
(16)saveVariableInteger(“i”, i);
(17)}
(18)  end do
(19)  print *, "The value of pi is  ", pi
(20)end