- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need some ideas on how to automatically select an edit descriptor to maximize the number of digigits printed in the output file.
If the number is 10.12345678 I want "10.123" to be printed when I select a width of 6. This is related to legacy codes wherein the input file is based on fixed width data. The aim is to increase the accuracy (precision) of the input variables read by the program. Are there any routines / codes available that will help me do this? One idea is to write a function that returns the string of required length with the numerical value. This sure seems to be a old wheel which somebody should have perfected.
I also came across the Fortran 2008 "g0" edit descriptor? Is there a "g10" or "g6" or some descriptor that I can use to do the above? Has the "g0" been implemented?
Your input would be much appreciated.
Thanks.
If the number is 10.12345678 I want "10.123" to be printed when I select a width of 6. This is related to legacy codes wherein the input file is based on fixed width data. The aim is to increase the accuracy (precision) of the input variables read by the program. Are there any routines / codes available that will help me do this? One idea is to write a function that returns the string of required length with the numerical value. This sure seems to be a old wheel which somebody should have perfected.
I also came across the Fortran 2008 "g0" edit descriptor? Is there a "g10" or "g6" or some descriptor that I can use to do the above? Has the "g0" been implemented?
Your input would be much appreciated.
Thanks.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran supports G in all its flavors, including G10.d, G0 and G0.3. I know of some issues where it does not always pick the correct format according to the standard, but that is being fixed. (Note that there is no "G10" - if the width is not zero, the digits must be specified.)
G0.5 may work for you - it ensures you get 5 significant digits. Note that it will switch to E format if the value is less than 0.1 or large enough that it doesn't fit in 5 (or whatever you specify) digits.
G0.5 may work for you - it ensures you get 5 significant digits. Note that it will switch to E format if the value is less than 0.1 or large enough that it doesn't fit in 5 (or whatever you specify) digits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct - this has come up in an earlier thread (which I cannot find at the moment).
Attached is a program that uses 11 as the fixed-length width to display numbers most efficiently with the largest number of significant figures. Try it by editing in your own set of numbers for the array X and set the field width N to your preferred value (11 at present as I say).
Attached is a program that uses 11 as the fixed-length width to display numbers most efficiently with the largest number of significant figures. Try it by editing in your own set of numbers for the array X and set the field width N to your preferred value (11 at present as I say).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve and anthonyrichars: Thanks for your input. I will give a shot to both your techniques.
Thanks. Ragu
Thanks. Ragu
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