! TEST do-loop
! sum1 =do-loop: sum1 =sum1+h
! sum2 =do-loop, sum2 =j*h

use ifcore  !cvf: use dflib
integer:: n =1e6; real:: h =0.01
!real*8 dsum
logical pressed

sum1 =0.0

open(1, file='do.rez')
write(1,'(a)') 'Calculul lui: SUM1 =SUM1+h; SUM2 =j*h; h =0.01'
write(1,*)
write(1,'(a, t15,a, t30,a, t43,a)') ' j',	'Sum1', 'Sum2',	'Er_Rel'

do j=1, n
sum1 =sum1 +h
sum2 =j*h
!dsum =dble(j)*dble(h)

if(mod(j, 100000)==0) then
!write(1,*) j, ':', sum1, sum2, (sum2-sum1)/sum2	!, dsum
write(1, '(1pe7.0, t13,F11.3, t28,F11.3, t42,E10.3)') real(j), sum1, sum2, (sum2-sum1)/sum2
endif
enddo

close(1)
write(*,*) 'Fisier de rezultate: do.rez'

write(*, '(/,a)') 'Apasa orice tasta'
DO WHILE (.NOT. pressed)   
pressed = PEEKCHARQQ ( )
END DO

END
