
!      this calculates PI= 3.14159265358979 accurately to 14 decimal places

       module module 1
       call arctan ( x = 1/5   , i = 10 :: x1 = arctan )
       call arctan ( x = 1/239 , i =  3 :: x2 = arctan )
!       print "arctan ( 1/5 ) =   pc_calc ( x1 , f.14)"
!       print "arctan ( 1/239 ) = pc_calc ( x2 , f.14)"
       print "PI = pc_calc( 16 * x1 - 4 * x2 , f.14)"
       end

       module arctan ( x = tan(arctan) , i = number of iterations )
       arctan = 0
       n = 1
       y = x
       x = x * x
       j = 1
       h = 1
       do while ( le(j,i) )
           if ( gt(h,0) ) then
               arctan = arctan + y / n
           else
               arctan = arctan - y / n
           endif
           h = -h
           y = y * x
           n = n + 2
           j = j + 1
       end do
       end
