Ada Lovelace day

March 24th, 2010

It is Ada Lovelace day today.

I would like to thank Frances Zhang for putting up with me in supervisions this year and for being really hard working and understanding things I don’t (e.g. probability) and not boasting about it as I tend to (sorry).

Dina Bester is generally awesome, has supplied pizza for many hungry CompScis and was willing to take on project Bravo which I thought looked pretty impossible and got a good project out at the end.

Sarah Gordon for doing a Women@CL talk which showed how testing can be exciting and be just as complicated and technical as writing the code that runs the project while requiring a greater understanding of how the whole project fits together.

I also think that Ada Lovelace day is a good idea and I am glad that my operating system (Ubuntu) is supporting it (or at least the Ubuntu Planet is). Making the internet a better place, one step at a time :-).

The first programmer was a women (Ada), the first programmers (ENIAC) were women, it is sad that the proportion of women in Computer Science now is as low as it is. Especially since they get proportionally more 1sts in CompSci.

Postgres, ResultSets and Concurrency

February 15th, 2010

I thought I had found a concurrency bug in PostgreSQL because a ResultSet that was local to a method was being closed by activity occurring in a different thread.

Then I read: “Once you make another query with the Statement used to create a ResultSet, the currently open ResultSet instance is closed automatically.” on http://jdbc.postgresql.org/documentation/84/resultset.html

Which means that I will have to make my code slightly less concurrent to work around that :-(.

I suspect it prevents bad coders from causing resource leaks though. So it is probably a good design decision.

This is why your unit tests should check for concurrency flaws :-).

Online Banking: liabilities

December 30th, 2009

I was surprised to find that the co-operative bank’s policy is not as evil as “Security Engineering” would suggest bank’s policies are. Specifically:

“We will repay you any money that is taken from your account due to: any error by our staff or our systems, a computer crime which is not found and stopped by our security system.”

Whereas “Security Engineering” suggests that in general UK banks say ‘you are an evil criminal’ if a computer crime against your account succeeds.
Halifax says:

“If a customer of our online service is a victim of online fraud, we guarantee that they won’t lose any money from their account and will always be reimbursed in full.”

but I suppose the “our system is secure and so online fraud is not possible so you are a criminal” trick might work there…
Possibly this means that banks policies are improving as they realise that tackling fraud is their responsibility. (Perhaps they read the book which is very good).

From the point of view of login security the co-operative would give me a chip and pin card reader to verify online transactions which gives better security than Halifax’s username + password + some random fact that would be very easy to find out using something like facebook. (though there are flaws in such a chip and pin system detailed in the book).

Only 5 chapters left to read… :-)

Election Day

June 4th, 2009

Today 4th June 2009 is the day of the European (and local council) elections.
This is the first election in which I can vote, and I will most definitely be voting.
If you are reading this and can vote but aren’t intending to I really think you should.

Part of the reason for writing this is to solidify my decision as to who I am going to vote for. Now at all previous elections since 1997 which is the first one I remember I would have voted Labour had I had a vote. At this election I will most definitely not be voting Labour. There are a number of policies on which Labour would have to make U-turns before I would consider voting for them, ID cards and centralised databases of far too much personal data about innocent people are a couple of things which mean that I can’t support them, there are other reasons such as various wars (I marched against the War in Iraq back at the beginning of that whole mess) and their Complete failure to do anything much about the Climate Change.
Now it appears from their election leaflets that the Conservatives are backward looking eurosceptics and as such they won’t be getting my vote either.
Now who does that leave? Well there are a whole pile of loony parties a few I have never heard of and two parties that appear fairly sane and which I have heard of. These would be the Liberal Democrat Party and the Green Party.
Now my father who has voted Labour since forever and been a member of the Labour party just as long is not voting Labour at this election but instead Green. (or at least I think he is). Things have changed.
Now what is the most important issue which we face? The most important issue that we face is Climate Change. Now Blair said that and he was right, but then he was good at talking but bad at actually doing things.
We have until 2015 to cause CO2 emissions to peak. That is a very tall order but when the alternative is the extinction of 90% of life on earth there isn’t really any choice.
Now I think that the Liberal Democrats understand that the environment is important but will my voting for them tell the other parties how important the environment is?
Now the European elections have proportional representation which means every vote counts in a way that first past the post doesn’t. So I think that for the European elections I will be voting Green.
And then I ask myself the question, how much do I care. And the answer is that I care a lot. I care if people live or die. I care about the future. I am going to find out what happens in this grand experiment we are playing with our world. I am going to see millions of people die due to Anthropomorphic Climate Change in my life time. That is something I can’t prevent. The choice is this: how many millions will I watch die. I live in the hope of a better world. I believe among other things that we should leave the world in a better state than we found it.

