Archive for March, 2007

Automating gnuplot

I wanted to be able to generate Gnuplot images of my SPH results for an arbitrary number of state files. Thanks to the magic of shell scripting, I can!

Here is a bash script:

#! /bin/bash
ls sphstate.* > list
for i in `cat list` ; do
echo item: $i
sed -e "s/INPUTFILE/$i/" -e "s/OUTPUTFILE/$i/" sphplot.plt | gnuplot

Here is a gnuplot script:

set term png small
set output "OUTPUTFILEtemp.png"
plot "INPUTFILE" using 1:7 title "temperature"

Here are a few URLS:
Sed tutorial
Gnuplot IFAQs (recommended)
Bash scripting guide


Comments (2)


I have discovered that there is a (beta) IDE for fortran, based on Eclipse. I’m going to try it out – emacs just doesn’t do it for me, and is a whole other world (windows style keyboard shortcuts are burned into my brain – think ctrl-x, ctrl-v). The IDE is called Photran.

Update – eclipse has a learning curve, but it’s not hard to get started. Seems like a pretty nice IDE. Need to figure out how to make different targets – I’ve got a ‘put’ target that copies the source to the supercomputer, I need to use a shell to run it atm.

Leave a Comment


I’m resolving to be professional in my approach to the development that this project requires. Professional developers: use CVS for source code; make and frequently revise roadmaps; follow a set of style rules. Some of this stuff I alread do, this is a just a resolution to be more concious about it.
This was sparked by a conversation with a colleague in which it came out that the code in use in a major scientific organisation was basically a mess – global variables, no sense of structured-ness.

Leave a Comment

rsync is my friend

rsync -av username@host:sourcedir/ destdir/


rsync -av ~/mybackupfolder/monday1/

The slashes on the ends specify to copy the contents of the folders and not the folders themselves.

To use wildcards, use –include and –exclude flags e.g. rsync -avtubz –include=’/sa_*’ –exclude=’/*’ ~/backup/

Include arguments override subsequent exclude arguments.

Leave a Comment

Ubuntu shell scripts

I just wasted hours as a result of a “feature” of Edgy, the distro of Ubuntu I’ve installed on my new deck. The developers have replaced bash with dash as the shell that is invoked by scripts using #! /bin/sh

This has the effect of breaking scripts that rely on bash extensions. Apparently it is the script writers who are to blame – thing is I don’t care! What bugs me is that the process of installing my fortran compiler, so that I can get to work, was made more difficult. The developers who’ve stuck by this change have decided that trying to enforce a standard is more important than the usability of their software. One more truly annoying Ubuntu experience like this and I will start shopping for another distro.

There are several solutions to this – you can modify the scripts that fail such that they use bash (change #! /bin/sh to #! /bin/bash), or more simply you can change the symbolic link sh, found in the /bin directory, to point to /bin/bash. I went as far as uninstalling the dash shell on principle.

*Edit* Now that I’ve cooled down, I’ve reinstalled dash. The argument in favour of the change is a speedup of shell script execution, which it’s claimed leads to significantly faster startup times. Might as well make the most of it.

Leave a Comment


Multiple smoothing lengths has worked wonders. Now let’s hope we can get a homogeneous fluid at sup-critical temperatures!

Inkscape is not as capable as I’d hoped – it can’t read latex equations directly. (To be fair, there is an extension that does this, but it doesn’t want to play on my system). To import my equations into illustrations, then, I need to output postscript, and use gsview to convert it to paths. A little more manual that I was hoping, but acceptable.

Leave a Comment

Unix revision

My shell skills are a little rusty. Now that I’m relying on Ubuntu to be my main OS for development and writing, I better sharpen, cut and buff them.

Leave a Comment

Older Posts »