!     0.01 繧� 10000蝗櫁ｶｳ縺吶�繝ｭ繧ｰ繝ｩ繝�
!
!     1. 蜊倡ｲｾ蠎ｦ縺ｧ雜ｳ縺�
!     2. 蛟咲ｲｾ蠎ｦ縺ｧ雜ｳ縺�
!     3. 蜊倡ｲｾ蠎ｦ縺ｧ陬懷勧螟画焚繧堤畑縺�※雜ｳ縺�
!
!     螻･豁ｴ
!     2013/07/04 譚第ｩ� 遨ｶ逅�渕縲譁ｰ隕丈ｽ懈�
!     2019/05/29 驤ｴ譛ｨ 邯ｾ鬥ｬ 繝ｯ繝ｼ繧ｯ繧ｼ繝� 霑ｽ險�(陬懷勧螟画焚繧恥df騾壹ｊ縺ｫ縺励◆)
!     2021/07/15 雜頑匱 蝠灘誓 菫ｮ豁｣
program sab_val
implicit none

real(8) :: operand      ! 雜ｳ縺呎焚(0.01)

real(4) :: sum_float    ! 蜊倡ｲｾ蠎ｦ縺ｮ蜥�
real(8) :: sum_double   ! 蛟咲ｲｾ蠎ｦ縺ｮ蜥�
real(4) :: sum_sub      ! 陬懷勧螟画焚繧剃ｽｿ縺｣縺溷柱(縺ゅ∪繧頑э蜻ｳ縺ｪ縺�､画焚)

real(4) :: R1
real(4) :: R2
real(4) :: T
real(4) :: S1
real(4) :: S2     ! 陬懷勧螟画焚縺溘■

integer :: i      ! 繝ｫ繝ｼ繝怜､画焚

! 蛻晄悄蛹�
sum_float = 0.0e0
sum_double = 0.0d0
sum_sub = 0.0e0

R1 = 0.0e0
S1 = sum_sub

operand = 0.01d0

do i = 1, 10000

   ! 蜊倡ｲｾ蠎ｦ縺ｮ蜥�
   sum_float = sum_float + real(operand)

   ! 蛟咲ｲｾ蠎ｦ縺ｮ蜥�
   sum_double = sum_double + operand

   ! 陬懷勧螟画焚繧剃ｽｿ縺｣縺溷柱
   R2 = R1 + real(operand)
   S2 = S1 + R2
   T = S2 - S1
   R1 = R2 - T
   S1 = S2

enddo

! 陬懷勧螟画焚繧剃ｽｿ縺｣縺溽ｵ先棡縺ｮ莉｣蜈･
sum_sub = S1

! 邨先棡縺ｮ蜃ｺ蜉�
write(*,*) '蜊倡ｲｾ蠎ｦ縺ｮ蜥後縲縲縲 = ', sum_float
write(*,*) '蛟咲ｲｾ蠎ｦ縺ｮ蜥後縲縲縲 = ', sum_double
write(*,*) '陬懷勧螟画焚繧堤畑縺�◆蜥� = ', sum_sub

end program