And so here at my first vote I shall make a choice between life and death. To that choice I have only one answer Life. For the sake of the children I hope to have one day. For the sake of my family and friends and of their children. For my own selfish sake and because one of our fundamental responsibilities is the stewardship of this planet.

I think I shall vote Green twice once in the European and once in the Local Elections.
I shall never give up hope, even through the horrors we will witness in this century we can make a better world. I care enough to cry for, I care enough to live for, I care enough that even this coward will stand up and be counted.

VOTE: For Life, Freedom, and Democracy.

Renewable energy policies

April 8th, 2009

Recently I have been reading books such as “Six Degrees: our future on a hotter planet,” “The Transition Handbook” and various others as part of my research for an essay I am writing for the Sir Geoffrey Ellis essay prize at Peterhouse, part of the reason I entered was because I wanted to write the essay (geek) and partly because I haven’t written essays recently and I knew that I needed practice (nerd). The title of the essay is: “Surviving Transition: Sustainability in the 21st Century” currently it runs to 5675 words (limit 6000) and it is almost done.

This explains why I am thinking about renewable energy policies. The position I am coming from is that drastic changes need to happen and that they need to happen very very quickly.

This is the policy:

In the first year all new buildings or buildings that are having their roof replaced must have all suitable roof area covered in either solar thermal or photovoltaic solar panels. This would only be mandatory on buildings that had some sort of electricity supply. Architects should be advised to maximise the potential of roof area to capture solar energy.
In the second year this would additionally apply to all buildings being sold or having their tenant changed.
In the third year all public buildings must comply.
In the fourth year all business premises must comply
In the fifth year all suitable buildings must comply.

In the UK this would first start in Cornwall which has the highest sunlight intensity in the UK(and in the 2 that come next in terms of sunlight intensity), the next year it would begin in the three counties with the next highest sunlight intensity and so on.
In Australia this would apply to the top third of states for sunlight intensity, in the second year it would apply to the second third and in the third year to the bottom third.
When this policy has been applied to the whole of England then England would produce 150%[1] of its electricity needs from solar power (though the area used for solar thermal would of course be reducing gas etc. usage rather than electricity) the additional electricity produced during daylight hours would be used to pump water up into reservoirs so that it could be released at night.
In Australia many areas have problems with water shortages, it also has a higher sunlight intensity and so would produce even more electricity than the UK. The excess electricity in daylight hours would be used to desalinate sea water and pump it into reservoirs so that water supplies would be increased and during the night water would be released for irrigation etc. allowing the production of electricity and alleviating drought. I don’t know the specifics of how much water could be produced by this method but I hope that it would be enough to supply most of Australia’s needs as in the future Climate Change may result in significantly lower rainfall in Australia.
I will now go even further out in terms of craziness of ideas with sufficient production of electricity more than enough water would be produced and the extra water could be used not only to irrigate areas of farmland that are currently suffering problems but also to encourage forests that are having difficulties. Forests such as the Amazon are self sustaining in that if they were to disappear as is quite likely to happen as early as 2050 then the area turns completely to desert. My particularly crazy idea is that it might be possible to do the reverse and create large forests (okay probably huge orchards as that would make more money) and that this might then increase rainfall and so cause such forests to become self sustaining and spread. This would help with the decreasing rainfall that Australia is likely to suffer in the future and provide a carbon sink.
Something similar needs to happen in Brazil – which has some very dry areas – but it has the problem of poverty.

There is far more that I have to say on this but I need to do some more real work now.

[1] I am recalling this figure from memory I read it at least 3 years ago it may be inaccurate as solar panels might be more efficient now.

Compiling JULES on Ubuntu Intrepid Linux

February 5th, 2009

I have obtained the source code for JULES which is one of the components that the Met Office uses to forecast the weather. Compiling it was not straightforward and required the modification of several source files.

The modified files and .patch files can be found here.

First I will outline the route I took to the most working binary.

An almost working way

1) in Makefile:

1.1) Setting the location of the netcdf libaries (you will probably need to install these)

JULESDIR=$(PWD)
CDF_LIB_PATH=/usr/lib/
CDF_MOD_PATH=/usr/include/

1.2) and to enable the use of the gfortran compiler

