Other Builds of the netCDF Package

This is where we document some reported builds of recent releases in environments that we did not or could not try.

Version 3.6.1-beta2 (January 2005)

Version 3.6.0 (December 2004) and 3.6.0-p1 (February 2005)

Version 3.6.0-beta6 (October 2004)

Version 3.5.1 (February 2004)

Version 3.5.1-beta13 (August 2003)

Version 3.5.1-beta12 (August 2003)

Version 3.5.1-beta10 (December 2002)

Version 3.5.0 (March 2001)

Version 3.5beta (February 2001)

Version 3.4 (March 1998)

Version 3.3.1 (June 1997)


HPUX with NagWare f95 compiler

Axel von Engeln reports that the followin settings were necessary to compile netCDF on HPUX with NAG fortran:

CC=cc CPPFLAGS="-DNDEBUG -DNAGf90Fortran" CFLAGS="-O3" CXXFLAGS="" \
   FC=f95 FFLAGS="-O3 -dusty  -DNAGf90Fortran -ieee=full" \
   FLIBS='' configure --prefix=yourdirhere



Compiling CXX API on Irix with MIPSpro compiler

Atro Tossavainen reports that CXXFLAGS="-LANG:std" is required for version 7.3 of the MIPSpro CC compiler (for the C++ API).



Xeon Multithreaded processor, using CentOS, and Intel Fortran

User Gregory C Smith reports:

We want to report successful compilation of Netcdf 3.6.0-p1 libraries
on a Xeon Multithreaded processor, using CentOS, and Intel Fortran
Compiler 9.0, 64bits. The environment variables are:

FC=ifort
F90=ifort
CC=gcc
CXX=g++
FFLAGS="-O"
CPPFLAGS="-DNDEBUG -DpgiFortran"



Building with Lahey Fortran 4.50i on Windows

Evan Twombly suggests the following for building with Lahey Fortran:


Caveat: I am compiling with version 4.50i.  This may work differently
with newer versions.

I access the netCDF DLL Library.  I did not access the NF90
subroutines, I went directly to the NF_ routines.  Here are the key
issues you need to know:

1) The netCDF library is compiled with UPPER CASE routines, or at
least that is how it appears to the Lahey Library Manager. Lahey
Fortran defaults to converting everything to lower case. So you need
to turn on the flag that requires the compilation of code to respect
the case of what you have typed.  Warning: this means your routines
and variables are case sensitive!  ie -twocase in your local lf90.fig
file or on the command line.

2) You need to compile the program as a windows program, even if you
are not using any windows code to access DLLs.  To see your screen
output, you need to put a pause at the end of the program so the DOS
window that opens does not close at the end of the run.  ie -win in
your local lf90.fig file or on the command line

3) When you refer to a netCDF DLL Routine, you need to identify it as
DLL with the DLL_IMPORT line or you can add the DLL_IMPORT lines to
the netcdf.inc file.

4) Whenever a character string is sent to an NF_ routine you must send
an array of bytes and the string length.  The string length should be
send as a number, NOT a pointer. This is done using Lahey's carg
extension. (C Argument) The string you are sending should be NULL
terminated.  Strings you recieve should have the NULL character
removed.

     ie To SEND a name to an NF Routine

     include 'netcdf.inc'
     CHARACTER(*)       :: cName
     CHARACTER(MAXCHAR) :: cString
     INTEGER(1)         :: iString(MAXCHAR)
     CHARACTER(7)       :: cMaxChar='(128a1)'
     DLL_IMPORT         :: NF_INQ_VARID
     ...
     cString=trim(cName)//char(0)
     read(cString,cMaxChar)iString
     iStatus = NF_INQ_VARID(lu_netCDF, iString, carg(MaxChar), iVarID)

     ie To GET a name from an NF Routine

     include 'netcdf.inc'
     CHARACTER(*)       :: cName
     CHARACTER(MAXCHAR) :: cString
     INTEGER(1)         :: iString(MAXCHAR)
     CHARACTER(7)       :: cMaxChar='(128a1)'
     DLL_IMPORT         :: NF_INQ_DIM
     ...
     iStatus = NF_INQ_DIM(lu_netCDF, iDimNumber, iString,
     carg(MaxChar),
iDimLength)
     do i=1,MaxChar
       if(iString(i)>0)cycle
       iString(i:)=32
     enddo
     write(cString,cMaxChar)iString
     cName=cString

I had a very limited need for access to the DLL so I did what was
described above.
What might work in general is
  1) convert all of the src/f90 subdirectory files to upper case
  2) convert all of netcdf.inc to upper case
  3) make a copy of netcdf_externals.f90 and change INTEGER,EXTERNAL
     to DLL_IMPORT and add this to netcdf.inc
  4)  ... (change the CHARACTER(LEN=80),EXTERNAL to DLL_IMPORT also)
      Then try compiling that along with the flags -win and -twocase

Option:
  If you JUST change the NF_ routines to upper case above and leave
everything else lower case, then compile an interface module using the
-twocase flag, you may be able to remove it for all other programming.



Compiling with gfortran

Magnus Hagdorn reports success compiling and runnig the tests of netCDF 3.6.0-p1 on

uname -a
Linux gargel 2.6.10-5-k7 #1 Tue Jun 7 10:08:19 UTC 2005 i686 GNU/Linux
with the gfortran compiler from gcc version 4.1.0 20050624 (experimental) by setting the following flags:
F90FLAGS=-ff2c 
FFLAGS=-ff2c



NEC SX architectures, including the Earth Simulator

Takashi Kagimoto of the Frontier Research Center for Global Change/JAMSTEC has contributed a patch of netcdf-3.6.0-p1 for the NEC SX series that includes changes to optimally vectorize type transformations on NEC SX architectures. Here are his notes on using the patch:

  I attached a patch file in order to make it feasible
