Those who know me know I spend an inordinate amount of time developing or trying to develop radiative-convective models of planetary atmospheres. This serves my interests in planetary astronomy and climatology (see the Climatology pages on this site). To write such a model you need a good programming language. I'm writing a book on how to write these models, so the language needed to be one I could explain to a reader without writing a whole programming book.
I had several criteria for which programming language to use. The most important one, considering my perpetually terrible finances, was that the compiler be free. I specify a compiler because I didn't want to touch interpreters, due to their slow speed. If you don't know the difference between a compiler and an interpreter, it's not too important, but please be aware that this page is full of such techie terms. For the record, a compiler produces "native code" on a computer so the program can run as fast as possible. An interpreter runs the program through another program which then carries out the instructions. The difference in speed can be substantial.
I'll list the criteria I used here. Some I started out with; some I developed as I tried various candidates and found roadblocks to what I wanted to do.
Here are the criteria the language I wanted had to meet:
After investigating several dozen free compilers available through the internet, I settled on a mere four final candidates:
Here is how they all stacked up on requirements 1-8:
|Requirement||Free Basic||Free Pascal||MingW C||Salford Fortran-95|
|Produces console applications?||✓||✓||✓||✓|
|Has console text manipulation?||✓||✓||X||X|
|Easy to learn?||✓||✓||X||✓|
|Neat numeric output?||X||✓||✓||✓|
|Reads mixed strings and numbers?||✓||X||✓||✓|
As you can see, they all had a few problems. Some were solvable with a lot of effort. Others were easier to handle. I review here, briefly, what I found by testing each one.
Free Basic was easy to use, easy to learn, and easy to debug. It was also a powerful language, with commands to do all kinds of interesting things. But both the functions it provided for neat numeric output -- PRINT USING and FORMAT -- were buggy. I tried to write my own routines and developed something that appeared to work against all testing after several days of patient debugging. But the point is, I shouldn't have had to.
I tried alerting the Free Basic community to the problem, and some other folks confirmed that it was there, but I was unable to make a bug report because I hadn't joined something called the SourceForge network, and even if I had, it would be some time before the fixes were incorporated in a new version of the language. Since my lifespan is limited and my time valuable, I decided to kiss off Free Basic.
Free Pascal was also both powerful and easy to learn. But I found error trapping difficult to make work right, and as a result, programs that blew up showed me nothing readable before killing the console window. I ran into a bug where the language could not read both string and numeric output on the same record. I couldn't find out what the problem was on my own. I posted the problem in the user forums. No one ever replied. So screw Free Pascal.
MingW C was powerful, but being a dialect of the C programming language, was a total pain in the rear to learn. No matter, I had trained on the old DOS Power C and on Borland's Turbo C, and I thought I could explain C to an audience of readers easily enough, if I went slowly enough. But this version of C turned out to lack the clrscr (clear screen) and gotoXY (position text cursor) functions found in other C dialects. And when I asked the user community about it, I was told that I should be developing Windows applications and not console apps, and that there was no good reason to provide console functions. So I kissed off MingW C and its hostile, supercilious user community.
Salford Fortran-95, Personal Edition was powerful, had an immensely helpful IDE, and could produce console apps -- but like MingW C, had no routines to clear the screen or move the text cursor. Here, however, the forums were very helpful (perhaps because many of the posters were polite UK citizens and not hostile, touchy Americans). By calling the Windows API ("Application Programming Interface," a part of Windows which provides various functions for programmers), I was able to produce reliable screen-clearing and text-positioning subroutines in less than one day. Criterion 9 saved the day for the problem with Criterion 4.
Fortran also has the advantage that it was the first compiled language, having gotten its first compiler in 1957 (three years before I was born, for those who are interested). It had had nearly fifty years to get thoroughly debugged, and was still the language of choice for scientific applications, due to its rich suite of mathematical functions. Fortran it was. I had trained on Fortran IV (the 1966 standard) and Fortran-77 (the 1977 standard, obviously), so the 1995 standard wasn't too hard to learn. Especially since Salford Fortran retained some F77 features for backwards compatibility with old apps.
Thus my choice of Fortran for my research, and for the book. If you have some other compiler which meets the criteria I list, or if you're a good enough programmer to go around the problems, there's no reason you can't use your own language to write RCMs. The algorithms are basically the same whatever the language.