LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-16-2014, 05:07 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 464

Rep: Reputation: Disabled
Intrinsic function PRECISION in GFortran - how it works?


Hi there. My environment: Win7==>Oracle VB==>Ubuntu==>GFortran. I need to check if my computations which involve long recurrences lose precision. There is an intrinsic function PRECISION (X) in Fortran. My question is: Let's say I defined a function f(x). Inside of this function there is a variable res which is a part of a do loop and the loop takes let's say 50 recurrences thus changing the variable res 50 times. Every time it is a bunch of additions and multiplications. Can I apply the PRECISION (res) function after that to determine if I've lost any significant digits?

Thanks, A.
 
Old 11-17-2014, 10:09 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
No. That function would tell you what the precision of the current variable is (somewhere around 7 significant digits if single precision, 15 if double), but it wouldn't be able to tell you if some mathematical operation you've performed in the past was truncated due to lack of precision.

The best option is to run through the math yourself, either that or re-run the same process with a double or a quad to see if there is any significant difference.
 
2 members found this post helpful.
Old 11-17-2014, 11:17 AM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 464

Original Poster
Rep: Reputation: Disabled
suicidaleggroll, thanks again. I sort of did some research last night and came to the same conclusion. I do have a question, however, while I have you here :-) Will this declaration REAL (KIND=16) :: x guarantee the quadruple precision for the variable x? Thanks A.

Last edited by AlexBB; 11-17-2014 at 11:45 AM.
 
Old 11-17-2014, 01:37 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
I usually just use REAL*16
 
Old 11-17-2014, 02:26 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
with FORTRAN

Keep your HP calculator NEXT TO THE KEYBOARD
run the math !!! as you test the code
 
Old 11-17-2014, 04:12 PM   #6
AlexBB
Member
 
Registered: Mar 2014
Posts: 464

Original Poster
Rep: Reputation: Disabled
John W., My calculations are very long, unfortunately. Still, is it OK to use KIND=16 ?
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding intrinsic camera(6) parameters with OpenCV Dstruct0 Programming 0 10-05-2011 07:46 PM
problem calling fftw3 library function while using gfortran compiler. Please help. buddyamit Programming 5 07-08-2011 12:07 AM
Intrinsic Function Sind McCoder Programming 4 07-09-2010 09:28 AM
Fortran 90 - intrinsic function SUM...works for double precision? Tahir Butt Programming 3 06-15-2009 08:52 PM
how does function callback works ?? alred Programming 5 05-12-2006 01:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration