fortran code problem

 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 6, 2009, 21:24 fortran code problem #1 Senior Member     p ding Join Date: Mar 2009 Posts: 338 Rep Power: 11 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, 22:28 #2 New Member   Ananda Himansu Join Date: Apr 2009 Location: Cleveland, Ohio, USA Posts: 17 Rep Power: 10 Try Real*8 a=3.1d0

 September 6, 2009, 23:28 #3 Senior Member     p ding Join Date: Mar 2009 Posts: 338 Rep Power: 11 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, 10:22 #4 New Member   Ananda Himansu Join Date: Apr 2009 Location: Cleveland, Ohio, USA Posts: 17 Rep Power: 10 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, 10:40 #5 Senior Member     p ding Join Date: Mar 2009 Posts: 338 Rep Power: 11 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, 04:22 #6 Member   Mohammad Reza Hadian Join Date: Mar 2009 Location: Yazd, Iran Posts: 52 Rep Power: 10 real*8 real(8) real(kind=8) are the same

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post emrah Main CFD Forum 4 December 15, 2007 10:53 Esto Main CFD Forum 3 June 15, 2006 11:02 Wen Long Main CFD Forum 9 April 1, 2004 12:38 Roy CFX 3 November 14, 2002 09:17 bobby Main CFD Forum 1 December 26, 2000 00:20

All times are GMT -4. The time now is 22:59.