- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following equation
TCP(L) = ((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S41
&+ PLOG*(S3 + PLOG*(S2 + PLOG*S1))
while debugging I came to know
L1INTEGER(4)
J41INTEGER(4)
A(J)281.844320000000REAL(8)
PLOG7.76195750680761REAL(8)
A(J+1)-4428.76670000000REAL(8)
A(J+2)8563.47850000000REAL(8)
A(J+3)76694.1260000000REAL(8)
S4-73755.8052496628REAL(8)
S3-9301.57554486114REAL(8)
S24506.18740882533REAL(8)
S1-283.717539158391REAL(8)
where as TCP(L) is NaN
DIMENSION A(120), AT1(20), AT2(20), AT3(20)
DIMENSION ACP1(20), ACP2(20), ACP3(20), TCP(2)
is saying the array sizes for TCP and A are with in the limit.
when I have set the fortran compiler settings of Data -> Local Variable to All Variable Save it happend not to get that error for a while and again it re appeard after some more calculations.
Please suggest what else are the setting I need to modify to get this work well.
Thanks,
Chandra.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I run the latter code, I get tcp(1) = 997.687999976726
The equation shows no sign of getting a NaN result. For a better understanding of real number computations, read the three "The Perils of Real Numbers" articels in the Doctor Fortran thread by Steve Lionel: http://software.intel.com/en-us/forums/showthread.php?t=41911
Your hint, that with save the variables you get the NaN more less shows, that some of your variables are not initialized every time you compute tcp.
[cpp]integer(kind=4) l,j real(kind=8) a(4),tcp(1),s1,s2,s3,s4,plog l=1 j=1 A(J) = 281.844320000000D0 PLOG = 7.76195750680761D0 A(J+1) = -4428.76670000000D0 A(J+2) = 8563.47850000000D0 A(J+3) = 76694.1260000000D0 S4 = -73755.8052496628D0 S3 = -9301.57554486114D0 S2 = 4506.18740882533D0 S1 = -283.717539158391D0 TCP(l) = ((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S4 + PLOG*(S3 + PLOG*(S2 + PLOG*S1))[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suppose you could consider x87 stack overflow as a sort of out of memory condition, so you should try running with fp stack checking, particularly if you want to compile without SSE2 code generation. I don't get a clear impression what you are thinking of. Other than that, NaN will be produced if one of the operands is NaN, or possibly by some combination with infinity sub-expressions.
The evaluation ought to be somewhat more reliable (and faster), if the polynomial evaluations are merged
TCP(L) = (((A(J)+S1)*PLOG + A(J+1)+S2)*PLOG + A(J+2)+S3)*PLOG + A(J+3) + S41
Setting /fp:precise might encourage the compiler to evaluate the expression in C standard order. The original expression is far too complicated to guess what order of evaluation a compiler will choose when given free rein.
Speaking for myself, I find it more readable if polynomials are always written low order term first. Reversing the order entirely, along with /fp:precise, could give you more assurance that you know the actual order of evaluation without reading asm code.
In case you don't optimize your source code, /pc80 switch might allow more use of extended range with x87 code.l

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page