LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 06:07 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

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, 11:09 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,355

Rep: Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989
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, 12:17 PM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

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 12:45 PM.
 
Old 11-17-2014, 02:37 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,355

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

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
with FORTRAN

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

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:46 PM
problem calling fftw3 library function while using gfortran compiler. Please help. buddyamit Programming 5 07-08-2011 01:07 AM
Intrinsic Function Sind McCoder Programming 4 07-09-2010 10:28 AM
Fortran 90 - intrinsic function SUM...works for double precision? Tahir Butt Programming 3 06-15-2009 09:52 PM
how does function callback works ?? alred Programming 5 05-12-2006 02:07 AM


All times are GMT -5. The time now is 01:25 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration