Compiler Errors: A Personal Experience

I have encountered compiler errors in just about every compiler on every system I have ever used. In fact, I'm convinced that the only reason I didn't find errors in all of them is because I didn't work long enough with some of them. Occasionally, the errors were so bad that we just could not get some codes to work at all on some systems. But there is one particular incident that will always stand out for me.

A little mystery

For years, I had a plot pinned to the wall above my desk to remind me of the dangers of trusting compilers. The plot showed the predicted thickness of a planar shear layer as one moved downstream from a splitter plate (if I can find it again, I'll post it here). Two curves of CFD results were plotted, along with some experimental points. The CFD curves appeared to agree reasonably well with each other, although one was clearly predicting a thicker layer than the other. Both numerical predictions were in rough agreement with experiment.

The problem was that both CFD results were from the same code, run on the same machine, with the same freestream conditions. The only difference that I knew of was that one had been run some time prior to the other. They should have been identical to the last decimal point, but they clearly weren't. After a frenzied several days (or maybe a week or two...I forget), I finally figured out what had happened: I was a victim of compiler errors.

The mystery explained

This particular code was descended from one I wrote when I was working on my Ph.D. At the time, I played around with various compiler options, found a set that seemed to produce good accuracy and good performance, and then never looked at the issue again. That was my mistake.

It turned out that, between the two CFD runs, a compiler "upgrade" had taken place on the machines I was using. Some of the optimizations I had been using safely for years no longer maintained mathematical consistency. If they had just crashed the code, that would have allowed me to figure out what was happening fairly quickly and compensate.

Unfortunately, instead of causing an outright crash, the errors just modified the solution a little bit at each time step. Over time (tens of thousands of iterations, in this case), the solution could skew quite a bit, but it still LOOKED reasonable. The only way I found the problem was by comparing a new result with an older one for the same case. Fortunately, by backing off from some of the compiler optimizations, I was able to avoid the compiler errors and recover the original (correct) behavior.

The price of complacency

The cost of this particular episode was about three month's work flushed away. Don't let this happen to you!

Click here to explore some techniques you can use to avoid being burned by compiler errors. Or, you can head back to the Verification and Validation page or browse the other topics from the Innovative CFD home page.

New! Comments

Have your say about what you just read! Leave a comment in the box below.