- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my Fortran program I have an expression as follows.
TCP(L) = ((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S4
+ PLOG*(S3 + PLOG*(S2 + PLOG*S1))
IF(ISNAN(TCP(L))) THEN
TCP(L) = ((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S4
+ PLOG*(S3 + PLOG*(S2 + PLOG*S1))
END IF
When I ran my program first time TCP(L) calculation resulting NaN and again it is going into the if loop and the same expression assgning to same variable is resulting in correct value.
Why is this split behaviour in fortran and what is the way to reslove it rather adding every where this IFELSE stuff...
Thanks,
Chandra.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't think of an explanation for this behavior. Can you provide a short but complete example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I seem to remember you posted something about this before. At the time I wondered why, having found that TCP(L) is NaN, you then proceeded to do exactly the same calculation again! I thought maybeother replies would produce further information.
The usual starting point is to ask - have you turned on all the debug options? (Check array boundaries, uninitialised variables etc)
Do you use "implicit none" in all your routines?
Is the code snippet you showed exactly as it appears in your actual code, or are there other statements between the first calculation of TCP and the IF (ISNAN) ?
Les
The usual starting point is to ask - have you turned on all the debug options? (Check array boundaries, uninitialised variables etc)
Do you use "implicit none" in all your routines?
Is the code snippet you showed exactly as it appears in your actual code, or are there other statements between the first calculation of TCP and the IF (ISNAN) ?
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Chandra,
disect your constituents. Use
[cpp]IF(ISNAN(TCP(L))) THEN IF(ISNAN(PLOG)) call Bug IF(ISNAN(A(J))) call Bug IF(ISNAN(A(J+1))) call Bug IF(ISNAN(A(J+2))) call Bug IF(ISNAN(A(J+3))) call Bug IF(ISNAN(S4)) call Bug IF(ISNAN(S3)) call Bug IF(ISNAN(S2)) call Bug IF(ISNAN(S1)) call Bug IF(ISNAN(A(J)*PLOG)) call Bug IF(ISNAN((A(J)*PLOG + A(J+1))) call Bug IF(ISNAN((A(J)*PLOG + A(J+1))*PLOG)) call Bug IF(ISNAN((A(J)*PLOG + A(J+1))*PLOG + A(J+2))) call Bug IF(ISNAN(((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG)) call Bug IF(ISNAN(((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3))) call Bug IF(ISNAN(((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S4)) call Bug IF(ISNAN(PLOG*S1)) call Bug IF(ISNAN(S2 + PLOG*S1)) call Bug IF(ISNAN(PLOG*(S2 + PLOG*S1))) call Bug IF(ISNAN(S3 + PLOG*(S2 + PLOG*S1))) call Bug IF(ISNAN(PLOG*(S3 + PLOG*(S2 + PLOG*S1)))) call Bug IF(ISNAN(((A(J)*PLOG + A(J+1))*PLOG + A(J+2))*PLOG + A(J+3) + S4) + PLOG*(S3 + PLOG*(S2 + PLOG*S1)))) call Bug call Bug ! ? unknown END IF [/cpp]Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, as Les suggested, enable bounds checking to insure indexes are valid for TCP(L), A(J) and A(J+3)
Jim Dempsey
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