dr-evilBy Claire

When I decided that doing two separate projects within my PhD was a good idea, I must have recently eaten too many nerds. What was I thinking??

My PhD consists of two very separate sections. The first part, which is mostly finished and ready to be written up, involved producing a paleoclimate record using stalagmites. I have slabbed and milled my sample, run it through the mass spec, plotted the results more times and in more ways than one would think possible, I’ve sent sections for dating and run samples again for trace elements. I’ve done all of that and I have a really nice delta18O record of monsoon changes over the past 40,000 years to show for it.

Now I’m on to the second part. Modelling.

The idea of doing climate modelling (to me at least) seemed so romantic. I’d walk up to a giant computer, say, “excuse me computer, any chance you could show me what the Younger Dryas might have looked like?” The computer would wink at me and then begin thinking until it had a nice, neat answer that it showed me, similar to a David Attenborough documentary, complete with incredible graphics and voice over explaining how everything works and fits together.

Now that it has actually come time to walk up to the giant computer and try to get an idea of what the Younger Dryas might have looked like, I realise that I couldn’t have been more wrong. 

It turns out that my hopes of walking up to a computer and speaking with my climate model are laughable. It turns out, climate models don’t speak English (or any other language available in Google Translate). They speak Fortran.

For those of you lucky enough to have no idea what hell Fortran is, let me enlighten you.

Fortran was first developed in the 1950s as a way to make computer coding closer to human language. It was the first high level programming language and was written before the time of user friendliness. Unfortunately, it still exists today, despite predictions it would die out. Climate models happen to be one of the stragglers.

Throughout my attempts to learn this language so far, I have been to many user forums, looking for a place to start. The almost unanimous answer I seem to find is, “Don’t do it!”

hCE140E14Even people who understand Fortran don’t understand Fortran.

Unfortunately, if I ever want to actually speak to my model, rather than just copy and paste scripts and follow instructions sheets (as is my interaction so far), I need to learn Fortran.

I have found a pretty good free online tutorial, which I am attempting to get through. Much to my frustrations, I have hit “lesson 5 – arrays” and been faced with this example:

program alloc
implicit none
integer, allocatable,dimension(:):: vector
!note syntax – dimension(:)
integer :: elements,i
print *,’enter the number of elements in the vector’
read *,elements
!allocates the correct amount of memory print *,’ your vector is of size ‘,elements,’. Now enter each element’ do i=1,elements
read *,vector(i) end do
print *,’This is your vector’
do i=1,elements print *,vector(i)
end do
!tidies up the memory end program alloc

While I can grasp the basic concepts of what’s going on, the thought that I will have to write code much more complicated than this one is pretty frightening.

I even attempted to interact with the model using a script I was provided. I was actually managing to follow the gist of the script, until I came to this:

foreach arg ($MONDATA/JAN*[0-9].acc$RUN.nc )
set year=`basename $arg | awk ‘{print substr($1,4,4)}’`
set svyr=`basename $arg | awk ‘{print substr($1,7,1)}’`
set svdc=`basename $arg | awk ‘{print substr($1,4,3)}’`
# echo -n Working for $year…
# Check for unzipped years that already have annual averages.
if ( -f $MONDATA/ANN$year.acc$RUN.nc ) then
# echo “File ANN$year.acc* already exists, moving & compressing”
$EXECDIR/bzip -9f $MONDATA/???$year.acc*
goto loopend

Ummmmm. Yes. And this isn’t even part of the model! This is just part of a script that averages the model output into annual files.

So it turns out that starting something that you have no idea about in the middle of a PhD is not such a great idea*. Especially if you don’t speak the right language.

Blog readers, please! Do you have any hints for someone who knows no programming at all trying to learn Fortran?

* Just in case my PhD panel members read this post, I am still getting great results from the model. I’m just not able to program the model myself. Or do anything other than press play and collect the output, which is actually still not a bad achievement 🙂