Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Double Precision and Modules

Status
Not open for further replies.

rna2009

Mechanical
Oct 28, 2009
1
0
0
GB
Hi,

very new to Fortran but have written the code attached. However it doesn't seem to run with double precision unless I use the old style method of writing 0d0 and implicit double precision at the top of the subroutines. I have tried to use a module and declare everything in it to be double precision but this doesn't work.

When it runs with double precision the final answer is 2.828427124751.

Have I made some really obvious error or why does this not work? I don't want to use the old Fortran methods so any help is really appreciated,

Rich
 
Replies continue below

Recommended for you

selected_real_kind(p=7) only gives 7 significant figures but your answer is 13 significant figures. I don't know if it has that level of accuracy. What answer are you getting? I'm getting 2.828427157712. The last 5 digits are different but the first 8 are the same.
 
Instead of
integer, parameter :: dbl = selected_real_kind(p=7)
Try
integer, parameter :: dbl = selected_real_kind(1.D0)

and specify all real constants like 0.1 as 0.1_dbl
 
Status
Not open for further replies.
Back
Top