- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My Fortran code sometimes gave results as NaN (Not a number). How can I change these NaN to some kind numbers (like 1e200 or something) so that my program can continue.
Thanks
Thanks
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dx,
You need to determine the underlaying cause for generating the NaN.
A frequent cause is the use of uninitialized variables.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Dx
My Fortran code sometimes gave results as NaN (Not a number). How can I change these NaN to some kind numbers (like 1e200 or something) so that my program can continue.
Thanks
Thanks
you can test for a NaN using isnan().
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tropfen
Hello Dx,
you can test for a NaN using isnan().
Frank
you can test for a NaN using isnan().
Frank
Thanks for your comments. I think the reason for my seeing NaN is the the program is going to the wrong direction.
Can I overwrite the NaN with some numbers ( say 0 or 1e200 or something) so the program can go to the next step?
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, you can't do that. What you can try is setting the option /fpe:0 (under Fortran > Floating Point) - if a calculation in the generated code would result in a NaN, this should give an error instead. NaNs can occur other ways that this won't catch, however.
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