|
[Sponsors] |
September 6, 2009, 22:24 |
fortran code problem
|
#1 |
Senior Member
|
Dear firends:
I write a simple code with the fortran 95 , but i can not understantd the following. I declare a double precdision number Real*8 a=3.1 but when i out put it with write(*,*) a the Intel fortran give me the following 3.09999990463257 i can not understand this, could you please give me some hints. Regards |
|
September 6, 2009, 23:28 |
|
#2 |
New Member
Ananda Himansu
Join Date: Apr 2009
Location: Cleveland, Ohio, USA
Posts: 17
Rep Power: 17 |
Try
Real*8 a=3.1d0 |
|
September 7, 2009, 00:28 |
|
#3 |
Senior Member
|
thank you very much , it works.
3.1d0 means 3.1 is a double float number, but i have declare the variable a as real*8. then what is the difference If i want 3.1 to be a long double float number, which symbol should i use. Regards |
|
September 7, 2009, 11:22 |
|
#4 |
New Member
Ananda Himansu
Join Date: Apr 2009
Location: Cleveland, Ohio, USA
Posts: 17
Rep Power: 17 |
You have to use the KIND parameter in the declaration of the variable. Also use a suffix of type real-kind for a constant such as 3.1. See any Fortran 90/95/2003 book or other documentation for the details. This will give you real*16 only if such a kind is available on the cpu architecture or if the compiler supports it through a library (the latter would be slow to execute). The actual value of the kind parameter depends on the architecture and compiler. You can use the PRECISION parameter to find the closest KIND.
|
|
September 7, 2009, 11:40 |
|
#5 |
Senior Member
|
Than you very much, Dear friends:
What is the difference between "Real*8 " and "Real(kind=8)", I think it is the same thing. |
|
September 8, 2009, 05:22 |
|
#6 |
Member
Mohammad Reza Hadian
Join Date: Mar 2009
Location: Yazd, Iran
Posts: 52
Rep Power: 17 |
real*8
real(8) real(kind=8) are the same |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
3D fortran Navier-Stokes code | emrah | Main CFD Forum | 4 | December 15, 2007 10:53 |
Looking for a open FEM code to solve a FSI problem | Esto | Main CFD Forum | 3 | June 15, 2006 12:02 |
Big loop problem of fortran | Wen Long | Main CFD Forum | 9 | April 1, 2004 13:38 |
a fortran problem in CFX | Roy | CFX | 3 | November 14, 2002 09:17 |
SIMPLE code for 3_D problem | bobby | Main CFD Forum | 1 | December 26, 2000 00:20 |