1

Does it make any difference to declare a double precision variable as

double precision :: var1, var2, var3
    
var1 = 1d0
var2 = 1.d0
var3 = 1.0d0

I believe var2 and var3 are identical. Are there any errors that may appear if we do not include the dot in the declaration (as in var1)?

Thales
  • 1,181
  • 9
  • 10
  • 2
    The best is to avoid double precision notation and suffix numbers with the appropriate kind, like: `use iso_fortran_env, only: RK => real64; real(RK) :: a = 1._RK`. This way, you will be able to change the kinds whenever needed in the future. The presence of the decimal dot `.` improves readability to easily distinguish it from integers. – Scientist May 19 '21 at 19:36

1 Answers1

0

No, there are no differences between 1d0, 1.d0 and 1.0d0 whatsoever. They represent the same literal value with the same type.

Be aware that for this specific small integer value you can get away with just using the default kind value 1.0 and you can definitely use the integer value 1.