Well, somewhere, that program is doing something "unusual" or something which is made worse (to the point of failure) just through the size in some way.
Which level of OPTimization are you using? If not 0, try with 0.
You could do a "quick inspection" of the 40,000-line program(!) and see if you spot anything that looks odd...
If you fancy some fun, you can try to "binary chop" it to locate the problem.
This may not work if there is too much "interaction" (of some type) causing the problem and you happen to "fix" it by reducing the interaction.
Let's say you have 40,000 lines of procedure code.
You consider one (approximate) half of that code. If you remove all of the code within paragraphs/SECTIONs for that half, but leave those labels, the program should still compile - although you'll get RC=8 - if it can.
If the program compiles, try with the other "half". If that fails now in the same way, then you may be on to something. Chop that half into halves again, in the same way, and recompile to get if either gives a failure.
Continue until both current "halves" of the previous (half of the half of the half...) compile without the issue. You would then have a considerably smaller chunk of code that exhibits the problem.
However, bear in mind that even OPT(0) (which you should use if you attempt this) does some optimisations and, although I've not used V5, I fear that that may include at least some, and perhaps lots or all, "unused code", which will likely defeat the process.
If this is so, X-clude all the PERFORMs when you delete the code. That should get the compiler to think things are happening.
Of course, if the code for the PERFORMs is "jam everything on one line if you can, then overflow to the next", that could well be too much to readily fix-up for the dummy compile.
Are you using any of the new compiler options available with V5? If so, turn those off, use TRUNC(STD) and NUMPROC(PFD).
It can be fun to narrow it down, but at the end of the day IBM will sort it out anyway. I just love looking at things like that
