This problem is discussed on this webpage
One statement there reads:
The book by Steve McDonnell (Code Complete, 2nd Edition. Redmond, Wa.: Microsoft Press, 2004. 960 pages. ISBN: 0735619670} has a brief section about error expectations. He basically says that the range of possibilities can be as follows:
(a) Industry Average: "about 15 - 50 errors per 1000 lines of delivered code." He further says this is usually representative of code that has some level of structured programming behind it, but probably includes a mix of coding techniques.
(b) Microsoft Applications: "about 10 - 20 defects per 1000 lines of code during in-house testing, and 0.5 defect per KLOC (KLOC IS CALLED AS 1000 lines of code) in released product (Moore 1992)." He attributes this to a combination of code-reading techniques and independent testing (discussed further in another chapter of his book).
(c) "Harlan Mills pioneered 'cleanroom development', a technique that has been able to achieve rates as low as 3 defects per 1000 lines of code during in-house testing and 0.1 defect per 1000 lines of code in released product (Cobb and Mills 1990). A few projects - for example, the space-shuttle software - have achieved a level of 0 defects in 500,000 lines of code using a system of format development methods, peer reviews, and statistical testing."
Obviously, the references cited are rather old, but from browsing through different posts on that webpage, i got the impression that a rate of 0.1 bugs per KLOC would be a conservative (likely underestimate) estimate.
Are estimates known for climate models, and satellite retrieval products?