to easily build netCDF library on NEC SX architectures
(SX-4,5,6,7 or 8) including the Earth Simulator (ES). 
What I changed from the original is as follows,

  (1) config.guess supports SX-7, -8 and ES architecture
    (but I checked only on SX-5, -8 and ES),
  (2) LINK.F, LINK.f and LINK.F90 macros in macros.make
    is determined in configure script so that an appropriate
    link process is done if c++ compiler is used for 
    compilation of C language source code on NEC 
    architectures (as you may know, c++ must be used for
    linking object and library in that case),
  (3) typeSizes.f90 and netcdf_overloads.f90 have cpp
    switches to plug-off unnecessary parts on NEC machines,
  (4) test carried out in ncgen directory allows a trivial
    failure associated with precision of floating point
    values

Additionally I changed libsrc/ncx.m4 in such a way that
type transformation routines are optimally vectorized
on NEC SX architectures. Originally this modification is
proposed by a person working in Max-Planck Institute.
He has vectorized only put and get routines for float to 
double and double to float transformations. I applied the
same modification to any variable types such as

    int            int
    long           long
    float   <--->  float
    double         double

all of which are objects for the vectorization. This modification
can be used if you build netcdf library on SX (if defined
_SX macro), thus it does not affect installation of the
netCDF library on other architectures at all.

  How I buit the netCDF on NEC architectures is as follows,

[SX-5]
  % setenv CC cc
  % setenv FC 'f90 -dW'
  % setenv F90 'f90 -dW'
  % setenv TEMP_LARGE /work
  % cd netcdf-3.6.0-p1/src
  % patch -p0 < netcdf-3.6.0-p1-NEC-patch
  % ./configure
  % make
  % make test
  % make extra_test
  % make install

[SX-8]
  % setenv CC c++
  % setenv FC 'f90 -dW'
  % setenv F90 'f90 -dW'
  % setenv TEMP_LARGE /work
  % cd netcdf-3.6.0-p1/src
  % patch -p0 < netcdf-3.6.0-p1-NEC-patch
  % ./configure
  % make
  % make test
  % make extra_test
  % make install

[ES]
  % setenv CC 'cc -D_SX'
  % setenv FC 'f90 -dW -D__SX__'
  % setenv F90 'f90 -dW  -D__SX__'
  % setenv TEMP_LARGE /work
  % cd netcdf-3.6.0-p1/src
  % patch -p0 < netcdf-3.6.0-p1-NEC-patch
  % ./configure
  % make
  % make test
  % make extra_test
  % make install



netcdf.dll and Visual Basic V6

Carsten Wieczorrek developed code in VB 6 to export chromatographic data into the netcdf/ANDI format. The application writes netCDF files that can be read by CHROMELEON, for example. For others interested in programming with netcdf.dll from VB 6, see Wieczorrek's web page on netcdf.dll and Visual Basic V6.



OpenVMS Alpha for netCDF 3.6.1-beta2

Jouk Jansen compiled and tested NetCDF 3.6.1-beta2 sucessfully on an OpenVMS Alpha system. Details are available at http://nchrem.tnw.tudelft.nl/openvms/software2.html#NETCDF. The C++ interface was not built since the current C++ compiler for OpenVMS does not support the required namespace syntax.



Linux x86 with Intel ifort 8.1 fortran compiler

See the successful build output for an example of building and passing tests with the ifort compiler.

Contributed by Arnaud Desitter.

env \
 FC="ifort" \
 FFLAGS="-g -O2 -mp -recursive"\
 CPPFLAGS="-DNDEBUG -DpgiFortran" \
 CC=gcc \
 CXX=g++ \
 CFLAGS="-g -O2 -march=pentium3" \
 ./configure --prefix=/path/to/installdir

Richard P. Signell reports that the environment settings above did not work for him, but these did:

export FC=ifort
export F90=ifort
export FFLAGS="-O -mp"
export CPPFLAGS="-DNDEBUG -DpgiFortran"

Linux x86 with Intel ifc 7.1 fortran compiler

Contributed by Arnaud Desitter.

env \
 FC="ifc" \
 FFLAGS="-g -O -mp -w" \
 FLIBS="-Vaxlib" \
 CPPFLAGS="-DNDEBUG -DpgiFortran" \
 CC=gcc \
 CXX=g++ \
 CFLAGS="-g -O2 -march=pentium3" \
 ./configure --prefix=/path/to/installdir


Linux x86 with NagWare f95 5.0 compiler

Contributed by Arnaud Desitter.

env \
 FC="f95" \
 FFLAGS="-g -mismatch -w=unused -DNAGf90Fortran -ieee=full"\
 CPPFLAGS="-DNDEBUG -DNAGf90Fortran" \
 CC=gcc \
 CXX=g++ \
 CFLAGS="-O2 -march=pentium3 -g" \
 ./configure --prefix=/path/to/installdir


SGI Altix (Itanium2) using Intel compilers

Len Makin determined a combination of environment variable settings that works with SGI Altix (Itanium2) running redhat-release-3AS-2 Linux 2.4.21-sgi303r2 using Intel compilers:

env CPPFLAGS="-DNDEBUG -DpgiFortran" \
CC=icc \
CFLAGS="-O -mp" \
CXX=icpc \
CXXFLAGS="-O -mp -cxxlib-gcc" \
FC=ifort \
FFLAGS="-O -mp -integer_size 32 -real_size 32 -double_size 64" \
./configure

Gerardo Cisneros contributed a different way of supporting Intel compilers for SGI Altix systems. It uses this patch to src/fortran/cfortran.h to add configuration for the Intel compilers. After applying the patch, set the following environment variables before running './configure':

