(The latest version of this document is available at http://www.unidata.ucar.edu/packages/netcdf/INSTALL.html.
This document contains instructions for building and installing the netCDF package from source on various platforms. Prebuilt binary releases are (or soon will be) available for various platforms from http://www.unidata.ucar.edu/packages/netcdf/binaries.html.
If you wish to report problems encountered during the installation of this package, see Reporting Problems below. You may also want to try the latest beta release of netCDF, which may have recent fixes for some problems.
Depending on the platform, you may need up to 25 Mbytes of free space to unpack, build, and run the tests. You will also need a Standard C compiler. If you have compilers for FORTRAN 77, FORTRAN 90, or C++, the corresponding netCDF language interfaces may also be built and tested.
If you wish to build from source on a Windows (Win32) platform, different instructions apply. We have pre-built netCDF 3.5.0 libraries for Win 95/98/NT, available here. To do your own source build, get this zip file (these make files are for Microsoft Visual C 6 and Digital Fortran 6, you will have to modify for a different environment). Read WIN32_README.TXT for more info.
Select and specify an appropriate build environment. If necessary, set whichever of the environment variables CC, CFLAGS, CPPFLAGS, FC, FFLAGS, CXX, CXXFLAGS, F90, and F90FLAGS are needed to represent that environment.
If you don't set an environment variable, the
configure script will try to figure out a reasonable
value.
(See Setting Environment
Variables to learn how to set environment variables.)
| Variable | Description | Notes |
|---|---|---|
| CC | C compiler | If you don't specify this, the configure script will try to find a suitable C compiler such as cc, c89, xlc, or gcc. |
| FC | Fortran compiler (if any) | If you don't specify this, the configure script will try to find a suitable
Fortran 90 or Fortran 77 compiler. Set FC to "" explicitly,
if no Fortran interface is desired. |
| F90 | Fortran 90 compiler (if any) | If you don't specify this, the configure script will try to find a suitable
Fortran 90 compiler. Not needed if FC specifies a Fortran 90 compiler. Set
F90 to "" explicitly, if no Fortran 90 interface desired. |
| CXX | C++ compiler | If you don't specify this, the configure script will try to find a suitable
C++ compiler. Set CXX to "" explicitly, if no C++ interface
is desired. |
| CFLAGS | C compiler flags | "-O" or "-g", for example |
| CPPFLAGS | C preprocessor options | "-DNDEBUG" to omit assertion checks, for example |
| FFLAGS | Fortran compiler flags | "-O" or "-g", for example |
| F90FLAGS | Fortran 90 compiler flags | "-O" or "-g", for example. If you don't specify
this, the value of FFLAGS will be used. |
| CXXFLAGS | C++ compiler flags | "-O" or "-g", for example |
| ARFLAGS NMFLAGS FPP M4FLAGS LIBS FLIBS FLDFLAGS |
Miscellaneous | One or more of these were needed for some platforms, as specified below. Unless specified, you should not set these environment variables, because that may interfere with the configure script. |
The section marked Tested Systems below contains a list of systems on which we have built this package, the environment variable settings we used, and additional commentary.
configure ScriptTo create the Makefiles needed to build netCDF, you must run the
provided configure script. Go to the top-level netCDF
src/ directory.
Decide where you want to install this package. Use this for the
"--prefix=" argument to the
configure script below. The default installation prefix
is "..", which will install the package's files in
../bin, ../lib, and ../man relative to the netCDF src/
directory.
Execute the configure script:
./configure --prefix=whatever_you_decided
The "--prefix=..." specification is optional; if omitted, ".."
designating the parent directory will be used as a default.
The configure script will examine your computer system -- checking
for attributes that are relevant to building the netCDF package. It will print
to standard output the checks that it makes and the results that it finds.
The configure script will also create the file "config.log", which
will contain error messages from the utilities that the configure
script uses in examining the attributes of your system. Because such an examination
can result in errors, it is expected that "config.log" will contain
error messages. Therefore, such messages do not necessarily indicate a problem
(a better indicator would be failure of the subsequent "make"). One exception,
however, is an error message in "config.log" that indicates that a compiler
could not be started. This indicates a severe problem in your compilation environment
-- one that you must fix.
Run "make". This will build one or more netCDF libraries. It will
build the basic netCDF library libsrc/libnetcdf.a. If you have Fortran 77 or
Fortran 90 compilers, then the Fortran interfaces will be included in this library.
If you have a C++ compiler, then the C++ interface will be built into the library
cxx/libnetcdf_c++.a. This will also build the netCDF utilities ncgen(1) and
ncdump(1).
Run "make test" to verify that the netCDF library and
executables have been built properly. This will build and run various
test programs that test the C, Fortran, and C++ interfaces as well as
the "ncdump" and "ncgen" utility programs. Lines in the output
beginning with "***" report on success or failure of the tests; any
failures will be reported before halting the test. Compiler and
linker warnings during the testing may be ignored.
To install the libraries and executables, run "make
install". Try linking your applications. Let us know if you
have problems (see Reporting Problems
below). Port the library to other platforms. Share data.
The following are environment variable settings that we've used to build netCDF-3 on various systems -- plus commentary. Take your pick if there is more than one set of settings for a particular system. For some platforms we have provided a simple setting for building the library and another setting that uses optimization flags (though optimization may not make much difference for an I/O library). On some platforms compilers emit harmless warning messages, which you can safely ignore unless the tests performed in the "make test" step fail.
If you don't find your environment listed here, then try http://www.unidata.ucar.edu/packages/netcdf/other-builds.html for reports of successful builds of this package in environments to which we had no access.
We found the vendor compilers in /usr/vac/bin, and included this
in our PATH.
The minimum set of environment variables that worked:
FC=xlf
F90FLAGS=-qsuffix=f=f90
F90=xlf90
--------
OBJECT_MODE=32
CC=xlc_r
CPPFLAGS=-DNDEBUG
CFLAGS='-D_LARGE_FILES -O -qmaxmem=-1 -qarch=auto -bmaxdata:2000000000 -bmaxstack:256000000'
FC=xlf_r
FFLAGS='-O -qarch=auto -bmaxdata:2000000000 -bmaxstack:256000000'
F90=xlf90_r
F90FLAGS='-qmaxmem=-1 -qsuffix=f=f90 -qarch=auto -bmaxdata:2000000000 -bmaxstack:256000000'
CXX=xlC_r
CXXFLAGS='-D_LARGE_FILES -O -qmaxmem=-1 -qarch=auto -bmaxdata:2000000000 -bmaxstack:256000000'
--------
OBJECT_MODE=64
CC=xlc_r
CPPFLAGS=-DNDEBUG
CFLAGS='-O -D_LARGE_FILES -O -qmaxmem=-1 -qarch=auto'
FC=xlf_r
FFLAGS='-O -qarch=auto'
F90=xlf90_r
F90FLAGS='-O -qsuffix=f=f90 -qmaxmem=-1 -qarch=auto'
CXX=xlC_r
CXXFLAGS='-O -D_LARGE_FILES -O -qmaxmem=-1 -qarch=auto'
AIX gale 3 4 001330614C00
CC=/bin/xlC
FC=/bin/xlf
F90=/bin/xlf90
F90FLAGS=-qsuffix=f=f90
CXX=/bin/xlC
--------
CC=/bin/xlc
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC=/bin/xlf
FFLAGS=-O
F90=/bin/xlf90
F90FLAGS=-qsuffix=f=f90 # Note: no "-O" option
CXX=/bin/xlC
CXXFLAGS=-O
When we added the "-O" option to the Fortran-90 compilation
flags, the result was an error message "1501-229 Compilation
ended due to lack of space".
--------
Carlie Coats reported that the following was necessary on an
IBM AIX SP system for 64-bit mode:
ARFLAGS='-X 64 cru'
NMFLAGS='-X 64'
--------
Alan Dawes reports the following is necessary to enable large
file support on AIX 32-bit architectures:
CFLAGS='-D_LARGE_FILES -O -qmaxmem=-1'
CXXFLAGS='-D_LARGE_FILES -O -qmaxmem=-1'
NMFLAGS='-X32'
ARFLAGS='-X32 cru'
FC='xlf -q32'
CC='xlc -q32'
CXX='xlC -q32'
OBJECT_MODE='32'
and the following works for AIX 64-bit architectures:
CFLAGS='-D_LARGE_FILES -O -qmaxmem=-1'
CXXFLAGS='-D_LARGE_FILES -O -qmaxmem=-1'
NMFLAGS='-X64'
ARFLAGS='-X64 cru'
FC='xlf -q64'
CC='xlc -q64'
CXX='xlC -q64'
OBJECT_MODE='64'
HP-UX robin B.11.00 E 9000/715 2010262449
No Fortran90 compiler was available for testing.
CC=/bin/c89
CPPFLAGS=-D_HPUX_SOURCE
FC=/opt/fortran/bin/fort77
FFLAGS=-w
FLIBS=-lU77 # needed to obtain getarg_
CXX=/bin/CC
--------
CC=/bin/c89
CPPFLAGS='-D_HPUX_SOURCE -DNDEBUG -w'
CFLAGS=-O
FC=/opt/fortran/bin/fort77 # might be /usr/bin/fort77 instead
FFLAGS='-O2 -w' # "-O3" causes ncgen test to fail
FLIBS=-lU77 # needed to obtain getarg_
CXX=/usr/bin/CC
CXXFLAGS=-O
The above resulted in ignorable errors involving "Redefinition
of macro FD_ISSET."
--------
CC=/bin/cc
CFLAGS=-D_FILE_OFFSET_BITS=64 # for Large File Support
FC=/opt/fortran/bin/fort77
FFLAGS=-w
FLIBS=-lU77
HP-UX tweety B.11.00 E 9000/785 2004553471 8-user license
A Fortran90 compiler was used to build the Fortran-77 interface
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
IRIX chevy 6.5 01101244 IP22
IRIX64 flip 6.5 10120105 IP30
IRIX f90 Note: On IRIX 6.x platforms with version 7 compilers,
the f90 compiler accepts 'integer*1', while f77 accepts both
'integer*1' and 'byte'. Using FC=f90 forces the
configure script to select 'integer*1'. The
resulting *.inc files and test configurations will then work
with either compiler.
CC=/bin/c89
FC=/bin/f90 # builds both f77 and f90 interfaces
CXX=/bin/CC
CXXFLAGS=-LANG:std # only needed for netcdf 3.5.1 and later
--------
CC=/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC=/bin/f90 # f77 also works
FFLAGS=-O
F90=/bin/f90
F90FLAGS=-O
CXX=/bin/CC
CXXFLAGS=-O
--------
CC=/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS='-O -o32'
FC=/bin/f77
FFLAGS='-O -o32 -nocpp'
CXX=/bin/CC
CXXFLAGS='-O -o32'
FPP='/bin/cc -E'
--------
CC=/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS='-O -n32'
FC=/bin/f90
FFLAGS='-O -n32'
CXX=/bin/CC
CXXFLAGS='-O -n32'
--------
# requires IRIX64
CC='/bin/cc -64'
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC='/bin/f90 -64'
FFLAGS=-O
F90='/bin/f90 -64'
CXX='/bin/CC -64'
CXXFLAGS=-O
Linux imogene 2.2.16-22enterprise #1 SMP EDT 2000 i686 unknown
CC=/usr/bin/egcs
CPPFLAGS=-Df2cFortran
FC=/usr/bin/g77
FFLAGS=-Wno-globals
CXX=/usr/bin/g++
--------
CC=/usr/bin/egcs
CPPFLAGS='-DNDEBUG -Df2cFortran'
CFLAGS=-O
FC=/usr/bin/g77
FFLAGS='-O -Wno-globals'
CXX=/usr/bin/g++
--------
CC=/usr/bin/egcs
CPPFLAGS='-DNDEBUG -Df2cFortran'
CFLAGS=-O
FC=/opt/bin/fort77 # uses f2c
FFLAGS='-O -Nx400 -w' # "-Nx400" permits many EXTERNAL statements
CXX=/usr/bin/g++
--------
CC=/usr/bin/gcc
CPPFLAGS='-DNDEBUG -DpgiFortran'
CFLAGS=-O
FC=/opt/pgi/linux86/bin/pgf90
FFLAGS='-O -w'
CXX=/usr/bin/g++
--------
The following is reported to work with more recent versions of Linux
CC=/usr/bin/c99
CPPFLAGS=-Df2cFortran
FC=/usr/bin/g77
FFLAGS=-Wno-globals
CXX=/usr/bin/g++
--------
To use the Intel IFC Fortran compiler, see these notes.
--------
Linux sunshine 2.4.2-2smp #1 SMP Sun Apr 8 20:21:34 EDT 2001 i686 unknown
An example of building netCDF with large file support
CC=/usr/bin/gcc
CFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'
Linux aqua 2.2.5-16 #1 Tue Apr 27 04:55:03 EDT 1999 alpha unknown
The following was reported to work on an Alpha Linux workstation:
CC=ccc # Compaq C compiler
CPPFLAGS='-DNDEBUG -Df2cFortran'
FC=fort # Compaq Fort F77/F90 Compiler
F90=fort
CXX=/usr/bin/c++
Darwin Kernel Version 1.4 (Mac OS X 10.1 with Developer Tools)
No Fortran 90 compiler was available for testing.
If no Fortran interface is required:
CC=/usr/bin/cc
CXX=/usr/bin/c++
FC=''
--------
After installing g77:
CC=/usr/bin/cc
CPPFLAGS=-Df2cFortran
FC=/usr/bin/g77
FFLAGS=-w
--------
After installing f2c:
CC=/usr/bin/cc
CPPFLAGS=-Df2cFortran
FC=/sw/bin/fort77
FFLAGS='-w -Nx400'
OSF1 dana V5.1 1885 alpha
NB: Use of "g++" in the following might require that the
LD_LIBRARY_PATH environment variable be set to reference the
directory that contains the "g++" sharable library, e.g.
export LD_LIBRARY_PATH=/opt/gnu/lib
NB: The -ieee flag is needed if the library may read subnormal
floats in netCDF files generated on other platforms. For more
details,
see Floating exceptions reading IEEE subnormal floats on Alpha.
CC=/bin/c89
CFLAGS=-ieee # force IEEE compliance in handling subnormal floats
FC=/bin/f77
F90=/bin/f90
CXX=g++
--------
CC=/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS='-O -ieee' # force IEEE compliance in handling subnormal floats
FC=/bin/f77
FFLAGS=-O
F90=/bin/f90
CXX=g++
CXXFLAGS=-O
SunOS 5.7 sun4u sparc SUNW,Ultra-2
SunOS 5.8 sun4u sparc SUNW,Ultra-2
SunOS 5.8 i86pc i386
Note: PATH should contain /usr/ccs/bin to find make, nm, ar, etc.
CC=/opt/SUNWspro/bin/c89 # also works with cc
FC=/opt/SUNWspro/bin/f90 # also works with f77
FFLAGS=-w # disables an ignorable warning
CXX=/opt/SUNWspro/bin/CC
--------
CC=/opt/SUNWspro/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC=/opt/SUNWspro/bin/f77
FFLAGS='-O -w'
F90=/opt/SUNWspro/bin/f90
F90FLAGS='-O -w'
CXX=/opt/SUNWspro/bin/CC
CXXFLAGS=-O
--------
CC=/opt/SUNWspro/bin/c89
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC=/opt/SUNWspro/bin/f90
FFLAGS='-O2 -w' # "-O" causes "ncgen -f" test to fail
CXX=/opt/SUNWspro/bin/CC
CXXFLAGS=-O
--------
CC=/opt/SUNWspro/bin/c89
CFLAGS='-xarch=v9' # 64-bit SPARC binary
FC=/opt/SUNWspro/bin/f90
FFLAGS='-w -xarch=v9'
CXX=/opt/SUNWspro/bin/CC
CXXFLAGS='-xarch=v9'
--------
CC=gcc
CPPFLAGS=-Df2cFortran # necessary for Fortran API
FC=g77
F90=''
CXX=g++
SunOS gummo 4.1.4 11 sun4m
No Fortran 90 compiler was available for testing.
CC=/usr/lang/acc
FC=/usr/lang/f77
FFLAGS=-w
CXX=/usr/lang/CC
--------
CC=/usr/lang/acc
CPPFLAGS=-DNDEBUG
CFLAGS=-O
FC=/usr/lang/f77
FFLAGS='-O -w'
CXX=/usr/lang/CC
CXXFLAGS=-O
--------
CC=gcc
CPPFLAGS='-DNDEBUG -D__USE_FIXED_PROTOTYPES__'
CFLAGS=-O
FC=/usr/lang/f77
FFLAGS='-O -w'
CXX=g++
LIBS='-L/usr/lang/SC3.0.1/lib -lansi' # To obtain memmove().
UNICOS
Before executing make, manually copy the file
"libsrc/ncx_cray.c" to file "libsrc/ncx.c". See the
commentary at the top of this file for more information.
CC=/opt/ctl/bin/cc
CPPFLAGS=
CFLAGS=-O3 # -g works as well
FC=/opt/ctl/bin/f90
FFLAGS='-g -F -dp' # "-F" enables macro substitution in code.
# "-dp" enables DOUBLEPRECISION/double
# equivalence.
CXX=/opt/ctl/bin/CC
CXXFLAGS= # "-h char" may be necessary with older C++
F90='' # Fortran-90 interface will be fixed in 3.5.1
The configure and build system should work on any system which has a modern
"sh" shell, "make", and so on. The configure and build system is less portable
than the "C" code itself, however. You may run into problems with the "include"
syntax in the Makefiles. You can use GNU make to overcome this, or simply manually
include the specified files after running configure.
If you can't run the configure script, you will need to create
libsrc/ncconfig.h and fortran/nfconfig.inc. Start with libsrc/ncconfig.in and
fortran/nfconfig.in and set the defines as appropriate for your system.
Operating system dependency is isolated in the "ncio" module. We provide two versions. posixio.c uses POSIX system calls like "open()", "read()" and "write(). ffio.c uses a special library available on CRAY systems. You could create other versions for different operating systems. The program "t_ncio.c" can be used as a simple test of this layer.
Numerical representation dependency is isolated in the "ncx" module. As supplied, ncx.m4 (ncx.c) supports IEEE floating point representation, VAX floating point, and CRAY floating point. BIG_ENDIAN vs LITTLE_ENDIAN is handled, as well as various sizes of "int", "short", and "long". We assume, however, that a "char" is eight bits.
There is a separate implementation of the ncx interface available as ncx_cray.c which contains optimizations for CRAY vector architectures. Move the generic ncx.c out of the way and rename ncx_cray.c to ncx.c to use this module. By default, this module does not use the IEG2CRAY and CRAY2IEG library calls. When compiled with aggressive inlining and optimization, it provides equivalent functionality with comparable speed and clearer error semantics. If you wish to use the IEG library functions, compile this module with -DUSE_IEG.
If you don't know what environment variables are or how to set them, then read this section; otherwise, you may safely skip it.
An environment variable is a named parameter that is managed by a user's
shell program and which the shell makes available to the utilities that
it executes (for example, a configure script). The following are examples of
typical environment variables:
NAME EXAMPLE VALUE
---- -------------
USER steve
HOME /home/steve
PATH /bin:/usr/bin:/home/steve/bin
You may obtain a listing of your environment variables by executing the command "env".
The way in which an environment variable is defined and set depends upon the shell the user is using. A user of a csh-like shell (e.g. csh, tcsh) might do the following:
% setenv CC c89
% setenv CPPFLAGS "-O -DNDEBUG"
whereas, the user of the standard UNIX shell (e.g. sh, ksh, bash) might,
equivalently, do the following:
$ export CC=c89
$ export CPPFLAGS="-O -DNDEBUG"
In both cases, the quotes above are necessary to delimit a value that
contains embedded whitespace. They do not, however, become part of
the value.
A user of a standard shell has an additional, shorthand method for defining and setting environment variables for just a single command. Environment variables can be defined and set on the command-line and take effect for only that command. For example
$ export FOO=foo
$ env | grep FOO
FOO=foo
$ FOO=bar env | grep FOO
FOO=bar
$ env | grep FOO
FOO=foo
For tested systems, environment variables and their values are given as if listed by the "env" utility. Users of the standard UNIX shell may use the syntax directly; whereas, users of a csh-like shell should convert the syntax to that expected by the shell. For example, a standard shell user might do the following (taken from the SunOS 5.6 example):
$ CC=/opt/SUNWspro/bin/c89 CPPFLAGS=-DNDEBUG CFLAGS=-O \
FC=/opt/SUNWspro/bin/f77 FFLAGS="-O -erroff=WDECL_LOCAL_NOTUSED" \
CXX=/opt/SUNWspro/bin/CC ./configure >configure.log 2>&1
whereas a csh-like shell user would, equivalently, do the following:
% setenv CC /opt/SUNWspro/bin/c89
% setenv CPPFLAGS "-DNDEBUG"
% setenv CFLAGS -O
% setenv FC /opt/SUNWspro/bin/f77
% setenv FFLAGS "-O -erroff=WDECL_LOCAL_NOTUSED"
% setenv CXX /opt/SUNWspro/bin/CC
% ./configure >&! configure.log
More information on environment variables can be found in the manual page for your shell (e.g. "man csh", "man ksh").
You may also want to try the latest beta release of netCDF, which already has fixes for some problems, including updates to the C++ interface for more recent C++ compilers.
If you still have a problem with the installation and wish to report it, then please do the following:
configure script. Redirect its standard output
and standard error to the file "configure.log". If this step fails -- which
is indicated by error messages (not warnings) in "configure.log" (not "config.log")
-- then stop and send items A through F below to <support@unidata.ucar.edu>.The following items help us diagnose installation problems.
configure script during step 6 above.configure script
during step 6 above.