Archive

Posts Tagged ‘Climategate’

The Met Office ‘climategate’ Perl code

December 25th, 2009 Derek-Jones 3 comments

In response to the Climategate goings on the UK Meteorological Office has released a subset of its land surface climate station records and some code to process it. The code consists of 397 lines of Perl (station_gridder.perl and make_global_average_ts_ascii.perl).

At various times I have been asked to suggest which part of an application’s or product’s source code should be made available to a third party. The third party may have been interested in evaluating the quality, getting a feel for the complexity or felt that they ought at least be able to say they had seen some code. In these situations there is always a trade-off between impressing the customer (e.g., well structured code containing lots of comments) and not revealing too much (e.g., impenetrable code with no comments).

Have the Met Office released the code they have used over a period of time or have they release newly written code?

The source does not have the characteristics often seen in well worn, ‘old’, code. There is no revision history (that may be due to poor programming practices or may have been stripped off prior to release; I discuss pretty printing below), the visual layout is generally consistent (this may be because the same small group of people have worked on it over time), there are no obvious hacks used to get around previous design decisions that have changed and unscientifically it just feels to me like newly written code.

Was the original code written in another language (e.g., Fortran), perhaps as part of a larger program and been rewritten in Perl?

The code does not have a Fortran ‘accent’ to it. The code was written by people who are fluent in Perl; perhaps they do not know Fortran very well and were given time to craft something presentable, hence no Fortran accent.

Why have I been referring to the code authors, plural, when writing 397 lines is well within the capabilities of a competent developer working for a day (I bet the authors spent longer in meetings about this code than actually writing it)? Developers tend to have very fixed habits when it comes to bracketing statements with curly braces, there are those who always put the open brace at the end of the line and those who always put it on a newline. The Met Office code contains both usages, sometimes within the same subroutine. Also the use of whitespace around punctuators and operators does not follow a consistent pattern, which for me rules out the use of an automated pretty printer and kind of implies more than one person doing the editing. And why are some variables names capitalized and other not (the names in subroutine read_station are all lower case while the names in the surrounding subroutines are mostly upper case)? More than one author is the simplest answer.

One Perl usage caught my eye, the construct unless is rarely used and often recommended against. Without a lot more code being available for analysis there are no obviously conclusions to draw from this usage (apart from it being an indicator of somebody who knows Perl well, most mainstream languages do not support this construct and developers have to use a ‘positive’ construct containing a negated condition rather than a ‘negative’ construct containing a positive condition).

Parsing Fortran 95

December 20th, 2009 Derek-Jones No comments

I have been looking at doing some dimensional analysis of the Climategate code and so needed a Fortran parser.

The last time I used Fortran in anger the modern compilers were claiming conformance to the 1977 standard and since then we have had Fortran 90 (with a minor revision in 95) and Fortran 03. I decided to take the opportunity to learn something about the new features by writing a Fortran parser that did not require a symbol table.

The Eli project had a Fortran 90 grammar that was close to having a form acceptable to bison and a few hours editing and debugging got me a grammar containing 6 shift/reduce conflicts and 1 reduce/reduce conflict. These conflicts looked like they could all be handled using glr parsing. The grammar contained 922 productions, somewhat large but I was only interested in actively making use of parts of it.

For my lexer I planned to cut and paste an existing C/C++/Java lexer I have used for many projects. Now this sounds like a fundamental mistake, these languages treat whitespace as being significant while Fortran does not. This important difference is illustrated by the well known situation where a Fortran lexer needs to lookahead in the character stream to decide whether the next token is the keyword do or the identifier do5i (if 1 is followed by a comma it must be a keyword):

      do 5 i = 1 , 10
      do 5 i = 1 . 10        ! assign 1.10 to do5i
5     continue

In my experience developers don’t break up literals or identifier names with whitespace and so I planned to mostly ignore the whitespace issue (it would simplify things if some adjacent keywords were merged to create a single keyword).

In Fortran the I/O is specified in the language syntax while in C like languages it is a runtime library call involving a string whose contents are interpreted at runtime. I decided to to ignore I/O statements by skipping to the end of line (Fortran is line oriented).

Then the number of keywords hit me, around 190. Even with the simplifications I had made writing a Fortran lexer looked like it would be a lot of work; some of the keywords only had this status when followed by a = and I kept uncovering new issues. Cutting and pasting somebody else’s lexer would probably also involve a lot of work.

I went back and looked at some of the Fortran front ends I had found on the Internet. The GNU Fortran front-end was a huge beast and would need serious cutting back to be of use. moware was written in Fortran and used the traditional six character abbreviated names seen in ‘old-style’ Fortran source and not a lot of commenting. The Eli project seemed a lot more interested in the formalism side of things and Fortran was just one of the languages they claimed to support.

