Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

real*8 1

Status
Not open for further replies.

jgbeckett

New member
Mar 15, 2005
4
Can anyone help?

I am trying to recreate some arrays using a subroutine written by someone else. By using real*8 throughout the program I get one set of results, by changing the precision in the subroutine to real at certain functions I get a differnt array resulting. The array I want is the exact average of the two!

Any ideas?

Are there any problems with using a subroutine, written in 77, for a program in CVF.

John
 
Replies continue below

Recommended for you

John

By default I only use double precision. When dealing with array manipulation, especially if it involves equation solving then single precision is a non-starter. It is bad practice to have mixed precision expressions, just because the result may be stored in a double precision variable doesn't mean you have double precision accuracy if it was calculated using single precision variables.

How do you know the result that you want? Are you trying to match results made years ago on a different computer system?

There should be no problem in using F77 with any later standard of Fortran.
 
thanks for the advise,

I am trying to match results done a few years ago (1987), but I beleive these to be accurate as they correspond to other results.
Also, the two matrices I get by varying the precision have the same amount of error when compared to the origional, only in different directions.
 
In that case I don't beleive you will be able to match your 1987 results. I suspect your old results were produced on something like a digital VAX computer running under VMS, in which case you will never get an exact match on a PC.
 
You might want to read up on how a computer does floating point operations and how variable precision plays a role. The Lahey.com website has an article on "The Perils of Floating Point" which you may find illuminating. Based on what I've read here so far... I feel quite safe in saying that you currently have no way of knowing for sure what the correct results should be. I would tend to guess that your double precision version is more likely to give good answers, however, that is not even close to guarantteed either.

Your results are dependant on several things. The particular computer used, CPU and possibly other hardware also, the operating system used, the fortran compiler used and the compiler switches which were set when you compiled the program. And last of all... the program code itself. How can you be SURE that the routines logic is sound????

Dan :)
 
Independent of the precision issue, it may simply be that you have ill-behaved algorithms and the errors emanate from poor formation of the equations, resulting in dependence on the least significant bits of the numbers.

TTFN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor