PGI Guide to NetCDF

This guide is intended to help build and test the network Common Data Format libraries using the PGI 2010 compilers.

Version Information

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.

Application Notes

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."

Obtaining the Source Code

netCDF source code can be downloaded from anonymous FTP found at the netCDF FTP site or on the web at the netCDF FAQ page. The 4.0 release notes contain information about this release.

Prerequisites

None.

Building netCDF and Testing

  1. Untar the netCDF package:

    tar -xvzf netcdf-4.0.1.tar.gz
    cd netcdf-4.0.1
    
  2. Edit the file configure and change line 15973 from:

     *pgCC\ [1-5]* | *pgcpp\ [1-5]*)
    

    to

     *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.

  3. 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"
    
  4. Configure the source code:

    ./configure --prefix=/usr/local >& config.log
    
  5. Build the code:

    make >& make.log
    
  6. Test the build:

    make test >& make_test.log
    
  7. 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.

Known Issues

  1. -bind_at_load

    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

  2. Missing 32-bit header files

    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.

  3. HDF5

    NetCDF 4.x requires HDF5. To build without having HDF5 installed, use this command:

    ./configure --prefix=/user/local --disable-netcdf-4
    
Click me