I have this simple test code
PROGRAM main INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(P=13, r=200) REAL(KIND=dp) :: Ca_myo, Ca_nsr REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: Ca_ds, Ca_jsr REAL(KIND=dp) :: old, dtmp INTEGER :: hidx, NSFU NSFU = 100 ! 1, 100, 1000, 20000 Ca_myo = 0.1d0 Ca_nsr = 1.d0 ALLOCATE(Ca_ds(NSFU), Ca_jsr(NSFU)) Ca_ds = Ca_myo Ca_jsr = Ca_nsr old = (Ca_myo+Ca_nsr) * (NSFU) dtmp = 0.d0 DO hidx = 1, NSFU dtmp = dtmp + Ca_ds(hidx) + Ca_jsr(hidx) END DO PRINT *, "old", old, "new", dtmp PRINT *, "the difference", (old-dtmp)/dtmp, ABS(old-dtmp) END PROGRAM main
Basically, there is no numerical error if I use NSFU=1. However, when I increase NSFU, significant difference is observed
NSFU = 10000, then diff = -1.8586764450774207E-013
This kind of error become larger, in my simulation system, which make the species in a closed system not conserved. Is this a normal (acceptable) error or is there a way to enhance the accuracy of the system?
I’m using X86_64bit system.