ifeq ($(COMPILER),g95)
include $(JULESDIR)/Makefile.comp.g95
endif
ifeq ($(COMPILER),gfortran)
include $(JULESDIR)/Makefile.comp.gfortran
endif
ifeq ($(COMPILER),nag)
include $(JULESDIR)/Makefile.comp.nag
endif

rather than

ifeq ($(COMPILER),g95)
include $(JULESDIR)/Makefile.comp.g95
endif
ifeq ($(COMPILER),nag)
include $(JULESDIR)/Makefile.comp.nag
endif

2) in Makefile.common.mk:

GRMPATH=$(which grm)

ifneq ($(strip $(GRMPATH)),)
    RM=grm -f
endif

RMPATH=$(which rm)

ifneq ($(strip $(RMPATH)),)
    RM=rm -f
endif

ifndef RM
    $(error No rm equivalent command found)
endif

rather than

RM=grm -f

grm means GNU rm, on a linux system rm is GNU rm, so rm should be used rather than grm the conditionals mean that if the met office run the code on their setup it ‘should work’ and if someone runs it on a normal linux distribution it should still work.

cp Makefile.comp.g95 Makefile.comp.gfortran

3) in Makefile.comp.gfortran:

In order to select the gfortran compiler rather than g95, as gfortran is available for Ubutnu/debian while g95 is not.

FC=gfortran -fno-underscoring

rather than:

FC=g95

and

MOD_PUT=-J

rather than:

MOD_PUT=-fmod=

4) Then to compile

make BUILD=run COMPILER=gfortran CDFDUMMY=true

#BUILD could also be debug or fast.
#CDFDUMMY is needed even though you can install netcdf from the repositories – because if you set it false you get:

/home/daniel/dev/JULES/jules-v2-0/libjules.a(RWERR_MOD.o): In function `__rwerr_mod_MOD_rwerr':
RWERR_MOD.f90:(.text+0xaae): undefined reference to `__netcdf_MOD_nf90_inquire_dimension'
RWERR_MOD.f90:(.text+0xed7): undefined reference to `__netcdf_MOD_nf90_strerror'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_closecdf':
JULES_NETCDF.f90:(.text+0xd): undefined reference to `__netcdf_MOD_nf90_close'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_check_nc_dims':
JULES_NETCDF.f90:(.text+0x2e1): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_readvar2dreal_ncvector_gswp2':
JULES_NETCDF.f90:(.text+0x566): undefined reference to `__netcdf_MOD_nf90_inq_varid'
JULES_NETCDF.f90:(.text+0x8b1): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0xbb9): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0xeed): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0x1160): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0x1477): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o):JULES_NETCDF.f90:(.text+0x178e): more undefined references to `__netcdf_MOD_nf90_get_var_1d_fourbytereal' follow
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_opencdf':
JULES_NETCDF.f90:(.text+0x1c24): undefined reference to `__netcdf_MOD_nf90_open'
collect2: ld returned 1 exit status
make: *** [jules.exe] Error 1

Successful compilation should result in:

gfortran -fno-underscoring -o jules.exe /home/daniel/dev/JULES/jules-v2-0/JULES.o \
	    /home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy/JULES_NETCDF_DUMMY.o \
	    -L/home/daniel/dev/JULES/jules-v2-0  -L/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -J/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -ljules

Alternatively try to use g95 as recommended

1) Install g95

From here: http://www.gfd-dennou.org/library/cc-env/g95/index.htm.en#label-5
g95 is not available in either Ubuntu or Debian repositories – for unknown reasons.

2) follow steps 1.1 and 2 from the instructions for gfortran.

3) try to compile

make BUILD=run COMPILER=g95 CDFDUMMY=true

If you do this there is no possibility of using netcdf prebuilt binaries according to: http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg04125.html
This is because they were built for gfortran and so will only work with gfortran.

unfortunately this results in:

g95 -o jules.exe /home/daniel/dev/JULES/jules-v2-0/JULES.o \
	    /home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy/JULES_NETCDF_DUMMY.o \
	    -L/home/daniel/dev/JULES/jules-v2-0  -L/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -fmod=/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -ljules
/home/daniel/dev/JULES/jules-v2-0/libjules.a(SOILHY7A.o):(.data+0x0): undefined reference to `darcy_'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(SOILHY7A.o):(.data+0x4): undefined reference to `hyd_con__'
make: *** [jules.exe] Error 1

Running Jules

To run jules you will need to

mkdir OUTPUT

after successfully compiling

and then to run a test run using one of the shipped examples:

./jules.exe < point_loobos_example.jin

unfortunately doing this I got:

