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."
Download the source code to a DOS directory. Trying to build in a Cygwin directory or in a shared directory can complicate the process. Untar the netCDF package.
tar -xvzf netcdf-4.0.1.tar.gz cd netcdf-4.0.1
Edit the file libsrc/v2i.c and on line 12 add:
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 the lower stanza.
Set up your environment:
setenv AR pgar setenv NM pgnm setenv CC pgcc setenv CXX pgcpp setenv CFLAGS "-O2 -V -Msignextend" setenv FC pgf90 setenv LD pgf90 setenv F90 pgf90 setenv FFLAGS "-O2" setenv CPPFLAGS "-DpgiFortran -D_MSC_VER" setenv PGI_OBJSUFFIX "o"
Download the files getopt.c and getopt.h from http://www.pwilson.net/sample.html. Add the two files to both ncdump and ncgen directories. The two files are also available from this web site as part of a netCDF zip archive.
Edit ncdump/ncdump.c, ncdump/dumplib.c and ncgen/genlib.c and replace all instances of snprintf with _snprintf.
Edit ncdump/Makefile.am and add getopt.c and getopt.h to the line starting with ncdump_SOURCES.
Edit ncdump/Makefile.in and add getopt.$(OBJEXT) to the line starting with am_ncdump_OBJECTS.
Edit ncgen/Makefile.am and add getopt.c and getopt.h to the line starting with ncgen_SOURCES.
Edit ncgen/Makefile.in and add getopt.$(OBJEXT) to the line starting with am_ncgen_OBJECTS.
Configure the source code:
./configure --enable-shared --prefix=C:/dos/path/to/install/directory
Build the code:
make >& make.log
Test the build:
make test >& make_test.log
Note that some of the ncgen tests fail but the libraries are complete and installable.
Finally, install the results:
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