This guide was created for the release 3.6.3 of netCDF and PGI Release 2012 pgfortran and pgcc compilers. This information is for both x64 processors running 64-bit Linux and x86 processors running 32-bit Linux. Linux.
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."
To build and run netCDF, you will first need to create a working directory and a final directory. Decompress the netcdf.tar.Z or netcdf.tar.gz package and then untar it in the working directory. Then run configure command and then the make command to produce the result. Finally, run the various tests by executing make test.
tar -xvzf netcdf-3.6.3.tar.gz cd netcdf-3.6.3
Edit the file configure and change line 15586 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.
env CC=pgcc CFLAGS="-fast -Msignextend" FC=pgfortran F90=pgfortran FFLAGS="-fast -w" \ CXX=pgcpp CPPFLAGS="-DNDEBUG -DpgiFortran" ./configure -prefix=/usr/local make make test
Note that some shell environments will ignore the env command listed above. If this occurs, please set each environment variable before executing the configure script.
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.
IPA will automatically obtain IPA from a library provided that the library was built with ‑Mipa and the application adds the IPA suboption ‑Mipa=libopt. If you believe your applications may use IPA optimziations, add ‑Mipa or ‑Mipa=fast to the CFLAGS and FFLAGS. Adding IPA to netCDF will not effect applications that do not use IPA.
If you get undefined reference errors to __builtin_alloca, the libnecdf_c++.a library was built with a compiler other than pgCC. This occurs because using env before ./configure doesn't work in some environments. You will need to edit your make.macros file with the correct variables as listed above and rebuild or individually set the environment variables and rerun ./configure.
If the build fails with the following error:
/usr/include/features.h: fatal error: bits/predefs.h: No such file or directory
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.