At line 152 of file SFSNOW7A.f
Fortran runtime error: Array reference out of bounds for array 'snowcanpft', upper bound of dimension 1 exceeded (6 > 5)

Also trying:

./jules.exe < grid_gswp2_example.jin

fails because:

Opening /users/global/rjel/jules/gswp2_files/lsmask_vector.nc
 fileFormat=nc
 ERROR: attempting to use a netCDF procedure, but netCDF library not available.
 This is a 'dummy' procedure.
 To use netCDF, remake model with the 'proper' netCDF library.

as we compiled with CDFDUMMY=true …

Conclusion

It is possible to compile JULES on Ubuntu Linux with a bit of work. However compiling a working version of JULES on Ubuntu Linux may be beyond my current ability (I don’t know any FORTRAN).

Hopefully this will help someone.

Thanks as always go to the denizens of #srcf on irc.srcf.ucam.org

Replacing the battery on a CASIO 1572 watch

January 13th, 2009
The watch in question (CASIO 1572)

The watch in question (CASIO 1572)

This was harder than expected and I did not find any instructions on the internet – the manual from the CASIO website was useless.

The battery required was a CR 2016 which I got from maplin.

Getting the battery out and putting a new one in was not too hard – taking the back off required a small philips screwdriver and then the central section was levered out and the inner metal cover removed by unclipping it. Putting the new battery in was also similarly easy.

However this did not make the watch work – it was still blank and needed reseting – though the light worked. I could find no way of fixing it and so in the end I held down the light button and poked the copper contacts inside with a pin connecting them to the outer metal case in the hope of flipping some switch somewhere and so making it work – to my surprise this worked.

Note: that there is a little spring inside the case and so be very careful when turning the inside section upside down to keep your finger over the spring to stop it falling out.

1.0 release of fractals

December 14th, 2008

I realise that this is definitely a namespace clash but hey.
After a few days work and significant help from #cl on the srcf irc my fractals program is ready for 1.0 release – at least in my eyes there are no known bugs – save that there may be more efficient algorithms to use especially from the point of view of quality of display – see here for an example of tc’s better version of carpet.

The ML code is released under GPL version 2 and can be found here

To compile it you will need a version of Moscow ML with its libraries – e.g. NOT the one shipped by Ubuntu which does not have the libraries packaged – hopefully this will be fixed in Jaunty – I used the version on the linux pwf machines at Cambridge University. All other instructions on compilation are included as a comment in the file.

Examples of output can be found here

This is an extension of ML Tick6* Foundations Of Computer Science at Cambridge University

And now for the pretty pictures:

part of the mandelbrot set

part of the mandelbrot set

koch curve

koch curve

Koch Snowflake

Koch Snowflake

Sierpiński Triangle

Sierpiński Triangle

Sierpiński Carpet

Sierpiński Carpet

Brownian Curve

Brownian Curve

Random Walk

Random Walk

Cheese ham and egg toasty.

November 11th, 2008

This is not a toasty blog but I am currently experimenting with different types of toasty and here is one not entirely obvious but delicious.

It is possible, make sure you heat the toasty maker up first and cook thoroughly

It is possible, make sure you heat the toasty maker up first and cook thoroughly

at least on top - but not necessaryly safe yet - so cook them again in a toasty.

at least on top - but not necessaryly safe yet - so cook them again in a toasty.

the eggs peel off nicely without making a mess and then go into the toasty, try and put them evenly across the dividing line so that both sides of the toasty get the same amount of egg.

the eggs peel off nicely without making a mess and then go into the toasty, try and put them evenly across the dividing line so that both sides of the toasty get the same amount of egg.

cheese ham and egg ready to cook

cheese ham and egg ready to cook

Lunch - when you can make all this with only a toasty maker who needs hobs... :-), it was delicious.

Lunch - when you can make all this with only a toasty maker who needs hobs... :-), it was delicious.

Chocolate toasty

November 10th, 2008

After the delicious but very messy chocolate toasty I had in SPT 5 on Sunday I decided that in order to stay awake during physics I was going to have to make a really nice chocolate toasty for breakfast, so I got up ten minutes early and it was delicious and not messy at all. It can be done! (with a fully functional toasty maker).

These photos document the results:

Ingredients of a chocolate toasty. Brown bread, chocolate spread, thin dark chocolate pieces, some chocolate digestive (not enough).

Ingredients of a chocolate toasty. Brown bread, chocolate spread, thin dark chocolate pieces, some chocolate digestive (not enough).

mmm chocolate toasty.

mmm chocolate toasty.

It cleaned up nicely

It cleaned up nicely