The Open Fortran Parser looked very interesting. It was designed to be used as a parsing skeleton that could be used to produce tools that processed source and already contained hooks that output diagnostic output when each language production was reduced during a parse. Tests showed that it did a good job of parsing the source I had, although there was one vendor extension used quiet often (an not documented in their manual). The tool source, in Java, looked straightforward to follow and it was obvious where my code needed to be added. This tool was exactly what I needed :-)

Does the Climategate code produce reliable output?

November 30th, 2009 Derek-Jones No comments

The source of several rather important commercial programs have been made public recently, or to be more exact programs whose output is important (i.e., the Sequoia voting system and code and data from the Climate Research Unit at University of East Anglia the so called ‘Climategate’ leak). While many technical commentators have expressed amazement at how amateurish the programming appears to be, apparently written with little knowledge of good software engineering practices or knowledge of the programming language being used, those who work on commercial projects know that low levels of software engineering/programming competence is the norm.

The emails included in the Climategate leak provide another vivid example, if one were needed, of why scientific data should be made publicly available; scientists are human and are sometimes willing to hide data that does not fit their pet theory or even fails to validate their theory at all.

The Climategate source has only only recently become available and existing technical commentary has been derived from embarassing comments and the usual complaint about not using the right programming language (Fortran is actually a good choice of language for this problem, it is widely used by climatology researchers and a non-professional programmer is probably makes best of their time by using the one language they know tolerably well rather than attempting to use a new language that nobody else in the research group knows).

An important quality indicator of the leaked software was what was not there, test cases (at least I could not find any). How do we know that a program’s output is correct? One way to gain some confidence in a program’s correctness is to process data for which the correct output is known. This blindness to the importance of program level correctness testing is something that I often encounter in people who are subject area experts rather than professional programmers; they believe that if the output has the form they are expecting it must be correct and will sometimes add ‘faults’ to ‘fix’ output that deviates from what they are expecting.

A quick visual scan through the source showed a tale of two worlds, one of single letter identifier names and liberal use of goto, and the other of what looks like meaningful names, structured code and a non-trivial number of comments. The individuals who have contributed to the code base obviously have very different levels of coding ability. Not having written any Fortran in anger for over 15 years my ability to estimate the impact of more subtle coding practices has atrophied.

What kind of faults might a code review look for in these programs? Common coding errors such as using uninitialized variables and incorrect argument passing are obvious choices and their are tools available to check for these kinds of error. A much more insidious kind of error, which requires people with the mathematical expertise to spot, is created by the approximate nature of floating-point arithmetic.

The source is not huge, but not small either, consisting of around 64,000 lines of Fortran and 16,000 lines of IDL (a language designed for interactive data analysis which to my untrained eye looks a lot like MATLAB). There was no obvious support for building the source included within the leaked files (e.g., no makefiles) and my attempt to manually compile using the GNU Fortran compiler failed miserably. So I cannot say anything reliable about the compiler output warnings.

To me the complete lack of test cases implies that the Climategate code does not produce reliable output. Comments in the code such as ***** APPLIES A VERY ARTIFICIAL CORRECTION FOR DECLINE********* suggests that the authors were willing to patch the code to produce output that matched their expectations; this is the mentality of somebody for whom code correctness is not an important issue and if they don’t believe their code is correct then I don’t either.

Source code in itself is rarely that important, although it might have been expensive to create. The real important information in the leaked files is the climate data. Now that this is available others can apply their analysis skills to provide an interpretation to what, if anything statistically reliable, it is telling us.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com name brand cialis

best price for generic cialis

canada propecia prescription

generic viagra canada

internet pharmacy propecia

for sale levitra

buy dosages levitra

generic levitra purchase

get propecia online pharmacy

cialis cheap

lowest propecia prices in canada

getting cialis from canada

lowest price for propecia

canada meds viagra

china viagra

daily dosage cialis

buying propecia

how much does cialis cost

levitra in india

buy cialis fedex shipping

cialis soft pills

healthcare canadian pharmacy

generic propecia sale

buy levitra vardenafil

ordering cialis gel

lowest price propecia best

natural viagra

buy viagra mexico

best price generic propecia

generic viagra india

canadian viagra and healthcare

buy levitra uk

discount us propecia

cheapest propecia prescription

buy cialis usa

buy generic viagra india rx

mail online order propecia

low price levitra

buy discount viagra

order cheap propecia

levitra pill

canada viagra

canadian pharmacies cialis

canadian pharmacy viagra

generic propecia finasteride

obtain viagra without prescription

canadian pharmacy discount code viagra

cialis and ketoconazole

cheap order prescription propecia

canadian pharmacy cialis

generic propecia 5mg

levitra viagra cialis

cost of propecia

cialis cheap us pharmacy

cialis 20 mg

buy viagra without prescription

buy propecia online from usa pharmacy

cialis next day delivery

buy online prescription propecia

levitra 10mg

cialis 100 mg generic

levitra prescription

best price cialis

genuine cialis pills

cheap levitra uk

buy cialis online uk

cialis woman

brand name cialis overnight

cialis in mexico

generic viagra made in usa

cialis 5 mg

discount generic propecia

