1! { dg-do run }
2! { dg-options "-O2" }
3program m
4   double precision :: y,z
5   call b(1.0d0,y,z)
6   if (ABS (z - 1.213) > 0.1) call abort
7contains
8     subroutine b( x, y, z)
9       implicit none
10       double precision :: x,y,z
11       integer :: i, k
12       double precision :: h, r
13
14       y = 1.0d0
15       z = 0.0d0
16
17       h = 0
18       DO k = 1,10
19          h = h + 1.0d0/k
20
21          r = 1
22          DO i = 1,k
23             r = (x/(2*i) ) * r
24          END DO
25
26          y = y + (-1)**k * r
27          z = z + (-1)**(k+1) * h * r
28
29          IF ( ABS(2*k/x*r) < 1d-6 ) EXIT
30       END DO
31
32       z = 2*y
33     end subroutine b
34end program m
35