Thanks for all the comments. I still have plenty to learn but I remain confused regarding the array size definition.
In this case all arrays are dimensioned in calling routines or are global. As the program can handle differing no of pieces of data to solve, they have plenty of room. In this example, n=49 but the high of x[], y[], n[n] and c[] and d[] is 200. They are dimensioned from 0..200 and 0 is never called, and 200 will never be reached. I would also have thought if the arrays were out of range I would get an error but I don't. All of this worked without error in another program with the arrays dimensioned as above, no changes to the calling routines or the routines in question and both are compiled on the same machine. So I am struggling to see the issue being array dimensioning. I know I can do better with dimensioning of arrays and what I do is not elegant or good practice, but it has always worked in the past.
I understand its only a snippet of code and hard for anyone to spot any issue on this alone. The overall code is maybe a bit large to include here but maybe I can get it cut down to the basics that are fundamental to this problem, though I was just wondering if there was a reason the for loop was jumping out part way through because of some known daft thing I wasn't aware of.
Thanks again for the comments, I will look into it further and see what happens.