I am running a program with several computations in a loop. I am getting NaN after a lot many computations. To get clean data free of NaN i made the program stop at first appearance of NaN. I got a breakpoint and what i see is an overflow. Earlier, when i had not induced any such breakpoint, as i went through the data file obtained, i saw NaN values among many normal data. Secondly, despite appearance of NaN the computation went on with number data appearing between NaN values. From this pattern should i assume that i should assign these variables to real(16) rather than real(8)?
please tell me the way out.
Real(16) will make things really slow. The NaN are usually caused by division by zero, You need to look improvements to the algorithms being used to trap/prevent this.
NaN and Infinity specifically make it possible for a program to continue. With these special numbers any arithmetic operation has a result.
Of course, NaNs are usually an indication that something is not working as expected and your mentioning overflows probably means that your calculation is unstable. Rather than using real numbers with a larger range (REAL(16) would do that) you should analyse why the numbers are getting so big. As we do not know anything about your algorithm we cannot say much about the possible causes.