CC=icc
FC=ifort
CXX=icc
CFLAGS='-g -O2 -w'
CXXFLAGS='-g -O2'
FFLAGS='-g -O2 -mp -w'
F90FLAGS='-g -O2 -mp -w'
This was tested with ifort 9.0.015 and icc 9.0.016 compilers, but these settings should also work with the 8.1.x compilers.


g95 Fortran on x86 Linux

Reported by Charlie Zender:

The following switches work for to build netCDF 3.6+ on x86 with the
g95 
fortran compiler:

export CC='gcc'
export CXX='g++'
export CPPFLAGS='-DNDEBUG -DpgiFortran'
export CFLAGS='-O -g'
export FC='g95'
export F90='g95'
export FFLAGS='-O -g -fno-second-underscore'
export F90FLAGS='-O -g -fno-second-underscore'

while the following switches work for me on x86_64:

export CC='gcc'
export CXX='g++'
export CPPFLAGS='-DNDEBUG -DpgiFortran'
export CFLAGS='-O -fPIC -m64'
export FC='g95'
export F90='g95'
export FFLAGS='-O -g -fno-second-underscore'
export F90FLAGS='-O -g -fno-second-underscore'


Absoft Fortran on Mac OS X

For this to work, you must use the 3.6.1 beta release (3.6.1-beta2 or later). With that release, the following works:

env CPPFLAGS="-DAbsoftProFortran" \
	FLIBS="-lU77" \
	 ./configure

John Tanski has provided an alternative script for compiling the netCDF source distribution with Absoft 9.2 running under Tiger (10.4.2). He notes:

One caveat is that the flags used in script must be used in compiling programs accessing the library, especially NOT having the -YEXT_NAMES and -YEXT_SFX options present. Also, I've compilied on a Dual G5 so I could get the 64-bit form of the library. Hope this provides some guidance for others.


Pathscale compiler recommendation from vendor

Didier Cabannes recommends the following configuration for building netCDF for Pathscale compilers:

  export CC=pathcc
  export FC=pathf90 
  export F90=pathf90
  export CXX=pathCC
  export CFLAGS=-Df2cFortran
  ./configure --prefix=/home/ssp/netcdf_path
  make
  make test
  make install

Pathscale compilers on Beowulf cluster

John Evans determined a combination of environment variable settings that works with Pathscale compilers on a Beowulf cluster:

env CC=pathcc \
	CFLAGS="-DpgiFortran" \
	FC=pathf90 \
	FFLAGS="-cpp -DpgiFortran -fno-second-underscore" \
	F90FLAGS="-cpp -DpgiFortran -fno-second-underscore" \
	F90=pathf90 \
	CXX=pathCC \
	CXXFLAGS="-DpgiFortran" \
	 ./configure


Intel Fortran (ifort 8.1) on Linux x86

According to Arnaud Desitter,

env \
 FC="ifort" \
 FFLAGS="-g -O2 -mp -auto" \
 CPPFLAGS="-DNDEBUG -DpgiFortran" \
 CC=gcc \
 CFLAGS="-O2 -g" \
 ./configure --prefix=/path/to/install
("-mp" is necessary for "make check" to succeed, "-auto" is not necessary. It allocates local variables on the stack and makes checking more relevant as otherwise all arrays and strings are allocated statically)


NagWare f95 compiler on Linux x86

According to Arnaud Desitter,

env \
 FC="f95" \
 FFLAGS="-g -mismatch -w=unused -DNAGf90Fortran -ieee=full"\
 CPPFLAGS="-DNDEBUG -DNAGf90Fortran" \
 CC=gcc \
 CFLAGS="-O2 -g" \
 ./configure --prefix=/path/to/install
"-ieee=full" is necessary for "make check" to succeed. "-mismatch" is necessary to downgrade argument mismatches from error to warnings (mismatches are in fortran test suite and in f90 library).


MacOS X with IBM xlf Fortran

Craig Mattocks has contributed a Mac OS X install script for downloading, uncompressing, configuring, building, testing, and installing netCDF on a MacOS X system using the IBM xlf Fortran compiler.


PathScale compilers

Robert Walsh has contributed this patch for the fortran/cfortran.h file in the netCDF 3.5.1 release to make it work with the PathScale compilers. This patch will be incorporated into the 3.6.0 release, so that release should work with PathScale compilers "out of the box".


AMD Opteron Linux, PGI compiler

Dr. Constantinos Evangelinos reports the following settings successfully completed the bundled test for NetCDF 3.5.1 on an Opteron system with SuSE Enterprise Server 8, gcc 3.3.1 and PGI compiler V. 5.1-3:

64bit, PGI F77 & C++ compilers, GCC for C, (pgf90 will not work for F90):

 env CC=gcc CFLAGS="-O3 -funroll-loops -march=k8 -m64 -mfpmath=sse -msse2
 -ffast-math -mcmodel=medium" FC=pgf77 FFLAGS="-fastsse -tp k8-64 -Minline
 -Mvect=recog,transform,assoc,cachesize:1048576 -mcmodel=medium" CXX=pgCC
 CXXFLAGS="-fastsse -tp k8-64 -Minline
 -Mvect=recog,transform,assoc,cachesize:1048576 -mcmodel=medium"
 CPPFLAGS="-DNDEBUG -DpgiFortran -D_FILE_OFFSET_BITS=64
 -D_LARGEFILE_SOURCE" ./configure
