Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29250 Discussions

suggestion for solving the Infinity model output?

changks888
Beginner
799 Views
Hi all modeler,

I'm up to here to ask about how to solve the model output as "Infinity".

Some of the calculations are"Infinity" and Matlab can not recognize it when I load the output in Matlab.

I already look at this document:
http://www.intel.com/software/products/compilers/flin/docs/main_for/mergedProjects/bldaps_for/using_the_floating_point_exception_handling_(-fpe)_option.htm

Thx,
Michael
0 Kudos
1 Solution
TimP
Honored Contributor III
799 Views
Is -Infinity a valid result of your analysis? According to search engine queries, Matlab should accept -Inf. So, where you WRITE values which may take this value, you could modify your WRITE along the line of
if(x < -huge(x)then
write(*,*)'-Inf'
else
write(*,*)x
endif

If necessary, you could
write(*,*) max(-huge(x),x) so as to replace -Infinity with the closest numeric value.
or, should we take your reference to exception handling to imply that you consider this erroneous, and want suggestions for debugging?

View solution in original post

0 Kudos
2 Replies
TimP
Honored Contributor III
800 Views
Is -Infinity a valid result of your analysis? According to search engine queries, Matlab should accept -Inf. So, where you WRITE values which may take this value, you could modify your WRITE along the line of
if(x < -huge(x)then
write(*,*)'-Inf'
else
write(*,*)x
endif

If necessary, you could
write(*,*) max(-huge(x),x) so as to replace -Infinity with the closest numeric value.
or, should we take your reference to exception handling to imply that you consider this erroneous, and want suggestions for debugging?
0 Kudos
changks888
Beginner
799 Views
Hi Tim,
-Infinity is a valid result in the numerical model. Matlab accept -Inf after loading the file, however the it's such painful to load a file contains strings. Your tips is helpful. Right now, I generally parse the -Infinity as NaN in another text editor.

-Michael

0 Kudos
Reply