Next: Additional Porting Notes, Previous: Installing NetCDF, Up: Building and Installing NetCDF on Unix Systems
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 3.6.2 can be found at http://www.unidata.ucar.edu/software/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 (we hope):
F90FLAGS=-qsuffix=f=f90
We had to use xlf for F77 code, and xlf90 for F90 code.
To compile 64-bit code, use the –enable-64bit option when running configure, and it will set the appropriate environment variables for you (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. The NetCDF configure script ignores these compilers. 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.
Cygwin is a Linux-like environment for Windows. NetCDF builds under Cygwin tools on Windows just as with Linux. For more information see the Cygwin web site: http://www.cygwin.com.
Building under Cygwin will yield a DLL on windows (as long as –enable-shared is used with configure). However this DLL will not work without the Cygwin POSIX emulation DLL as well. For a stand-alone DLL, use MinGW (below).
MinGW, or Minimalist GNU for Windows, is a set of GNU Unix tools ported to Windows. The NetCDF C and Fortran APIs builds under MinGW tools on Windows just as with Linux.
Those diving into netCDF and MinGW should be familiar with the information at the web page “Different Ways of Building Woe32 DLLs” at: http://www.haible.de/bruno/woe32dll.html, the MinGW FAQ at: http://www.mingw.org/mingwfaq.shtml, and the peculiarities of the win32 environment as explained by this helpful Red Hat document at: http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/win32.html.
The netCDF C++ API does not (yet) build DLLs cleanly under MinGW. Any knowledgeable user who can make this work should send results to the netCDF support email address: support@unidata.ucar.edu.
Using MinGW it is possible to produce stand-alone windows DLLs. First build netCDF in the usual way, with –enable-shared and –enable-dll as configure options.
This builds the DLL for compatibility with g77. Set FC to the command line invocation of your fortran compiler. To build for other fortran compilers (i.e. ones you don't have), change the config.h file to select another fortran and recompile (without rerunning configure).
The fortran tests will not, of course, work for these other fortrans, because you don't have the compiler to compile the test program!
FC=g77 ./configure --enable-dll --disable-cxx --enable-shared make check
Due to the magic of libtool, the output files are found in the libsrc/.libs directory.
To get a MS compatible export library, open an MS DOS window, change directory to libsrc/.libs and run the following command:
lib /machine:i386 /def:libnetcdf.def
The above command uses the Microsoft LIB tool, which comes with Visual C++.NET, and perhaps other Microsoft development tools. (To get this in my path, I open the “Visual Studio 2003 Command Prompt” in my Windows program menu.)
This command creates the .lib file, the import library, needed (or at least used) by MicroSoft (and other) build environments on Windows.
For more information about MinGW, see the MinGW web site: http://www.mingw.org. For more information about producing stand-alone windows DLLs with MinGW, see the MinGW FAQ: http://www.mingw.org/mingwfaq.shtml.
For the c89 compiler to work, CPPFLAGS must include -D_HPUX_SOURCE. This isn't required for the cc compiler.
Our HPUX machine has two C compilers. Only the one in /opt/ansic/bin/ works for netCDF.
For large file support, HP-UX requires _FILE_OFFSET_BITS=64. The configure script sets this automatically.
The HPUX C++ compiler (on our machine) 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 ”), or using the –disable-cxx option.
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 with the –enable-64bit option when running configure; it will set the appropriate environment variables for you.
It builds 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 FC=xlf F90=xlf90 F90FLAGS=-qsuffix=cpp=f90
For the g95 compiler, you must set LIBS to -lSystemStubs before running configure.
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. Configure will turn this on automatically.
Large file support doesn't work with c89, unless the -Xa option is used. The netCDF configure script turns this on automatically where appropriate.
To compile in 64-bit mode, use option –enable-64bit with configure. It sets -xarch=v9 on all compilers (i.e. in CFLAGS, FFLAGS, 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.
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 requires that netCDF be built with the pgiFortran flag. It will be automatically turned on by configure if your fortran compiler is named “ifort.”
The Portland Group fortran compiler requires that netCDF be built with the pgiFortran flag. It will be automatically turned on by configure if your fortran compiler is named “pgf90.”
The GNU Fortran 77 compiler (g77) requires that netCDF be built with the f2cFortran flag. This is turned on automatically by configure. Since g77 can't build Fortran 90 code, the F90 API will not be built if g77 is the only available fortran compiler.
The version 4 series of gcc, the GNU Compiler Collection, offers a F95 compiler, usually called gfortran. NetCDF requires the pgiFortran flag to build with gfortran, and this is turned on automatically by configure.
g95 is a Fortran 95 compiler which is different from the Free Software Foundation's gfortran. The netCDF configure script sets the f2cFortran flag when g95 is used.
Some g95 users recommend instead setting the following, which handles the underscores differently, and reportedly works better when integrating with other packages or libraries:
CC=gcc FC=g95 CPPFLAGS=-DpgiFortran FFLAGS=-fno-second-underscore FCFLAGS=-fno-second-underscore
If this approach is taken, all fortran programs which use netCDF must be compiled with the -fno-second-underscore flag.
One the Macintosh, g95 requires environment variables LIBS and FLIBS to be set to -lSystemStubs.
Older versions of the GNU C++ compiler don't handle large files well. A version 3.2 installation of g++ fails to build for me without –disable-largefile. This turns off the ability of netCDF to handle files larger than about 2 GiBytes. Users should upgrade their g++, or learn to live with small files.