View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2815 Location: South Pole, Antarctica
|
Posted: Mon Jun 13, 2016 12:51 am Post subject: Is this a Standard ? |
|
|
I got a reading error while filling real*4 variables with these numbers which led me to this text line in the data file
Code: | 1.8000E-02 7.0438E+00 -8.4720+220
|
Notice the number without E or D ? Kind of I did not pay attention before to this but is this standard way of writing real*8 numbers ? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Mon Jun 13, 2016 6:02 am Post subject: |
|
|
The only reason to get an error in reading the data that you showed is that the third item has an exponent that is too large for a REAL*4 variable. The standard specifies (look up the section for Fw.d input) that the start of the exponent field may contain an 'e', 'd', 'E', 'D', '+' or '-' .
You may not like leaving out the E/D, and you can certainly make sure that your input data contains the E/D, but the standard does not require it.
The justification? You have to think in terms of punched card input, where being able to leave out the E/D could reduce your card budget by 10 percent. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2815 Location: South Pole, Antarctica
|
Posted: Mon Jun 13, 2016 6:05 pm Post subject: |
|
|
Thanks Mecej4. This is the case when I can definitely live with it if this is a Standard. This behavior of the code is reasonable when the compiler detects an error and that definitely is very useful warning i should not miss. I ignored these errors in this place before and when the code with time became too large and complex and buggy I now pay for that by loosing a lot of time with any small error. Lost one more Saturday, which became like a doom to me lately, I loose now most of Saturdays on some "errors from the hell" (the ones I never had before or the ones hard to find.... I wrote about this devilry effect before) . |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Tue Jun 14, 2016 5:43 am Post subject: |
|
|
it's always a good idea to build in checks on the validity of the numbers to threshold values as they are read in, especially for large sets of input data. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Tue Jun 14, 2016 9:17 am Post subject: |
|
|
Dan,
According to the Fortran standard, I think the value "-8.4720+22" is a valid number, although I would consider this an error.
John |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed Sep 07, 2016 1:10 pm Post subject: |
|
|
John, I just noticed that that you wrote "-8.4720+22"; what Dan's data file had, however, was "-8.4720+220". Without the third digit ('0') in the exponent field, the input number would have been well within the range of REAL, and no runtime error would have been issued. |
|
Back to top |
|
|
|