This guide was created for the 4.0.1 release of netCDF and PGI 2010 release. This information is for both x64 processors running 64-bit Linux or Mac OS X and x86 processors running 32-bit Linux or Mac OS X.
Information about netCDF can be found at the netCDF FAQ page.
(From the webpage) "NetCDF (network Common Data Form) is an interface for array-oriented data access and a freely-distributed collection of software libraries for C, Fortran, C++, Java, and perl that provide implementations of the interface. The netCDF software was developed by Glenn Davis, Russ Rew, Steve Emmerson, John Caron, and Harvey Davies at the Unidata Program Center in Boulder, Colorado, and augmented by contributions from other netCDF users. The netCDF libraries define a machine-independent format for representing scientific data. Together, the interface, libraries, and format support the creation, access, and sharing of scientific data."
Untar the netCDF package:
tar -xvzf netcdf-4.0.1.tar.gz cd netcdf-4.0.1
Edit the file configure and change line 15973 from:
*pgCC\ [1-5]* | *pgcpp\ [1-5]*)
*pgCC\ [1-5].* | *pgcpp\ [1-5].*)
These changes will allow the match for the PGI 2010 release 10.0 and above compilers to fall through to a lower stanza rather than matching a stanza intended for PGI compilers prior to Release 6.0.
Set up your environment:
setenv CC pgcc setenv CXX pgcpp setenv FC pgf90 setenv LD pgf90 setenv CFLAGS "-O2 -Msignextend" setenv FFLAGS "-O2" setenv CPPFLAGS "-DpgiFortran"
Configure the source code:
./configure --prefix=/usr/local >& config.log
Build the code:
make >& make.log
Test the build:
make test >& make_test.log
Finally, install the results:
sudo make install
Note the example above uses the csh command setenv to set the environment variables. Please change this to match your shell's method of setting environment variables.
The exact optimizations you use should be adjusted depending upon how you compile the applications that will use the netCDF library. If your application is 32-bits and is compiled with ‑Mcache_align or the aggregate flag ‑fastsse which contains ‑Mcache_align, then you must add ‑Mcache_align or ‑fastsse to the CFLAGS and FFLAGS. Failure to do so may result in a segmentation violation cause by mismatched data alignment.
The netCDF build scripts use ‑bind_at_load which can cause PGI compilers to react poorly. To work around this problem, create or edit a siterc file with these contents:
switch -bind_at_load is replace(-bind_at_load) positional(linker);
Place (or find) the file in $PGI/linux86/2010/bin/siterc and $PGI/linux86-64/2010/bin/siterc or in $PGI/osx86/2010/bin/siterc and $PGI/osx86-64/2010/bin/siterc
If the configuration fails with the following error:
... checking whether we are cross compiling... configure: error: in `/home/me/Documents/netcdf-4.1.3': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details
The cause is likely you're building on a 64-bit machine. NetCDF requires some 32-bit header files. To install them, enter:
sudo apt-get install libc6-dev-i386
Once this package is installed, the configure should proceed without error.
NetCDF 4.x requires HDF5. To build without having HDF5 installed, use this command:
./configure --prefix=/user/local --disable-netcdf-4