! test suma serie armonica alternata
! Build with: "Enable Floating Point Consistency".
real*4 sum_largest, sum_smallest
real*8 ss


open(1, file ='Alt_Arm.rez', status='unknown', form='formatted')
write(1,'(a)') ' TEST suma serie armonica alternata'
write(1,'(a)') ' Numar termeni = 10^N'

write(1,*)
write(1,'(a)') ' N     Sum_double      Rel_Err(smallest)   Rel_Err(largest)'

DO in =1,7
n =10**in
il= -1
is =(-1)**(n-1)

sum_largest = 0.E0
sum_smallest =0.E0
ss =0.D0

do j=1,n
il= -il
sum_largest =sum_largest +il*1.E0/float(j)
sum_smallest =sum_smallest +is*1.E0/float((n+1-j))
ss =ss +is*1.D0/dfloat(n+1-j)
is =-is
end do

write(1,'(/, I2, 1pg18.7, 1pE15.3, 1pE20.3)') in, ss, (ss-sum_smallest)/ss, (ss-sum_largest)/ss
END DO

close(1)
END
