This is a module that you will need when you come to the exercise when you add a module to GLIMMER-CISM. It's not available through the Ubuntu package manager, so you will install it yourself into your own filespace.
Compiling the Module
OK, first thing's first, let's get the source code. Open a terminal, stay in (move to) your home directory and cut and paste the following:
Now, we'll unpack the tarball, and move into the appropriate directory:
tar -xzf pycdf-0.6-3b.tar.gz cd pycdf-0.6-3b
You will need to edit the file called setup.py to reflect where you installed your NetCDF libraries. Scroll down a short way in the file and edit the line library_dirs (note the 3 options in the conditional and assuming your followed Ian's NetCDF build instructions to the letter; you'll also need to substitute your own username):
elif USE == NUMPY: from numpy.distutils.misc_util import get_numpy_include_dirs _pycdf_ext = Extension(extName, sources = CCode, #library_dirs=["non standard path where libs live"], library_dirs=["/home/PSU/pdx05933/installs/netcdf-4.0.1/lib"], include_dirs = get_numpy_include_dirs(), libraries = ["netcdf"])
Once you've done that, you can compile and install the module with the command:
python setup.py install --prefix=~/py
If you have administrative privileges you can install it on your machine for all users:
python setup.py build
sudo python setup.py install
Setting your PYTHONPATH
We will need to make the new module available to your python installation. A good way to do this is to add the following to your shell start-up file, called ~/.bashrc (the ~ indicating that the file is in your home directory):
then, in order to re-read that start-up file, you will need to type:
The next time you open a new shell, your PYTHONPATH environment varaible will be set automatically, and you won't need to bother with all that source .. malarky.
Checking that it Works
OK, let's make sure that everything is hunky dori. Move back to your home directory and start python:
You'll see a prompt such as:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
Now, import the module, by typing:
If you get no errors, all is well: type ctrl-D to exit Python.