The following platform-specific note may be helpful when building and installing netCDF. Consult your vendor manuals for information about the options listed here. Compilers can change from version to version; the following information may not apply to your platform.
Full output from some of the platforms of the test platforms for netCDF 4.1.1 can be found at http://www.unidata.ucar.edu/netcdf/builds.
We found the vendor compilers in /usr/vac/bin, and included this in our PATH. Compilers were xlc, xlf, xlf90, xlC.
The F90 compiler requires the qsuffix option to believe that F90 code files can end with .f90. This is automatically turned on by configure when needed:
FCFLAGS=-qsuffix=f=f90
We had to use xlf for F77 code, and xlf90 for F90 code.
To compile 64-bit code, set the appropriate environment variables (documented below).
The environment variable OBJECT_MODE can be set to 64, or use the -q64 option on all AIX compilers by setting CFLAGS, FFLAGS, and CXXFLAGS to -q64.
The following is also necessary on an IBM AIX SP system for 64-bit mode:
ARFLAGS='-X64 cru' NMFLAGS='-X64'
There are thread-safe versions of the AIX compilers. For example, xlc_r is the thread-safe C compiler. To use thread-safe compilers, override the configure script by setting CC to xlc_r; similarly for FC and CXX.
For large file support, AIX requires that the macro _LARGE_FILES be defined. The configure script does this using AC_SYS_LARGEFILES. Unfortunately, this misfires when OBJECT_MODE is 64, or the q64 option is used. The netCDF tries to fix this by turning on _LARGE_FILES anyway in these cases.
The GNU C compiler does not mix successfully with the AIX fortran compilers.
NetCDF builds under Cygwin tools on Windows just as with Linux.
The HP Fortran compiler (f77, a.k.a. fort77, also f90) requires FLIBS to include -lU77 for the fortran tests to work. The configure script does this automatically.
For the c89 compiler to work, CPPFLAGS must include -D_HPUX_SOURCE. This isn't required for the cc compiler. The configure script adds this as necessary.
For large file support, HP-UX requires _FILE_OFFSET_BITS=64. The configure script sets this automatically.
The HPUX C++ compiler doesn't work on netCDF code. It's too old for that. So either use GNU to compile netCDF, or skip the C++ code by setting CXX to ” (in csh: setenv CXX ”).
Building a 64 bit version may be possible with the following settings:
CC=/bin/cc CPPFLAGS='-D_HPUX_SOURCE -D_FILE_OFFSET_BITS=64' # large file support CFLAGS='-g +DD64' # 64-bit mode FC=/opt/fortran90/bin/f90 # Fortran-90 compiler FFLAGS='-w +noppu +DA2.0W' # 64-bit mode, no "_" suffixes FLIBS=-lU77 CXX='' # no 64-bit mode C++ compiler
Sometimes quotas or configuration causes HPUX disks to be limited to 2 GiB files. In this cases, netCDF cannot create very large files. Rather confusingly, HPUX returns a system error that indicates that a value is too large to be stored in a type. This may cause scientists to earnestly check for attempts to write floats or doubles that are too large. In fact, the problem seems to be an internal integer problem, when the netCDF library attempts to read beyond the 2 GiB boundary. To add to the confusion, the boundary for netCDF is slightly less than 2 GiB, since netCDF uses buffered I/O to improve performance.
A 64-bit version can be built by setting the appropriate environment variables.
Build 64-bit by setting CFLAGS, FFLAGS, and CXXFLAGS to -64.
On our machine, there is a /bin/cc and a /usr/bin/cc, and the -64 option only works with the former.
The f2cFortran flag is required with GNU fortran:
CPPFLAGS=-Df2cFortran
For Portland Group Fortran, set pgiFortran instead:
CPPFLAGS=-DpgiFortran
Portland Group F90/F95 does not mix with GNU g77.
The netCDF configure script should notice which fortran compiler is being used, and set these automatically.
For large file support, _FILE_OFFSET_BITS must be set to 64. The netCDF configure script should set this automatically.
The f2cFortran flag is required with GNU fortran (CPPFLAGS=-Df2cFortran). The NetCDF configure script should and set this automatically.
For IBM compilers on the Mac, the following may work (we lack this test environment):
CC=/usr/bin/cc CPPFLAGS=-DIBMR2Fortran F77=xlf FC=xlf90 FCFLAGS=-qsuffix=cpp=f90
NetCDF builds out of the box on OSF1.
PATH should contain /usr/ccs/bin to find make, nm, ar, etc.
For large file support, _FILE_OFFSET_BITS must be 64, also _LARGEFILE64_SOURCE and _LARGEFILE_SOURCE must be set. Configure will turn this on automatically for netCDF, but not for HDF5. So when building HDF5, set these variables before running configure, or HDF5 will not be capable of producing large files.
To compile in 64-bit mode, set -m64 (formerly -xarch=v9, which works on SPARC platforms only) on all compilers (i.e. in CFLAGS, FFLAGS, FCFLAGS, and CXXFLAGS).
When compiling with GNU Fortran (g77), the -Df2cFortran flag is required for the Fortran interface to work. The NetCDF configure script turns this on automatically if needed.
Commercial fortran compilers will generally require at least one flag in the CPPFLAGS variable. The netCDF configure script tries to set this for you, but won't try if you have used –disable-flag-setting, or if you have already set CPPFLAGS, CFLAGS, CXXFLAGS, FCFLAGS, or FFLAGS yourself.
The first thing to try is to set nothing and see if the netCDF configure script finds your fortran compiler, and sets the correct flags automatically.
If it doesn't find the correct fortran compiler, you can next try setting the FC environment variable to the compiler you wish to use, and then see if the configure script can set the correct flags for that compiler.
If all that fails, you must set the flags yourself.
The Intel compiler likes the pgiFortran flag, as does the Portland Group compiler. (Automatically turned on if your fortran compiler is named “ifort” or “pgf90”).
Alternatively, Intel has provided a web page on “Building netCDF with the Intel compilers” at http://www.intel.com/support/performancetools/sb/CS-027812.htm, providing instructions for building netCDF (without using the pgiFortran flag).
The Portland Group also has a “PGI Guide to NetCDF” at http://www.pgroup.com/resources/netcdf/netcdf362_pgi71.htm.