that does not do what the user intends, for two reasons. First, real variables are single precision by default in Fortran. Second, a literal constant such as 3.1415926535897931 is interpreted as single precision unless you append "d0". So the results of the code
implicit none
real, parameter :: PI = 3.1415926535897931
double precision, parameter :: pi_d = 3.1415926535897931d0
print*,PI
print*,pi_d
end
are
3.14159274
3.1415926535897931
So I suggest replacing the definition of pi currently used in your code with what I show above in the 3rd line. (You can rename pi_d to pi.) Or you can just write
real, parameter :: PI = 3.14159265
and avoid showing digits that will not be stored in single precision pi.
The Fortran code has a line
real, parameter :: PI = 3.1415926535897931
that does not do what the user intends, for two reasons. First, real variables are single precision by default in Fortran. Second, a literal constant such as 3.1415926535897931 is interpreted as single precision unless you append "d0". So the results of the code
are
So I suggest replacing the definition of pi currently used in your code with what I show above in the 3rd line. (You can rename pi_d to pi.) Or you can just write
and avoid showing digits that will not be stored in single precision pi.