
[Sponsors] 
September 27, 2001, 13:04 
double precision assigning in FRTRAN

#1 
Guest
Posts: n/a

Dear friends I am working in error analysis of a new stabalized scheme for Darcy Flow problem. I am facing some problem in assigning a double precision. I am using fortran powerstation. i am using implicit*8 command. it is working fine but for the folowing cases it is taking a single precision data; 1)Function Return 2)Assignment of a Double Precision number to a variable. e.g. real*8 a a=0.1234567891234567 write(*,*) a It gives an answer accurate upto single precision. 3)Data command e.g real*8 b data b /0.1234567891234567/ gives the value in single precission.
This is spoiling the overall accuracy of my simulations. I can redesign my code and avoid these three cases by use of subroutine or reading data from a file(which gives double precision data) but i want to know any command(which i believe must be present in fortran). I appreciate your help 

September 27, 2001, 15:07 
Re: double precision assigning in FRTRAN

#2 
Guest
Posts: n/a

(1). 1.23...D1 (2). IMPLICIT REAL*8 (AH,OZ) at the begining of every subroutines and functions, including the main program.


September 27, 2001, 15:21 
Re: double precision assigning in FRTRAN

#3 
Guest
Posts: n/a

Thanks Chien
1)i do not understand first part of the answer. 2)i have used implicit real*8 in all he subrouines and the main program. But the compiler does not allow me to define the value of the function in double precision e.g FUNCION F(X) IMPLICIT REAL*8(a:h,o:z) F=X**2 RETURN END COMMENT: THIS PROGRAM GIVES ERROR. IT CAN NOT ALLOW VARAIBLE F TO BE DEFINED IN THIS MANNER Thanks for your advice. Looking forward to have more suggestions 

September 27, 2001, 15:33 
Re: double precision assigning in FRTRAN

#4 
Guest
Posts: n/a

(1). Try to add another line after the implicit real*8 (ah,oz), REAL*8 F, X . Based on the sample in my book.


September 27, 2001, 15:51 
Re: double precision assigning in FRTRAN

#5 
Guest
Posts: n/a

(1). Use double precision form of a floating point variable will make sure that it is a double precision variable. (2). Why not use formatted I/O instead of Write(*,*)? In this way, you can control the output. (*,*) normally will print out results in single precision format.


September 27, 2001, 15:54 
Re: double precision assigning in FRTRAN

#6 
Guest
Posts: n/a

Chien
1)Fortran power station does not allow me to use both of these commands.2)I can replace a function by a subroutine and i have done so successfully and gotresults in double precision 3)But my mail problem is assigning a double precision value to a variable. See example; Real*8 a a=0.1234567891234567 !16 digits print*, a end OUTPUT of PROGRAM: 0.12345678 !single precison Comment: I was able to get double precison when iwrote the numbers in a seperate file and read and print it in the main program. BUT i can not do it for all the assignments in my program! Same is the problem with asigning array of numbers in DATA comand. Thanks for your help 

September 27, 2001, 16:10 
Re: double precision assigning in FRTRAN

#7 
Guest
Posts: n/a


program junk double precision A A=0.1234567891234567 write(*,5)A 5 format(f20.18) end  >>f77 junk.f :>a.out 0.123456789123456701 

September 27, 2001, 19:13 
Re: double precision assigning in FRTRAN

#8 
Guest
Posts: n/a

Dear MR QUESTION
My computer is still giving the answer in single precison. i got this answer in FORTRAN POWERSTATION 0.123456791043281600 *********** > Garbage I think this is a compiler problem. Do you have any idea how to fix it. Is there any option in powersation to select the precsion level? 

September 27, 2001, 20:38 
Re: double precision assigning in FRTRAN

#9 
Guest
Posts: n/a

(1). After a=0.1234567891234567, add three lines of code, itrue=0, if ( a .eq. 0.1234567891234567 ) itrue=1, write(*,*) itrue. (2). In this way, you can tell whether a is identical to 0.1234567891234567 or not.


September 28, 2001, 01:48 
Re: double precision assigning in FRTRAN

#10 
Guest
Posts: n/a

Try
real*8 a a = 0.1234567891234567D+00 Hope this helps. Best regards Markus 

September 28, 2001, 09:57 
Re: double precision assigning in FRTRAN

#11 
Guest
Posts: n/a

This link is support for precision, specific to your compiler.
http://support.microsoft.com/support.../Q125/0/56.ASP 

September 28, 2001, 11:46 
Re: double precision assigning in FRTRAN

#12 
Guest
Posts: n/a

Double precision can be tricky. Markus is correct in pointing out that you should use d+00 at the end of literals. I.e., 0.12d+00 instead of 0.12. Also, it seems I heard someplace that real*8 is not a good idea with some compilers, use
double precision a instead of real*8 a. The problem with the function returning single precision can be fixed by using double precision function x(a) as the first line of the function rather than function x(a) It has been my experience that using switches on the compiler to convert stuff to double precision doesn't always work the way you expect. It is best to tell the compiler explicitly what you want it to do. Hope this helps. 

October 2, 2001, 11:00 
Re: double precision assigning in FRTRAN

#13 
Guest
Posts: n/a

Dean, Markus, MR. ?,John C. Chien
Thanks. The problem has been solved with your help. For the benifit of other friends I want to give its solution. 1)In Fortran Powerstation, assigning a double precision number is done by adding d0 at the end of the number e.g. x=0.1234567891234567d0 (not as x=0.1234567891234567) 2)Similarly numbers in the data array need to be difined in a similar fashion data a \0.1234567891234567d0\ 3)Function need to be defined(as you suggested) as; Double precision F(x) real*8 x f=x**2 return end //Main Program Real*8 f,y y=0.1234567891234567d0 print*, y,f(y) end Note: I do not found any difference in Double precision and real*8 command. Thank you guys. I will be needing more of your help R.A Khurram UIC 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Parallel User Defined Real Gas Model  aeroman  FLUENT  4  July 1, 2015 06:09 
Continuing User Defined Real Gas Model issues  aeroman  FLUENT  5  May 1, 2015 02:57 
Missing math.h header  Travis  FLUENT  4  January 15, 2009 12:48 
what's wrong about my code for 2d burgers equation  morxio  Main CFD Forum  3  April 27, 2007 10:38 
REAL GAS UDF  brian  FLUENT  6  September 11, 2006 08:23 