online pharmacy propecia renova

online levitra

cialis headaches

levitra for sale

cialis pharmacy

cheap propecia online prescription

cheapest price propecia cheap

buy levitra online no prescription

buy now propecia

buy propecia online

levitra online us

levitra canadian

best viagra

buy prescription propecia without

cialis price in canada

generic levitra cheap

levitra mail order

buy cialis in usa

low cost canadian viagra

i need to buy propecia

buying online propecia

order generic levitra

buy cheap generic propecia

canadian healthcare

cialis en mexico

can i get viagra in mexico

lowest priced propecia

buy can from i propecia who

discount propecia rx

buy levitra online viagra

buy cialis 5 mg

cialis online

cialis 5 mg italia

levitra online

cialis alternative

cheap cialis from india

order cheapest propecia online

buy real viagra online

hydrochlorothiazide cialis

discount levitra rx

herbal propecia

canada viagra generic

levitra in canada

order levitra online

combine cialis and levitra

cheap viagra online

cialis overnight delivery

levitra online prescription

once daily cialis

cheap prescription propecia

cialis next day

buy propecia without prescription

buy canada levitra

cialis purchase

levitra mg

levitra online no prescription

cialis 50 mg

cheap propecia 5mg

buy cialis cannada

cialis vs levitra

cheap fast levitra

buy real cialis

low cost propecia

canadian healthcare viagra

cialis and diarrhea

cheap viagra canada or india

buying generic propecia

online generic cialis 100 mg

fda levitra

cialis uk

online propecia uk

buy propecia online prescription

gele viagra

cialis on women

ordering propecia online

best price for propecia

online cialis

cialis from mexico

get levitra

lowest cost levitra

canadian online pharmacy cialis

order cheap levitra

generic propecia online pharmacy

buy viagra online

generic levitra vardenafil

best way to use cialis

mail order levitra

levitra low price

best price levitra

cheapest propecia uk

buy viagra

indian cialis generic

levitra discount

indian viagra

discount propecia online

generic viagra made in india

canada online pharmacy levitra

info levitra

cheap levitra prescription

cheapest overnight cialis

generic levitra online

lowest propecia 1 mg

levitra cost

female viagra pills

levitra online overnight delivery

cialis price

generic propecia fda approved

buy levitra online from canada

buy propecia canada

buy cialis online canada

buying cialis

canadian pharmacy

cialis buy overnight

levitra buy online

levitra sales uk

brand viagra over the net

buy cheap generic levitra

cheap levitra

cialis tablets

cheap cialis

canadian viagra india

cialis discounts

how strong is 5 mg of cialis

buy propecia now

buying viagra in canada

does generic cialis work

how much is viagra

order propecia

lowest price on non generic levitra

cialis strenght mg

discount levitra online

online viagra gel to buy

buy propecia generic

levitra viagra online

buy generic cialis

buy branded viagra

online propecia prescription

lowest price levitra

mexico pharmacy cialis

online pharmacy propecia viagra

how much cialis

generic cialis sale

cialis profesional

buy cialis once daily

get cialis online

cialis 100 mg

canadian viagra

canada generic propecia

buy 5 mg cialis

generic cialis from india

cheap levitra without prescription

cheapest propecia sale uk

cheapest viagra online

levitra online sales

bio viagra herbal

50 mg cialis

lowest propecia prices

cheap viagra from uk

buy viagra on line

mexico levitra

cheap propecia uk

mail order propecia

generic levitra overnight delivery

cialis by mail

cialis fast delivery

best price propecia

overnight delivery cialis

generic propecia alternative

cialis daily in canada

buying cialis soft tabs 100 mg

brand cialis for sale

levitra from canadian pharmacy

cheapest prices for viagra

cialis for woman

cialis professional 20 mg

cialis from canada

buying levitra online

low cost levitra

buy propecia online pharmacy

cheap canadian viagra

buy propecia prescriptions online

cialis quick shipment

buy generic propecia

discount drug propecia

buy propecia on line

levitra cheap fast

cialis 5 mg buy

online ordering propecia

buying cialis next day delivery

generic viagra canadian

canada levitra

cialis to buy

cialis tablets foreign

buy fast propecia

cialis and canada custom

canada viagra pharmacies scam

get cialis

how to buy cialis in canada

buy cialis without prescription

next day viagra

order prescription propecia

cialis professional no prescription

cialis daily dosage pharmacy

buy propecia where

cost of viagra

canadian propecia rx

cheap cialis soft

cialis overnight

buy viagra germany canadian meds

cialis fast delivery usa

cialis professional 100 mg

canadian viagra 50mg

buy cheap levitra

cialis generic 100 mg

cialis discount

buy generic levitra

cialis no prescription

canada cheap propecia

cheapest viagra

levitra tabs

cheap propecia online

buy cialis for daily use

buy cheapest propecia

cialis transdermal

discount cialis india

cialis delivered overnight

buying generic cialis mexico rx

online cheap viagra