This one works but the tests complain:
 ./nf_test: Symbol `exit' causes overflow in R_X86_64_PC32 relocation
 ./nf_test: Symbol `exit' causes overflow in R_X86_64_PC32 relocation
 ./ftest: Symbol `exit' causes overflow in R_X86_64_PC32 relocation
 ./ftest: Symbol `exit' causes overflow in R_X86_64_PC32 relocation
 ./nctst: Symbol `exit' causes overflow in R_X86_64_PC32 relocation
Compiling without -mcmodel=medium does away with these warnings (and should provide a small speedup) at the expense of available address space.

32bit, PGI F77 & C++ compilers, GCC for C, (pgf90 will not work for F90):

 env CC=gcc CFLAGS="-O2 -funroll-loops -march=k8 -m32 -mfpmath=sse -msse2
 -ffast-math" FC=pgf77 FFLAGS="-fastsse -tp k8-32 -Minline
 -Mvect=recog,transform,assoc,cachesize:1048576" CXX=pgCC
 CXXFLAGS="-fastsse -tp k8-32 -Minline
 -Mvect=recog,transform,assoc,cachesize:1048576" CPPFLAGS="-DNDEBUG
 -DpgiFortran -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" ./configure

64bit, all GCC, no F90:

 env CC=gcc CFLAGS="-O3 -funroll-loops -march=k8 -m64 -mfpmath=sse -msse2
 -ffast-math -mcmodel=medium" FC=g77 FFLAGS="-O3 -funroll-loops -march=k8
 -m64 -mfpmath=sse -msse2 -ffast-math -mcmodel=medium -Wno-globals" CXX=g++
 CXXFLAGS="-O3 -funroll-loops -march=k8 -m64 -mfpmath=sse -msse2
 -ffast-math -mcmodel=medium" CPPFLAGS="-DNDEBUG -Df2cFortran
 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" ./configure

32bit, all GCC, no F90:

 env CC=gcc CFLAGS="-O2 -funroll-loops -march=k8 -m32 -mfpmath=sse -msse2
 -ffast-math" FC=g77 FFLAGS="-O2 -funroll-loops -march=k8 -m32 -mfpmath=sse
 -msse2 -ffast-math -Wno-globals" CXX=g++ CXXFLAGS="-O2 -funroll-loops
 -march=k8 -m32 -mfpmath=sse -msse2 -ffast-math" CPPFLAGS="-DNDEBUG
 -Df2cFortran -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" ./configure


SuSE SLES 8 Opteron Linux, PathScale compiler

Marc Rieffel reports the following (slightly modified to conform to standard-shell syntax):

I've been able to build a working version of netcdf-3.5.1 with the PathScale compiler on a SuSE SLES 8 Opteron system using the following command. Note that the "-cpp -DpgiFortran" has to be in the FC definition, not just the FFLAGS definition. The FFLAGS definition isn't used everywhere these flags are needed.

CC='/opt/pathscale/bin/pathcc -DpgiFortran' \
FC='/opt/pathscale/bin/pathf90 -cpp -DpgiFortran -fno-second-underscore' \
F90='/opt/pathscale/bin/pathf90 -DpgiFortran -cpp -fno-second-underscore' \
CXX='/opt/pathscale/bin/pathCC -DpgiFortran' \
./configure
-- Marc Rieffel, Sr. Manager, R&D, Paracel

Intel ifc Fortran 95 compiler

Arnaud Desitter successfully built the netCDF package using the Intel Fortran-95 compiler, ifc. The environment variable settings were

FC=ifc
FLIBS=-Vaxlib
FFLAGS="-O -mp -cm -w95"
CPPFLAGS="-DNDEBUG -DpgiFortran"
CC=gcc
Arnaud's rationale for the Fortran compiler options is:
-O
Enable reasonable optimization.
-mp
Maintain floating point accuracy. Necessary so that "make test" succeed.
-cm -w95
Suppress all comment messages and messages about use of non standard Fortran. Useful for "make test".
-Vaxlib
Link with portability library. Avoids hardwiring the compiler location. Necessary for "make test".
-DpgiFortran
Portland Group compiler has the same default calling conventions.


32-bit Linux Opteron using ifort(1)

Christoph Arns successfully built a 32-bit netCDF package on an AMD Opteron system running Linux Fedora Core 1 using the ifort(1) compiler:

I would like to report a successfull build including make test for the
following platform:

AMD Opteron Fedora Linux, ifort compiler (32-bit installation):

setenv FC  ifort;
setenv F90 ifort;
setenv FLIBS -Vaxlib;
setenv FFLAGS "-O -mp -static-libcxa";
setenv CPPFLAGS "-DNDEBUG -DpgiFortran";
setenv CC gcc;
setenv CFLAGS "-O2 -funroll-loops -m32 -mfpmath=sse -msse2 -ffast-math";
setenv CXX g++;
setenv CXXFLAGS "-O2 -funroll-loops -m32 -mfpmath=sse -msse2 -ffast-math";
setenv FFLAGS "-O -mp -cm -w95 -static-libcxa -Wl,-m elf_i386";
setenv F90FLAGS "-O -mp -cm -w95 -static-libcxa -Wl,-m elf_i386";


Intel Fortran Compiler (ifc) 7.1

Hudson Souza reports that it was necessary to use the "-i_dynamic" option with version 7.1 of the Intel Fortran Compiler (ifc, build 20030307Z) for 32-bit applications in order for the netCDF package to pass its "make test" on an Linux (Redhat 9.0, kernel 2.4.20-8). The environment variable settings he used were:

FC=/usr/intel/compiler70/ia32/bin/ifc 
FLIBS=/usr/intel/compiler70/ia32/lib/libPEPCF90.a 
FFLAGS="-O -mp -cm -i_dynamic -dynamic-libcxa" 
CPPFLAGS="-DNDEBUG -DpgiFortran" 
CC=/usr/bin/gcc 


Intel Fortran Compiler (ifc) 8.0

Jeff Nucciarone reported a successful build and test of the netCDF package on an Itaium based Unisys ES7000 running Linux, kernel version 2.4.21-9.0.3.EL (Red Hat Linux 3.2.3-34) using the following settings:

FC=/usr/local/intel/intel_fc_80/bin/ifort
FFLAGS="-O -mp" 
CPPFLAGS="-DNDEBUG -DpgiFortran" 
CC=/usr/bin/gcc 


Using Intel ifort for f90 with g77

David Forrest reports the following environment variable settings work for building netCDF on Linux using Intel's ifort for the Fortran 90 compiler and g77 for the Fortran 77 compiler:

 CPPFLAGS='-DpgiFortran -DNDEBUG'
 FC=g77
 FFLAGS='-fno-second-underscore'
 F90='ifort'
 F90FLAGS='-Vaxlib -mp -static-libcxa'

The above works for a linux install using g77 to build the library and intel's ifort for building the f90 interface. 'make test' works fine, with or without the -mp.

Crossing fortran compilers is awkward -- the -fno-second-underscore is a big difference between the f2c type compilers like g77 and others, but it makes symbols that non-f2c fortran compilers understand.

In a mixed linux f2c / f90 environment, it might be useful to produce two libraries, one for the f2c type (nf_open__...) routines and one for the non-f2c routines (nf_open_).

An alternate solution would be to conditionally rewrite the f90 code to reference the double-underscored fortran routines similar to the .../fortran/ncfortran.h #if defined(f2cFortran) clause.

I was investigating this because I wanted to use the debian netcdf package, which seems to be missing the fortran interface.



OpenVMS Alpha

Jouk Jansen compiled and tested NetCDF 3.5.1 sucessfully on an OpenVMS Alpha system. Details are available at http://nchrem.tnw.tudelft.nl/openvms/software2.html#NETCDF. The C++ interface was not built since the current C++ compiler for OpenVMS does not support the required namespace syntax.


Linux 2.4 using g95

Tom Wainwright successfully built and tested the netCDF 3.5.1 package on an Intel Linux 2.4 (SuSE 8.2) system using the g95(1) Fortran compiler with the following environment variable settings:

export FC=g95
export F90=g95
export CPPFLAGS="-Df2cFortran"


MacOS X 10.2 and NAG f95

Eric Salathe was successful in building netcdf with all fortran 90 features on Macintosh OS X 10.2 using the NAG f95 compiler. make test runs successfully through all tests.

Here is what he did:

1) Define the variables:

setenv FC /usr/local/bin/f95
setenv FFLAGS "-O -dusty -w"
setenv F90 /usr/local/bin/f95
setenv FPP "/usr/local/bin/f95 -fpp"
setenv F90FLAGS "-O -w=unused -mismatch_all"
setenv CPPFLAGS "-DNAGf90Fortran"

2) Run configure <--prefix=installationd_directory>

3) OS X is case insensitive, which causes problems with .F files. To 
work around, modify the .F.o rule in the rules.make file. It should 
read like this:

# Not all FORTRAN compilers support C-preprocessing of *.F files; ergo, a
# relatively complicated rule ensues.
.F.o:
         @case "$(COMPILE.F)" in \
             '') \
                 set -x; \
                 cp $*.F $*.ff; \
                 $(FPP) $(FPPFLAGS) -c -O -dusty -w $*.ff ;      \
                 ;;      \
             *)  \
                 set -x; \
                 $(COMPILE.F) $<;        \
                 ;;      \
         esac

4) Add this line to the file nf_test.F in the directory nf_test, after 
the program nf_test statement:
   USE F90_UNIX_ENV, ONLY : IARGC,GETARG
(this will define iargc and getenv)

comment out this line:
    integer         iarg
(conflicts with f90_unix_env)

5) Make and make test

6) make install

7) manually copy src/f90/netcdf.mod src/f90/typesizes.mod to 
/usr/local/include, or wherever the installation is supposed to go.



FreeBSD 4.8

Rick Grubin successfully built the netCDF package using the following environment variable settings:

CC=gcc   # v3.3
FC=g77   # v3.3
CXX=g++  # v3.3
F90=""
CFLAGS=-O
FFLAGS=-O
CXXFLAGS=-O
CPPFLAGS=-Df2cFortran


Lahey Fortran 95 version 6 compiler

Gareth Williams reports that compiling with a CPPFLAGS environment variable that includes "-DNAGf90Fortran" works with the Lahey fortran compiler lf95 (version L6.00a) and netcdf-3.5.1-beta10. Presumably this will also work with later versions as well.



Intel ifc Fortran 95 compiler

Ayal Anis indicates that the following should work on systems running GENTOO Linux 1.4rc4 for 32-bit applications:

export FC=/opt/intel/compiler70/ia32/bin/ifc
export FLIBS="/opt/intel/compiler70/ia32/lib/libPEPCF90.a"
export FFLAGS="-O -mp -dynamic-libcxa" # -static-libcxa also works
export CPPFLAGS="-DNDEBUG -DpgiFortran"
export CC=gcc

This works because the Fortran-calling-C argument-passing conventions for the Intel Fortran compiler are, apparently, identical to those of the Portland Group Fortran compiler.

Alternatively, Carlie Coats has provided a patch to "src/fortran/cfortran.h" to make this work with the 3.5.0 release. After applying the patch, add the line

#define INTEL_COMPILER
to that file. Environment variable settings before running the configure script are:
FC=ifc
FLIBS="-L/usr/local/intel/compiler50/ia32/lib -lPEPCF90"
FFLAGS="-O -mp"
According to Andreas Manschke
The "-mp" option is for saying ifc should use default numerics and not optimized ones. Without that "make test" runs but detects some differences.

Enda O'Brien reports that the above changes

... apply equally well to the Intel efc compiler (for 64-bit Itanium systems), with just the following entirely predictable changes:
FC=efc
FLIBS="-L/usr/local/intel/compiler70/ia64/lib -lPEPCF90"
FFLAGS="-O -mp"
In particular, the changes to the src/fortran/cfortran.h file for ifc are identical for efc. By the way, I've done this with netcdf-3.5.0. I'm running Linux 2.4.18-e.12smp on a couple of dual-processor HP rx2600s.



AbSoft Fortran 90 compiler on MacOS X

According to Dierk Polzin, netCDF 3.5.0 compiles and passes its test suite with Absoft Pro Fortran 7.0 on MacOS X if you follow these steps. First, apply this patch to the src/fortran/cfortran.h file that comes with the netCDF 3.5.0 distribution:

  patch -c cfortran.h absoft90-macosx.patch
Next, set the environment variables as follows before running the configure script that comes with the distribution:
FC=/Applications/absoft/bin/f90
FFLAGS="-w -YEXT_NAMES=LCS -YEXT_SFX=_ -YCFRL=1"
F90=/Applications/absoft/bin/f90
F90FLAGS="-w -YEXT_NAMES=LCS -YEXT_SFX=_ -YCFRL=1"
FLIBS=-lU77
CPPFLAGS="-DAbsoftProFortran"
CFLAGS=

WARNING: The above will cause the Fortran-callable routines in the netCDF library to be in lower-case symbols with trailing underscores; consequently, all packages that use the netCDF library will also have to be compiled using the options "-YEXT_NAMES=LCS -YEXT_SFX=_".



AbSoft Fortran 90 compiler on Linux

We received the following email from Bill McKie on installing the netCDF package on a Linux system using the AbSoft Fortran-90 compiler:
From: Bill McKie <mckie@sky.arc.nasa.gov> 
Subject: netcdf v3.5.0 build notes for RH Linux & Absoft f90
Organization: NASA/Ames

Hi 

I recently picked up netcdf v3.5.0 for use on a Redhat Linux v6.1
system with the AbSoft ProFortran v6 f90 compiler.

It is working ok.  But as with builds of previous versions of netcdf,
I had to do a few manual customizations in the build process in order
for it to install on the above system.  I thought you might like to have
my notes for possible use in helping others with a similar system.

A summary of the steps I used follows.

Thanks for continuing to develop and provide the netcdf package,

Bill McKie
NASA Ames


 Unpack the distribution tarball as usual.

 Ensure the AbSoft f90 compiler is in the PATH environment variable.

 Set the environment variables:
   CC gcc
   FC "f90"
   F90 "f90"
   CXX ""
   CFLAGS ""
   FFLAGS ""
   F90FLAGS ""
   CXXFLAGS ""

 cd .../netcdf-3.5.0/src

 ./configure --prefix=directory_path_to_install_into

 cd fortran

 Edit cfortran and add following line near top

  #define AbsoftProFortran

 cd .../netcdf-3.5.0/src
 make

 Don't do "make test", since it will fail at some link
 steps with unsatisfied external references to command
 line argument routines iargc and getarg.

 cd .../netcdf-3.5.0/src
 Edit macros.make and change the line:
  NETCDF.MOD = netcdf.mod
 to:
  NETCDF.MOD = NETCDF.mod

 make install



Portland Group's pgf90 compiler on Linux

Subsequent to the release of version 3.5.0 of the netCDF package, we successfully built the package on an in-house Linux system using the Fortran-90 compiler from Portland Group. The type of system was

$ uname -a
Linux sunshine 2.4.2-2smp #1 SMP Sun Apr 8 20:21:34 EDT 2001 i686 unknown
The environment variable settings were
CC=/usr/bin/gcc
CPPFLAGS='-DNDEBUG -DpgiFortran'
CFLAGS=-O
FC=/opt/pgi/linux86/bin/pgf90
FFLAGS="-O -w"
CXX=/usr/bin/g++

This information will be in the next release as an example.



HP-UX B.11.11 9000/800 using /opt/fortran90/bin/f90

According to a user, the following settings should work. Please report if they don't.

CPP=/usr/bin/cc -E
CPPFLAGS=
CC=/usr/bin/cc
CXX=
FC=/opt/fortran90/bin/f90
FFLAGS=
F90FLAGS=
F90LIBS=

Since releasing this version, we've managed to build it in 64-bit mode using the following settings:

CC=/bin/cc
CPPFLAGS='-D_HPUX_SOURCE -D_FILE_OFFSET_BITS=64'    # large file support
                              # might work without it
CFLAGS=+DD64                  # 64-bit mode
FC=/opt/fortran90/bin/f90     # Fortran-90 compiler
FFLAGS='-w +DA2.0W +noppu'    # 64-bit mode, no "_" suffixes
FLIBS=-lU77
CXX=                          # C++ doesn't support 64-bit mode


HP-UX ia64 (Itanium 2) using f90

Charles F. Fisher of the University of Kentucky has successfully built the netCDF 3.5.0 package on an HP-UX ia64 (Itanium 2) system using the following settings:

32-bit installation

CC=cc
CPPFLAGS="-D_HPUX_SOURCE -D_FILE_OFFSET_BITS=64 -Dextname"
FC=f90
FFLAGS=-w
FLIBS=-lU77
CXX=aCC

64-bit installation

CC=cc
CPPFLAGS="-D_HPUX_SOURCE -D_FILE_OFFSET_BITS=64 -Dextname"
FC=f90
FFLAGS="-w +DD64"
FLIBS=-lU77
CXX=aCC
CXXFLAGS=+DD64


NEC-SX5 with SUPER-UX

Anne Fouilloux has provided the following changes needed to compile and install netcdf-3.5.0 on a NEC-SX5 platform:

For the installation of netcdf-3.5 on a NEC-SX5 machine (SUPER-UX
Release 11.1 SX-5), we did the following changes in the code :

- Configuration file "configure" : the Fortran compilation was made
  with the flag -dW i.e. FFLAGS=${FFLAGS--dW}

- C++ compilation :

    * ncvalues.h : we replace the occurrence of <strstream.h> by
      <strstream> 

    * netcdfcpp.h : we replace the 3 occurrences of

        friend NcFile;

      with

        friend class NcFile;

    * ncvalues.cpp : we replace the 2 occurrences of the statement

        long save=os.flags();

      with

        ostream::fmtflags save=os.flags();

- Fortran-90 compilation :

    * typeSizes.f90 : we replace the occurrence of

        EightByteInt = selected_int_kind(18)

      with

        EightByteInt = selected_int_kind(10)

      and we modified the line 55 :

        if (bit_size( One) == 8 .and. bit_size( Two) == 16 .and. &

      with

        if (bit_size( One) == 16 .and. bit_size( Two) == 16 .and. &

      (we could have remove "bit_size(One)" but we prefered to
      keep the general structure of the code)

    * netcdf_overloads.f90 : functions with a name containing
      OneByteInt were removed since integers of this size do not
      exist on a NEC-SX5. 

With these modifications, netcdf-3.5 was successfully installed on our
NEC-SX5.


Cray SV1

Guntram Seiß of the Bundesanstalt für Wasserbau Dienststelle (Federal Institute for Waterway Engineering) in Hamburg has made a binary version of the netCDF 3.5.0 library and utilities available for Unicos 10.0.0.6 on the Cray SV1. The library includes C, Fortran77, and Fortran90 interfaces. The binary distribution and files that were modified to create it are available from ftp://ftp.unidata.ucar.edu/pub/binary/cray_sv1/.



Interix on Windows XP Pro

Leigh Holcombe reports success in building netCDF 3.5.0 under Interix on Windows XP Pro:

OS: Interix via Windows XP Pro

environment variables:
% setenv CC /usr/contrib/bin/gcc
% setenv CXX
% setenv FC
% setenv F90
(since no fortran or C++ compiler was available)

potential issues:
*using WinZip to untar the archive is a bad idea.  

*failing to set the CC variable will result in a
successful configure but a failed make, because the
code defaults to c89 as its compiler, which on this
system is simply a reference to the MSVisualC++
compiler, which it won't find unless it is installed
locally.  gcc works just fine.

*using these same variables, I have had successful
builds with both versions 3.5.0 and 3.4.0.

*GMT users will want to add the following line to
their
/usr/etc/csh.lcl file:
% setenv NETCDFHOME /usr/local/netcdf-3.5.0
leave the csh.login and csh.cshrc files alone!  they
reference the csh.lcl file.


Borland Delphi on Windows

Sandy Ballard of Sandia National Laboratories has contributed a file of Delphi declarations for netCDF.



Lahey Fortran 95 compiler on Linux

Dirk Slawinski has made information about this port available from http://www.per.marine.csiro.au/staff/Dirk.Slawinski/cwr_web/work/netcdfinfo.html.



Lahey Fortran 95 compiler on Windows NT

Dirk Slawinski has ported netCDF to this platform and made information about the port available from http://www.per.marine.csiro.au/staff/Dirk.Slawinski/cwr_web/work/netcdfinfo.html#WinNT.



BeOS

Jeff Wong has ported netCDF to BeOS. More information about the port is available from http://www.bebits.com/app/1397.



UNICOS

sn9607 (UNICOS) ouray 10.0.0 and.2 CRAY J90
        Cray Standard C Version 6.0.1.3 03/04/98 14:55:01
        Cray CF90 Version 3.0.1.3 03/04/98 14:55:17
        Cray C++ Version 3.0.1.3 03/04/98 15:13:33
Fri Mar  6 14:37:42 MST 1998

    The "-F" option in the following causes the Fortran compiler to
    1) do its own preprocessing of *.F files rather than use a separate
    utility; and 2) substitute macros in code as well as in conditional
    compilation directives (which is necessary).

    Before executing make(1), 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.

    --------

    # The following requires about 46.3 MB for the source build-and-test
    # directory hierarchy, and about 6.8 MB for the installation
    # directory hierarchy.
    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 rev C++ compilers

        The 'C' compiler may run out of memory compiling libsrc/putget.c
        using "-O3" option. 
        cc-7951 cc: LIMIT File = putget.c, Line = 6617
                Insufficient memory is available for compiler to continue.
        (We don't see this problem anymore.) You can work around this
        by compiling -O2
                cd libsrc; c89 -c -O2 -I.  -DNDEBUG putget.c
        and continuing with the build.

        The C compiler issues some warnings:
                cc-7212 c89: ... Variable "xx" is used before it is defined.
        We believe these are unfounded. Since the only appear with
        optimization, they may be due to the compiler's inlining strategy.

        In nf_test, you can ignore the following warning:
 ldr-290 f90: CAUTION 
     Duplicate entry point 'HASH' was encountered.
     Entry in module 'HASH' from file 'util.o' has been used.
     Entry in module '$ZZFFLOW' from file '/opt/ctl/mpt/mpt/lib/libc.a' has
     been ignored.



Mac OS 8.x, 9.x

Sergey Malyshev has developed a Macintosh version of the netCDF library and udunits, for both PowerPC and 68K, and two MPW tools working with NetCDF files (they are a part of source distribution). This includes the Fortran interface built for Absoft FORTRAN.



NetBSD

Eric Fox reports:

I just wanted to let you know that the "netcdf" software runs on NetBSD 1.3.x (http://www.netbsd.org), with an easy to install package at ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/devel/netcdf/README.html.



Interix on Windows NT

Paul Wessel reports:

Some information that may be useful for others trying to install netCDF under Interix (formerly known as OpenNT). Interix is strictly POSIX and only comes with POSIX include files and libraries.

  1. If using gcc,
    • setenv CC gcc before running configure
    • run configure
    • delete the line containing "values.h" in ncgen/ncgentab.c Otherwise, compilation will fail on all systems that only have POSIX include files.
    • make as usual
    All compiles and tests fine, including g++. Fortran not tested since no Fortran compiler was found.

  2. If using the Microsoft Visual C/C++ compiler (which is accessed via the cc or c89 interface scripts),

    Problem: There is an #ifdef MSC_VER statement that will include io.h rather than unistd.h since the latter does not exist among the MSC include file. However, under OpenNT, only the compiler is used and the include files are the standard POSIX ones. Thus, under OpenNT with c89 we get the error message that io.h is not found. Solution: Perhaps use a different #ifdef that can distinguish between using MSVC in Windows and under OpenNT?



PowerPC running Linux

Richard van Hees <R.M.vanHees@fys.ruu.nl> reports:
I have just installed netcdf-3.4 on my PowerPC running Linux 
(pmac version 2.1.24), using egcs (instead of gcc-2.7.2).

environment settings:
   CPPFLAGS=-Df2cFortran
   CC=gcc
   CFLAGS="-O2 -fomit-frame-pointer -fsigned-char -pipe"
   FC=g77
   FFLAGS=-O2
   CXX=g++
   CXXFLAGS="$CFLAGS"

The compilations failed, while compiling ncgen/genlib.c due to an unused
definition at line 1204:

#define fpr    (void) fprintf

removing this line, and everything compiled just fine (C, Fortran and C++)
An RPM package for this platform is available.



Linux using egcs(1) & g77(1)

Bill Emanuel <wre6s@cycles.evsc.virginia.edu> reports that the following worked on his Dell Dimension XPS computer running Slackware 3.5 Linux 2.0.34:

CPPFLAGS='-Df2cFortran -DNDEBUG'
CC=egcs         # version 2.90.29
CFLAGS=
FC=/usr/bin/f77
FFLAGS="-O -Nx400 -w"
He further notes that if the C compiler is given the -O option, then the configure script fails because a test program wouldn't compile.

Linux using Portland Group's pgf90 compiler

Geoffrey Vallis <gkv@splash.princeton.edu> reported that the following settings worked when used in conjunction with the new src/fortran/cfortran.h file that will be in the next release:
CC=/usr/bin/cc
CPPFLAGS=-DpgiFortran
CFLAGS=-g
FC=pgf90
FFLAGS="-g -w"
CXX=/usr/bin/g++

Bill McKie reports further:

The final hurdle was being able to compile the test routine: netcdf-3.4/src/nf_test/test_put.F with pgf90 during the "make test" phase of the build. The preprocessor for this source file generates a large intermediate Fortran source file with more than 81000 lines and more than 100 internal subprograms. This quantity of lines and/or routines apparently causes an abnormal pgf90 compiler abort when pgf90 is run with default optimization. Turning off optimization in pgf90 with the -O0 switch allowed the compile of test_put.F to proceed. And the entire build was then able to complete to give us a netcdf v3.4 that is linkable with pgcc or pgf90.


Linux using Kuck & Associates KAI C++ compiler

Nicola Botta <botta@pik-potsdam.de< reports that the following settings worked for building netCDF-3.4 on a Linux 2.0.32 box with Kuck & Associates KAI C++ compiler:
CPPFLAGS=-g
CC='KCC --c'
CFLAGS=-g
FC=
FFLAGS=
CXX=KCC


MachTen 4.1.1 Unix (on a Mac PPC)

Hartmut Peters <hpeters@rsmas.miami.edu> reports that the following settings work for building netCDF 3.4 on a Mac PPC under MachTen 4.1.1 Unix (as well as Linux Redhat 5.2 on a Pentium II):
CPPFLAGS=-Df2cFortran
CC=/usr/bin/gcc
CFLAGS=-O
FC=/usr/bin/g77
FFLAGS=-O2
CXX=/usr/bin/g++
CXXFLAGS=-O
after modifying ncgen/ncgentab.c, exchanging the include file "values.h" (which is obsolete) with "float.h".



SunOS 5 using gcc(1) and g77(1)

Randy Arndt <rarndt@aurorasim.com> reports that the following worked:

$ uname -a
SunOS atlas 5.5.1 Generic Sun4u sparc SUNW,Ultra-1

CPPFLAGS=-Df2cFortran
CC=gcc # version 2.7.2.2.f.2
CFLAGS=-O
FC=f77 # symbolic link to g77 2.7.2.2.f.2
FFLAGS=-O
CXX=c++ # symbolic link to gcc 2.7.2.2.f.2


AIX 3.5

Kate Hedstrom <kate@ahab.rutgers.edu> reports that the following worked:

CPPFLAGS='-D_POSIX_SOURCE -DNDEBUG -D_ALL_SOURCE'
CC=xlc
CFLAGS=-O
FC=xlf
FFLAGS=-O
CXX=xlC


Linux using g77(1)

Phil Austin <phil@geog.ubc.ca> reports that the following worked on his Debian 1.3 Linux system:

$ uname -a
Linux curlew 2.0.27 #2 Tue May 6 17:57:24 PDT 1997 i686

CPPFLAGS='-Df2cFortran -DNDEBUG'
CC=/usr/bin/cc # version 2.7.2.1-4
CFLAGS=-O
FC=g77 # version 0.5.19.1-1
FFLAGS=-O
CXX=/usr/bin/c++

Jan Polcher <Jan.Polcher@lmd.jussieu.fr> reports that he added "-ff2c" to his FFLAGS option.



Using NAG f90 compiler

Steve Mauget <smauget@mail.csrl.ars.usda.gov> reports that the following worked on his SGI IRIX 5.3 system:

CPPFLAGS=
CC=c89
CFLAGS=-g
FC=f90 # NAG
FFLAGS='-g -mismatch'


HP-UX 10

We have found that the following works on our new HP-UX B.10.20 system:

CPPFLAGS='-D_HPUX_SOURCE -DNDEBUG'
CC=c89
CFLAGS=-O
FC=fort77
FFLAGS='-O3 -w'


This page was prepared by Steve Emmerson.
Questions or comments can be sent to <support@unidata.ucar.edu>.