- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a customer who can successfully read NaN values under XP/Intel 11, but when transferring the program to Win7/Intel 12, gets an I/O error.
Has the compiler changed or is there a switch he should be using to get around this?
I see from a Steve Lionel reply to a similar problem back in 2006, his answer was:
Some common causes of this are:
- Reading character strings that have blanks or punctuation in them that aren't enclosed in quotes
- NaN or Inf in the input file for reals
and I see elsewhere that being able to read NaNs is a 2003 feature.
Does anyone have any experience of this?
Thanks,
Kevin
Has the compiler changed or is there a switch he should be using to get around this?
I see from a Steve Lionel reply to a similar problem back in 2006, his answer was:
Some common causes of this are:
- Reading character strings that have blanks or punctuation in them that aren't enclosed in quotes
- NaN or Inf in the input file for reals
and I see elsewhere that being able to read NaNs is a 2003 feature.
Does anyone have any experience of this?
Thanks,
Kevin
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just tried an experiment reading a NaN in list-directed input and had no problems. A test case would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the data file written by the same compiler major version which is trying to read it? I don't know how much portability there should be, but I'm certain the list-directed format ifort used changed some time in the past.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think the handling of NaN changed at all. We did eliminate, by default, the free conversion between logical and numeric types in list-directed and namelist input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the NaN read a signaling NaN (SNaN) or quiet NaN (QNaN)?
I am assuming you are using an unformatted (binary) read.
If formatted then B, O or Z edit descriptors.
If you are relying on junk text to produce QNAN with other edit descriptorsthen you may have a problem.
Jim Dempsey
I am assuming you are using an unformatted (binary) read.
If formatted then B, O or Z edit descriptors.
If you are relying on junk text to produce QNAN with other edit descriptorsthen you may have a problem.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim, the thread title says list-directed I/O. Reading the string "NaN" in list-directed I/O gives you a QNaN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your comments so far.
A sample line from the datafile is:
4,"Quantam",T,"09193",0.0000,0.0000,0.0000,0.0000,0.00,0.00,0.00,0.00,"Monthly",0.0000,
T,0.00,0.00,0.00,0.00,0.00,"Quarter",0.0000,F,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.0000,0.00,-0.13,0.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
NaN,NaN,NaN,NaN,0.00,0.00,0.25,0.,0.,0.,NaN,0.0000,0.0000,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.00,0.00,0.00,0.00,0.00,4,"Quantam",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.00,0.00,"20100623","Blank","Blank","Blank","20100629","12153700","JH",28111
And an extract of the code is:
Type :: Feesheet_Record
Integer :: Feesheet_Number
Character (len= 32) :: Feesheet_Name
Logical :: Feesheet_Active
Character (len= 8) :: Feesheet_Account
Real (kind= 8) :: Feesheet_Fund_cash_retained
Real (kind= 8) :: Feesheet_Fund_leveraged
Real (kind= 8) :: Feesheet_Fund_proportion
Real (kind= 8) :: Feesheet_Afee_rate
Real (kind= 8) :: Feesheet_Afee_base
Real (kind= 8) :: Feesheet_Afee_calculated
.
.
.
Type(Feesheet_Record) :: Feesheet_Data
Character (len=2048) :: Data_string
open(unit=iFile,name='Datafile.txt',status='old')
read ( unit = iFile, fmt= "(A)", iostat= iErr ) Data_string
read (Data_string, fmt= * , iostat= iErr ) Feesheet_Data
expecting the NaNs to be read into some of the REALS of the record structure.
Unfortunately, when I narrow the code down to a small program on my machine, it works OK, so I was hoping that it could be a switch-setting on the customer's project that was causing the error.
A sample line from the datafile is:
4,"Quantam",T,"09193",0.0000,0.0000,0.0000,0.0000,0.00,0.00,0.00,0.00,"Monthly",0.0000,
T,0.00,0.00,0.00,0.00,0.00,"Quarter",0.0000,F,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.0000,0.00,-0.13,0.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
NaN,NaN,NaN,NaN,0.00,0.00,0.25,0.,0.,0.,NaN,0.0000,0.0000,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.00,0.00,0.00,0.00,0.00,4,"Quantam",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
0.00,0.00,0.00,0.00,"20100623","Blank","Blank","Blank","20100629","12153700","JH",28111
And an extract of the code is:
Type :: Feesheet_Record
Integer :: Feesheet_Number
Character (len= 32) :: Feesheet_Name
Logical :: Feesheet_Active
Character (len= 8) :: Feesheet_Account
Real (kind= 8) :: Feesheet_Fund_cash_retained
Real (kind= 8) :: Feesheet_Fund_leveraged
Real (kind= 8) :: Feesheet_Fund_proportion
Real (kind= 8) :: Feesheet_Afee_rate
Real (kind= 8) :: Feesheet_Afee_base
Real (kind= 8) :: Feesheet_Afee_calculated
.
.
.
Type(Feesheet_Record) :: Feesheet_Data
Character (len=2048) :: Data_string
open(unit=iFile,name='Datafile.txt',status='old')
read ( unit = iFile, fmt= "(A)", iostat= iErr ) Data_string
read (Data_string, fmt= * , iostat= iErr ) Feesheet_Data
expecting the NaNs to be read into some of the REALS of the record structure.
Unfortunately, when I narrow the code down to a small program on my machine, it works OK, so I was hoping that it could be a switch-setting on the customer's project that was causing the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(I'm going to insert some line breaks in that record for formatting here...)
The only one I can think of that might be an issue is /fpe0. This will cause an exception on any reference of a NaN.
The only one I can think of that might be an issue is /fpe0. This will cause an exception on any reference of a NaN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm afraid we've already tried that switch.
Thanks for your help - I assume there must be something else going on in the program that is affecting the read. I'll keep digging.
Thanks for your help - I assume there must be something else going on in the program that is affecting the read. I'll keep digging.
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