Common block mystery

Here is a little program that demonstrates the difference between SPACING and EPSILON. As detailed in the link referenced by @ilayn, the SPACING (or gap between representable numbers) varies with order of magnitude. EPSILON represents the gap in numbers between 1 and 2 and is therefore constant irrespective of the number you give it. To me the results from this little exercise demonstrates why you have to be careful if you want to use default 32 bit precision in floating point intensive calculations. If you have data that varies several orders of magnitude (ie powers of 10), then you should consider normalizing your data back into a range of probably 0 to 100.

This program

Program spacing_v_eps

  USE ISO_FORTRAN_ENV, SP=>REAL32, DP=>REAL64

  Implicit NONE

  Real(SP) :: a4
  Real(DP) :: a8

  Integer :: i

  Print *,''
  Print *,' SPACING - 10**i'
  Print *,''
  Do i = 0,10
    a4 = 10.0_SP**i
    a8 = 10.0_DP**i
    Write(*,'(" i = ",i2," r4 = ", ES0.7, " r8 = ", ES0.16)') i, SPACING(a4), &
              SPACING(a8)
  End Do
  Print *,''
  Print *,' EPSILON - 10**i'
  Print *,''
  Do i = 0,10
    a4 = 10.0_SP**i
    a8 = 10.0_DP**i
    Write(*,'(" i = ",i2," r4 = ", ES0.7, " r8 = ", ES0.16)') i, EPSILON(a4), &
              EPSILON(a8)
  End Do

End Program spacing_v_eps

gives these results when compiled with ifx 2024.1

SPACING - 10**i

i = 0 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 1 r4 = 9.5367432-07 r8 = 1.7763568394002505-15
i = 2 r4 = 7.6293945-06 r8 = 1.4210854715202004-14
i = 3 r4 = 6.1035156-05 r8 = 1.1368683772161603-13
i = 4 r4 = 9.7656250-04 r8 = 1.8189894035458565-12
i = 5 r4 = 7.8125000-03 r8 = 1.4551915228366852-11
i = 6 r4 = 6.2500000-02 r8 = 1.1641532182693481-10
i = 7 r4 = 1.0000000+00 r8 = 1.8626451492309570-09
i = 8 r4 = 8.0000000+00 r8 = 1.4901161193847656-08
i = 9 r4 = 6.4000000+01 r8 = 1.1920928955078125-07
i = 10 r4 = 1.0240000+03 r8 = 1.9073486328125000-06

EPSILON - 10**i

i = 0 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 1 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 2 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 3 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 4 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 5 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 6 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 7 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 8 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 9 r4 = 1.1920929-07 r8 = 2.2204460492503131-16
i = 10 r4 = 1.1920929-07 r8 = 2.2204460492503131-16 <