! Test suma serie armonica
! Build with: "Enable Floating Point Consistency".
real*4 s_largest, s_smallest
real*8 ss


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

write(1,*)
write(1,'(a)') &
' N    SUM_double	SUM_smallest    SUM_largest      Rel_Err(smallest)  Rel_Err(largest)'


DO in =1,7
n =10**in
!n =n*10

s_largest  =0.E0
s_smallest =0.E0
ss =0.D0

do j=1 ,n
s_largest =s_largest +1.E0/real(j)
s_smallest =s_smallest +1.E0/real((n+1-j))
ss =ss +1.D0/dble(n+1-j)
end do

!write(1,'(1pE7.0, 3x, 1pE14.7, 6x, 1pE14.7)') real(n), ss-s_smallest, ss-s_largest
write(1,'(/, I2, 2x, 2(1pG14.7), 2x, 1pG14.7, 1pG14.3, 5x, 1pG14.3))') &
in, ss, s_smallest, s_largest, (ss-s_smallest)/ss, (ss-s_largest)/ss
END DO

close(1)
END
