I have some code that calls a passed-in function called YDDZIC inside a loop. For 22 iterations this works fine but on the 23rd it crashes out of the whole program when it hits the END statement of the YDDZIC Function. The table below shows a side-by-side comparison of the local variables on the 22nd (left) and 23rd(right) iterations. The obvious difference here is that BRTS and X_1 are undefined in the 23rd iteration, it is also notable that I5, IBODY0 and IX0 are negative, these are used as array indices.
However when I step through the code (also below) the debugger steps all the way to the END statement before it falls over and I was wondering why it doesn't fail sooner, is it that it actually performs the evaluation when the end statement is reached? That seems unlikely because the debugger needs to determine the intermediate variables values. Any other ideas why it doesn't fall over before reaching the END statement?
ENTRY YDDZID ( XI ) C Find the envelope spline bay containing XI. I = ISEG2 C Use the spline coefficients to find area slope at XI. I5 = IBODY0 + (I-1)*5 DX = XI - BODY(I5+1) DS = BODY(I5+3) + + DX*( 2.0 * BODY(I5+4) + + DX* 3.0 * BODY(I5+5)) C Ward function of X-XI DX = X(IX0+1) - XI Z = DX*BR W = (A0 + Z*(A1 + Z*A2)) / + (B0 + Z*(B1 + Z*(B2 + Z*(B3 + Z*B4)))) C Integrand in W&F linear phi' equation YDDZID = W*DS RETURN * ======> END
<Edit> I put the variables in as a table but they just came out as a list so I have attached an image of the variables</edit>