Difference between revisions of "UsingNetCDF"

From SourceWiki
Jump to navigation Jump to search
Line 5: Line 5:
 
=Admin Details=
 
=Admin Details=
 
==Compiling the NetCDF Libraries from Unidata==
 
==Compiling the NetCDF Libraries from Unidata==
 +
 +
The source code can be downloaded from Unidata:
  
 
<pre>
 
<pre>
Line 10: Line 12:
 
</pre>
 
</pre>
  
 +
Now, unpack the tarball and build the libraries:
  
 
<pre>
 
<pre>
 
tar -xzf netcdf-4.0.tar.gz
 
tar -xzf netcdf-4.0.tar.gz
 
cd netcdf-4.0
 
cd netcdf-4.0
./configure --prefix=/opt/netcdf/netcdf-4.0 --enable-shared FC=ifort CC=gcc CXX=g++ CPPFLAGS="-DpgiFortran"
+
./configure --prefix=/opt/netcdf/netcdf-4.0 --enable-shared FC=ifort CC=gcc CXX=g++ CPPFLAGS="-DpgiFortran" \
 +
FCFLAGS="-fpic" CFLAGS="-fPIC" CXXFLAGS="-fPIC"
 
make
 
make
 
make check
 
make check
Line 20: Line 24:
 
</pre>
 
</pre>
  
 +
Note that we need to build the '''shared''' libraries.  Hence the addition of the '''-fPIC''' flags
  
 
==Installing the Python Interface==
 
==Installing the Python Interface==

Revision as of 17:00, 9 June 2009

Using NetCDF files for your data

Introduction

Admin Details

Compiling the NetCDF Libraries from Unidata

The source code can be downloaded from Unidata:

wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.0.tar.gz

Now, unpack the tarball and build the libraries:

tar -xzf netcdf-4.0.tar.gz
cd netcdf-4.0
./configure --prefix=/opt/netcdf/netcdf-4.0 --enable-shared FC=ifort CC=gcc CXX=g++ CPPFLAGS="-DpgiFortran" \
FCFLAGS="-fpic" CFLAGS="-fPIC" CXXFLAGS="-fPIC"
make
make check
make install

Note that we need to build the shared libraries. Hence the addition of the -fPIC flags

Installing the Python Interface

wget http://sourcesup.cru.fr/frs/download.php/1833/Numeric-23.8.2.tar.gz
tar -xzf ...
cd Numeric...
python setup.py install
wget http://sourcesup.cru.fr/frs/download.php/2309/ScientificPython-2.8.tar.gz
cd ..
tar ...

but now need to hack setup.py for:

  • netcdf path
  • problems with /usr/lib and /usr/lib64

perhaps easiest to just patch with a symbolic link:

cd /usr/lib/python2.4/site-packages
ln -s /usr/lib64/python2.4/site-packages/Scientific