- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am porting an application from fortran older version(4.0) to new oversion (11.0). While porting I am facing some problems with real*4 varibales.
ex:
real*4 a,b,c
a=0.9876875
b=0.6754345
c=a*b
value for 'c' in old compiler 0.667118,which is correct value. But with new compiler I am getting a small variation from the output(c variable) like 0.667120. Though it is a small variation, I am using these values in some other calculation. So the overall output has a huge difference. How to overcome this issue? Please explain me?
I am porting an application from fortran older version(4.0) to new oversion (11.0). While porting I am facing some problems with real*4 varibales.
ex:
real*4 a,b,c
a=0.9876875
b=0.6754345
c=a*b
value for 'c' in old compiler 0.667118,which is correct value. But with new compiler I am getting a small variation from the output(c variable) like 0.667120. Though it is a small variation, I am using these values in some other calculation. So the overall output has a huge difference. How to overcome this issue? Please explain me?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the results are different on a case as simple as this, the earlier compiler must have set an extension which treats constants as double precision, as well as using double precision evaluation of expressions. You could set /fpconstant /arch:IA32 in order to get closer to the numerical behavior of the older compiler. You still could not trust the results, if they depend on extensions beyond single precision. You might perform a check with /real-size:64 , rather than attempting to duplicate the old results.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The values you have are right at the borderline in terms of significant digits for single-precision. The Microsoft 4.0 compiler always used the X87 floating point instructions which would do single-precision arithmetic in double-precision. Intel Fortran 11.0 and later uses the faster SSE instructions which use the precision you declared. The two values you show are different in the last fraction bit, probably due to rounding.
In general, you can't rely on bit-for-bit identical results between two different implementations when optimizations and different instruction sets are used. Your program probably should be using double precision if it cares about results to that many digits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the results are different on a case as simple as this, the earlier compiler must have set an extension which treats constants as double precision, as well as using double precision evaluation of expressions. You could set /fpconstant /arch:IA32 in order to get closer to the numerical behavior of the older compiler. You still could not trust the results, if they depend on extensions beyond single precision. You might perform a check with /real-size:64 , rather than attempting to duplicate the old results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - cvnravi
value for 'c' in old compiler 0.667118,which is correct value. But with new compiler I am getting a small variation from the output(c variable) like 0.667120. Though it is a small variation, I am using these values in some other calculation. So the overall output has a huge difference. How to overcome this issue? Please explain me?
Les
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page