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

New Bug with Fortran

acobulareddy
Beginner
364 Views

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.

0 Kudos
4 Replies
Steven_L_Intel1
Employee
364 Views
I can't think of an explanation for this behavior. Can you provide a short but complete example?
0 Kudos
Les_Neilson
Valued Contributor II
364 Views
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
0 Kudos
jimdempseyatthecove
Honored Contributor III
364 Views

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
0 Kudos
jimdempseyatthecove
Honored Contributor III
364 Views

Also, as Les suggested, enable bounds checking to insure indexes are valid for TCP(L), A(J) and A(J+3)

Jim Dempsey
0 Kudos
Reply