Most of the scientific code is awful, in climate science and elsewhere, because the constraints are totally different than commercial code. Maintainability is not so much a concern, and it is only a tool to obtain a result, not an end in itself. People don't care about the code quality most of the time.
There is another concern, which is that you rarely know what you exactly want when programming for research. You don't always have the time to design reasonable API, because the requirements keep changing - and keep in mind that you cannot spend too much time on this because you have to write papers, do some actual research, etc...
Even in my field, which is engineering and where people are expected to be more "programming methods-aware", most of the code is awful. My own code for research is awfully bad compared to what I release as open source for scientific programming: when I release something, I easily spend several times as much work on the thing, because of documentation issues, etc... Doing this for all my code is simply not possible.
If you want to dismiss climate science because of code quality, be ready to throw away the majority of science, from biology to IA through EE. Just look at lapack code: the code is awful, using goto to avoid structured programming, etc... (e.g. http://www.netlib.org/lapack/double/dsgesv.f). And it is used by 99 % of code which does linear algebra, including commercial software.