double precision assigning in FRTRAN
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 
Re: double precision assigning in FRTRAN
(1). 1.23...D1 (2). IMPLICIT REAL*8 (AH,OZ) at the begining of every subroutines and functions, including the main program.

Re: double precision assigning in FRTRAN
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 
Re: double precision assigning in FRTRAN
(1). Try to add another line after the implicit real*8 (ah,oz), REAL*8 F, X . Based on the sample in my book.

Re: double precision assigning in FRTRAN
(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.

Re: double precision assigning in FRTRAN
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 
Re: double precision assigning in FRTRAN

program junk double precision A A=0.1234567891234567 write(*,5)A 5 format(f20.18) end  >>f77 junk.f :>a.out 0.123456789123456701 
Re: double precision assigning in FRTRAN
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? 
Re: double precision assigning in FRTRAN
(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.

Re: double precision assigning in FRTRAN
Try
real*8 a a = 0.1234567891234567D+00 Hope this helps. Best regards Markus 
Re: double precision assigning in FRTRAN
This link is support for precision, specific to your compiler.
http://support.microsoft.com/support.../Q125/0/56.ASP 
Re: double precision assigning in FRTRAN
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. 
Re: double precision assigning in FRTRAN
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 
All times are GMT 4. The time now is 04:03. 