Sara, I have just tried on my Ubuntu (12.04) and your code works fine. I am using the following packages: libnetcdf-dev 1:4.1.1-6 libnetcdf6 1:4.1.1-6 netcdf-bin 1:4.1.1-6 So my guess is that your problem may be related to an old bug... Can you update your system and try again? Best, Virgilio