- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All
I have inherited a fortran program from somebody and have run into a situation where it prints very small numbers out with the write statement, something like -8.97639E-30 or 7.36475-173. How can I get the program to write numbers under a certain threshold value to be zero without having to trawl through the code and do a check everywhere. Is there a compiler option I can use for instance?
Thanks in advance
Ed
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is not such an option. I assume that -173 exponent value is double-precision, as I don't think a denormalized single will go that small.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will have to dig through your program because either the FORMAT edit descriptors (or lack thereof with *), are specifying that the print is to supply the exponents of such small (or large) numbers. IOW has E, EN, ES or G formatting. Change these to F formatting (Fw.d). This transfers real numbers without exponent.
If you really want exponents printed, except for very small numbers, then you will need to qualify a cutoff point. For this, often one writes a specialized formatting subroutine that handles, in your case, very small numbers.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An alternative to consider is to write a post-processor program. If you have lots of text interspersed with the numbers, that can be difficult to do. On the other hand, if there are only numbers on some lines and only text on others, the post-processor would be very easy to implement.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page