Netcdf Install

Embed Size (px)

Citation preview

  • 7/30/2019 Netcdf Install

    1/36

    The NetCDF Installation and Porting GuideNetCDF Version 4.1.3

    Last Updated 10 June 2011

    Ed Hartnett, Russ Rew, John CaronUnidata Program Center

  • 7/30/2019 Netcdf Install

    2/36

    Copyright c 2005-2009 University Corporation or Atmospheric Research

    Permission is granted to make and distribute verbatim copies o this manual provided thatthe copyright notice and these paragraphs are preserved on all copies. The sotware and anyaccompanying written materials are provided as is without warranty o any kind. UCARexpressly disclaims all warranties o any kind, either expressed or implied, including but not

    limited to the implied warranties o merchantability and tness or a particular purpose.The Unidata Program Center is managed by the University Corporation or AtmosphericResearch and sponsored by the National Science Foundation. Any opinions, ndings, con-clusions, or recommendations expressed in this publication are those o the author(s) anddo not necessarily reect the views o the National Science Foundation.

    Mention o any commercial company or product in this document does not constitute anendorsement by the Unidata Program Center. Unidata does not authorize any use oinormation rom this publication or advertising or publicity purposes.

  • 7/30/2019 Netcdf Install

    3/36

    i

    Table o Contents

    1 Installing the NetCDF Binaries . . . . . . . . . . . . . . . 1

    2 Quick Instructions or Installing NetCDF onUnix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2.1 Building NetCDF Without HDF5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Building NetCDF With HDF5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 Building with HDF4 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    3 Building and Installing NetCDF on UnixSystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    3.1 Installation Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 Speciying the Environment or Building

    . . . . . . . . . . . . . . . . . . . . . . . .

    53.2.1 Variable Description Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    3.3 Building on 64 Bit Platorms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.4 Building on Platorms with Parallel I/O . . . . . . . . . . . . . . . . . . . . . . . . 8

    3.4.1 Building HDF5 or Parallel I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.4.2 The parallel-netcd Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.4.3 Building NetCDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3.5 Running the congure Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.6 Running make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.7 Testing the Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.8 Installing NetCDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    3.9 Platorm Specic Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    143.9.1 AIX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.9.2 Cygwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.9.3 HPUX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.9.4 Irix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.9.5 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.9.6 Macintosh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.9.7 OSF1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.9.8 SunOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.9.9 Handling Fortran Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    3.10 Additional Porting Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.11 Contributing to NetCDF Source Code Development . . . . . . . . . . 17

    4 Using NetCDF on Unix Systems . . . . . . . . . . . . . 194.1 Using Linker Flags with NetCDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2 Using Compiler Flags with NetCDF . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.3 Using the nc-cong Utility to Find Compiler and Linker Flags. . 19

  • 7/30/2019 Netcdf Install

    4/36

    ii NetCDF Installation and Porting Guide

    5 Building and Installing NetCDF on Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    5.1 Getting Prebuilt netcd.dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2 Installing the DLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.3 Building netcd.dll with VC++ 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    5.4 Using netcd.dll with VC++ 6.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    245.5 Building netcd.dll with VC++.NET . . . . . . . . . . . . . . . . . . . . . . . . . . 245.6 Using netcd.dll with VC++.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    6 I Something Goes Wrong . . . . . . . . . . . . . . . . . . . . 276.1 The Usual Build Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    6.1.1 Taking the Easy Way Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.1.2 How to Clean Up the Mess rom a Failed Build . . . . . . . . . . . 276.1.3 Platorms On Which NetCDF is Known to Work . . . . . . . . . 276.1.4 Platorms On Which NetCDF is Reported to Work . . . . . . . 286.1.5 I You Have a Broken Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    6.1.6 What to Do I NetCDF Still Wont Build. . . . . . . . . . . . . . . . .

    286.2 Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.2.1 Problems During Conguration. . . . . . . . . . . . . . . . . . . . . . . . . . . 286.2.2 Problems During Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.2.3 Problems During Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    6.3 Finding Help On-line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.4 Reporting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

  • 7/30/2019 Netcdf Install

    5/36

  • 7/30/2019 Netcdf Install

    6/36

  • 7/30/2019 Netcdf Install

    7/36

    Chapter 2: Quick Instructions or Installing NetCDF on Unix 3

    2 Quick Instructions or Installing NetCDF onUnix

    Who has time to read long installation manuals these days?

    When building netCDF-4, you must rst decide whether to support the use o HDF5 asa storage ormat.

    2.1 Building NetCDF Without HDF5

    I you dont want netCDF-4/HDF5, then build like this:

    ./configure --prefix=/home/ed/local --disable-netcdf-4

    make check install

    (Replace /home/ed/local with the name o the directory where netCDF is to be in-stalled.)

    I you get the message that netCDF installed correctly, then you are done!

    2.2 Building NetCDF With HDF5I you want to use the HDF5 storage ormat, you must have the HDF5 1.8.6 release. Youmust also have the zlib compression library, version 1.2.5. Both o these packages are avail-able rom the netCDF-4 tp site at ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4 .

    Make sure you run make check or the HDF5 and zlib distributions. They are very well-behaved distributions, but sometimes the build doesnt work (perhaps because o somethingsubtly miscongured on the target machine). I one o these libraries is not working, netCDFwill have serious problems.

    Optionally, you can also build netCDF-4 with the szip 2.0 library (a.k.a. szlib). NetCDFcannot create szipped data les, but can read HDF5 data les that have used szip.

    There are license restrictions on the use o szip, see the HDF5 web page:http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.html . These licenserestrictions seem to apply to commercial users who are writing data. (Data readers arenot restricted.) But here at NetCDF World Headquarters, in Sunny Boulder, Colorado,there are no lawyers, only programmers, so please read the szip documents or the licenseagreement to see how it applies to your situation.

    I you wish to use szip, get it rom the HDF5 download page: http://hdfgroup.org/HDF5//HDF5/re

    I make check ails or either zlib or HDF5, the problem must be resolved beore thenetCDF-4 installation can continue. For HDF5 problems, send email to the HDF5 helpdesk: [email protected].

    Build zlib like this:

    ./configure --prefix=/home/ed/localmake check install

    Then you build HDF5, speciying the location o the zlib library:

    ./configure --with-zlib=/home/ed/local --prefix=/home/ed/local

    make check install

    Note that or shared libraries, you may need to add the install directory to theLD LIBRARY PATH environment variable. See the FAQ or more details on using sharedlibraries: http://www.unidata.ucar.edu/netcdf/faq.html .

    ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.htmlhttp://hdfgroup.org/HDF5//HDF5/release/beta/obtain518.htmlhttp://www.unidata.ucar.edu/netcdf/faq.htmlhttp://www.unidata.ucar.edu/netcdf/faq.htmlhttp://hdfgroup.org/HDF5//HDF5/release/beta/obtain518.htmlhttp://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.htmlftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4
  • 7/30/2019 Netcdf Install

    8/36

  • 7/30/2019 Netcdf Install

    9/36

    Chapter 3: Building and Installing NetCDF on Unix Systems 5

    3 Building and Installing NetCDF on UnixSystems

    The latest version o this document is available at http://www.unidata.ucar.edu/netcdf/docs/netcd

    This document contains instructions or building and installing the netCDF packagerom source on various platorms. Prebuilt binary releases are (or soon will be) available orvarious platorms rom http://www.unidata.ucar.edu/downloads/netcdf/index.jsp .

    A good general tutorial on how sotware is built rom source on Linux platorms can meound at http://www.tuxfiles.org/linuxhelp/softinstall.html .

    3.1 Installation Requirements

    I you wish to build rom source on a Windows (Win32) platorm, diferent instructionsapply. See Chapter 5 [Building on Windows], page 21.

    Depending on the platorm, you may need up to 25 Mbytes o ree space to unpack,

    build, and run the tests. You will also need a Standard C compiler. I you have compilersor FORTRAN 77, FORTRAN 90, or C++, the corresponding netCDF language interacesmay also be built and tested. Compilers and associated tools will only be ound i theyare in your path, or i you speciy the path and compiler in the appropriate environmentvariable. (Example or csh: setenv CC /some/directory/cc).

    I you want to run the large le tests, you will need about 13 GB o ree disk space, assome very large les are created. The created les are immediately deleted ater the testscomplete. These large le tests are not run unless the enable-large-le-tests option is usedwith congure. (The with-temp-large option may also be used to speciy a directory tocreate the large les in).

    Unlike the output rom other netCDF test programs, each large test program deletes its

    output beore successully exiting.To use the netCDF-4 eatures you will also need to have a HDF5-1.8.6 release installed.

    HDF5, in turn, must have been built with zlib, version 1.2.5.

    A tested version o HDF5 and zlib can be ound at the netCDF-4 tp site atftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4 .

    For more inormation about HDF5 see the HDF5 web site at http://hdfgroup.org/HDF5/.For more inormation about zlib see the zlib web site at http://www.zlib.net.

    To use the DAP eatures you will also need to have a version o libcurl (version 7.18.0or later) installed. Depending on how this library was built, you may also need zib (version1.2.5 or later). Inormation about libcurl may be obtained at http://curl.haxx.se.

    3.2 Speciying the Environment or BuildingThe netCDF congure script searches your path to nd the compilers and tools it needed.To use compilers that cant be ound in your path, set their environment variables.

    The congure script will use gcc and associated GNU tools i they are ound. Many users,especially those with perormance concerns, will wish to use a vendor supplied compiler.

    For example, on an AIX system, users may wish to use xlc (the AIX compiler) in one oits many avors. Set environment variables beore the build to achieve this.

    http://www.unidata.ucar.edu/netcdf/docs/netcdf-installhttp://www.unidata.ucar.edu/downloads/netcdf/index.jsphttp://www.tuxfiles.org/linuxhelp/softinstall.htmlftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4http://hdfgroup.org/HDF5/http://www.zlib.net/http://curl.haxx.se/http://curl.haxx.se/http://www.zlib.net/http://hdfgroup.org/HDF5/ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4http://www.tuxfiles.org/linuxhelp/softinstall.htmlhttp://www.unidata.ucar.edu/downloads/netcdf/index.jsphttp://www.unidata.ucar.edu/netcdf/docs/netcdf-install
  • 7/30/2019 Netcdf Install

    10/36

  • 7/30/2019 Netcdf Install

    11/36

  • 7/30/2019 Netcdf Install

    12/36

    8 NetCDF Installation and Porting Guide

    AIX Set -q64 option in all compilers, and set NMFLAGS to -X64, and ARFLAGSto -X64 cru. Alternatively, set environment variable OBJECT MODE to 64beore running congure.

    IRIX Set the -64 option in all compilers.SunOS Use the -xarch=v9 or -m64 ag on all compilers or Sparc, or -m64 on x86

    platorms.

    3.4 Building on Platorms with Parallel I/O

    NetCDF makes available the parallel I/O eatures o HDF5 and the parallel-netcd libraries,allowing parallel I/O rom netCDF-4 linked programs.

    3.4.1 Building HDF5 or Parallel I/O

    For parallel I/O to work, HDF5 must be installed with enable-parallel, and an MPI li-

    brary (and related libraries) must be made available to the HDF5 congure. This can beaccomplished with the mpicc wrapper script, in the case o MPICH2.

    The ollowing works to build HDF5 with parallel I/O on our netCDF testing system:

    CC=mpicc ./configure --enable-parallel --prefix=/shecky/local_par --with-zlib=/s

    3.4.2 The parallel-netcd Library

    Optionally, the parallel-netcd library should also be installed, and the replacement orpnetcd.h should be copied rom tp://tp.unidata.ucar.edu/pub/netcd/contrib/pnetcd.h.

    3.4.3 Building NetCDF

    To build netCDF with parallel I/O, build as usual, but point the congure at a version o

    HDF5 that has been built or parallel I/O.

    CPPFLAGS=-I/shecky/local_par/include

    CXXFLAGS=-I/shecky/local_par/include

    FFFLAGS=-I/shecky/local_par/include

    FCFLAGS=-I/shecky/local_par/include LDFLAGS=-L/shecky/local_par/lib

    FC=mpif90 CXX=mpicxx CC=mpicc ./configure

    make check install

    To enable the parallel tests, speciy enable-parallel-tests as an option to congure.These tests will be run as mpiexec calls. This may not be appropriate on all systems,especially those which use some queue or jobs.

    To use parallel-netcd to perorm parallel I/O on classic and 64-bit ofset les, use theenable-pnetcd option.

    For parallel builds the netCDF examples are not built. This is to avoid cluttering themwith MPI Init/Finalize calls.

    3.5 Running the confgure Script

    To create the Makeles needed to build netCDF, you must run the provided congure script.Go to the top-level netCDF directory.

  • 7/30/2019 Netcdf Install

    13/36

  • 7/30/2019 Netcdf Install

    14/36

    10 NetCDF Installation and Porting Guide

    --enable-hdf4

    Turns on the HDF4 read layer. This reads HDF4 les created with the SD(Scientic Data) API o HDF4.

    --enable-hdf4-file-testsCauses make check to use wget to etch some HDF4 data les rom the UnidataFTP server, and check that they are properly understood. This is done as parto automatic netCDF testing, and should not be done by users.

    --enable-pnetcdf

    Allows parallel I/O with classic and 64-bit ofset ormat les,using the parallel-netcd (ormerly pnetcd) library rom Ar-gonne/Northwestern. The parallel-netcd library must be installed,and a specially modied pnetcd.h must be used. (Get it attp://tp.unidata.ucar.edu/pub/netcd/user/contrib/pnetcd.h)

    --with-udunitsBuilds UDUNITS2 as well as netCDF. The UDUNITS2 package supportsunits o physical quantities (e.g., meters, seconds). Specically, itsupports conversion between string and binary representations o units,arithmetic manipulation o units, and conversion o numeric valuesbetween compatible units. For more inormation about UDUNITS, see:http://www.unidata.ucar.edu/sotware/udunits/

    --disable-largefile

    This omits OS support or large les (i.e. les larger than 2 GB).

    --disable-fortran

    Turns of Fortran 77 and Fortran 90 API. (Same as disable-77.)

    --disable-f77

    This turns of building o the F77 and F90 APIs. (The F90 API cannot be builtwithout the F77 API). This also disables some o the congure tests that relateto ortran, including the test o the F90 compiler. Setting the environmentvariables FC or F77 to NULL will have the same efect as disable-77.

    --disable-f90

    This turns of the building o the F90 API. Setting the environment variableF90 to null or congure will have the same efect.

    --disable-cxxThis turns of the building o the C++ API. Setting the environment variableCXX to null or congure will have the same efect.

    --disable-v2

    This turns o the V2 API. The V2 API is completely replaced with the V3 API,but is usually built with netCDF or backwards compatibility, and also becausethe C++ API depends on the V2 API. Setting this has the efect o automaticallyturning of the CXX API, as i disable-cxx had also been specied.

  • 7/30/2019 Netcdf Install

    15/36

    Chapter 3: Building and Installing NetCDF on Unix Systems 11

    --enable-cxx4

    Turns on the new C++ API, which is currently under development, and willexpose the ull expanded model in the C++ API. The cxx4 API is experiemental,unnished, and untested. It is provided or experiemental purposes only.

    --enable-large-file-tests

    Turn on tests or large les. These tests create les over 2 GB in size, andneed about 13 GB o ree disk space to run. These les are deleted aterthe test successully completes. They will be created in the netCDF nc testdirectory, unless the with-temp-large option is used to speciy another location(see below).

    --with-temp-large

    Normally large les are not created during the netCDF build, but they willbe i enable-large-le-tests is specied (see above). In that case, this cong-ure parameter can be used to speciy a location to create these large les, orexample: with-large-les=/tmp/ed.

    --enable-benchmarks

    Turn on tests o the speed o various netCDF operations. Some o these oper-ations take a long time to run (minutes, on a reasonable workstation).

    --enable-valgrind-tests

    Causes some tests to be re-run under valgrind, the memory testing tool. Val-grind must be present or this to work. Also HDF5 must be built with enable-using-memchecker, and netCDF must be compiled without optimization (atleast on the Unidata test platorm where this is tested). The valgrind tests arerun by shell script libsrc4/run valgrind tests.sh. It simply reruns the test pro-grams in that directory, using valgrind, and with settings such that any errorreported by valgrind will cause the make check to ail.

    --disable-fortran-type-check

    The netCDF congure compiles and runs some programs to test ortran vs.C type sizes. Setting this option turns of those test, and uses a set o de-ault values (which can be overridden by environment variables see Section 3.2[Environment], page 5).

    --disable-examples

    Starting with version 3.6.2, netCDF comes with some examples in the exam-ples directory. By deault, the examples are all built during a make checkunless the disable-examples option is provided.

    --enable-extra-tests

    This option may turn on tests which are known to ail (i.e. bugs that we arecurrently working to x).

    --with-default-chunk-size

    Change the size (in bytes) that will be used as a target size when computingdeault chunksizes or netCDF-4/HDF5 chunked variables.

    --default-chunks-in-cache

    Change the number o chunks that are accomodated in the per-variable chunkcaches that are used by deault.

  • 7/30/2019 Netcdf Install

    16/36

    12 NetCDF Installation and Porting Guide

    --max-default-cache-size

    Change the maximum size o the per-variable chunk caches that are used bydeault.

    --with-chunk-cache-sizeChange the size o the deault le-level chunk cache size that will be used whenopening netCDF-4/HDF5 les.

    --with-chunk-cache-nelems

    Change the size o the deault le-level chunk cache number o elements thatwill be used when opening netCDF-4/HDF5 les. Should be a prime number.

    --with-chunk-cache-preemption

    Change the deault preemption o the le-level chunk cache that will be usedwhen opening netCDF-4/HDF5 les. Must be a number between 0 and 1(inclusive).

    The congure script will examine your computer system checking or attributes thatare relevant to building the netCDF package. It will print to standard output the checksthat it makes and the results that it nds.

    The congure script will also create the le "cong.log", which will contain error mes-sages rom the utilities that the congure script uses in examining the attributes o yoursystem. Because such an examination can result in errors, it is expected that "cong.log"will contain error messages. Thereore, such messages do not necessarily indicate a problem(a better indicator would be ailure o the subsequent "make"). One exception, however, isan error message in "cong.log" that indicates that a compiler could not be started. Thisindicates a severe problem in your compilation environment one that you must x. I thisoccurs, congure will not complete and will exit with an error message telling you aboutthe problem.

    3.6 Running make

    Run "make". This will build one or more netCDF libraries. It will build the basic netCDFlibrary libnetcd.a. I you have Fortran 77 or Fortran 90 compilers, then the Fortran librarywill also be built (libnetcdf.a). I you have a C++ compiler, then the C++ interace will bebuilt (libnetcd c++.a.)

    A make will also build the netCDF utilities ncgen(1) and ncdump(1).

    Run make like this:

    make

    3.7 Testing the BuildRun make check to veriy that the netCDF library and executables have been builtproperly (you can instead run make test which does the same thing).

    A make check will build and run various test programs that test the C, Fortran, andC++ interaces as well as the "ncdump" and "ncgen" utility programs.

    Lines in the output beginning with "***" report on success or ailure o the tests; anyailures will be reported beore halting the test. Compiler and linker warnings during thetesting may be ignored.

  • 7/30/2019 Netcdf Install

    17/36

    Chapter 3: Building and Installing NetCDF on Unix Systems 13

    Run the tests like this:

    make check

    I you plan to use the 64-bit ofset ormat (introduced in version 3.6.0) or the netCDF-

    4/HDF5 ormat to create very large les (i.e. with variables larger than 2 GB), you shouldprobably speciy the enable-large-le-tests to congure, which tests the large le eatures.You must have 13 GB o ree disk space or these tests to successully run.

    I you are running the large le tests, you may wish to use the with-temp-large optionto speciy a temporary directory or the large les. (You may also set the environmentvariable TEMP LARGE beore running congure).

    The deault is to create the large les in the nc test subdirectory o the netCDF build.

    Run the large le tests like this:

    ./configure --enable-large-file-tests --with-temp-large=/home/ed/tmp

    make check

    All o the large les are removed on successul completion o tests. I the test ails, youmay wish to make sure that no large les have been let around.

    I any o the the large le tests test ail, check to ensure that your le system can handleles larger than 2 GiB by running the ollowing command:

    dd if=/dev/zero bs=1000000 count=3000 of=$(TEMP_LARGE)/largefile

    I your system does not have a /dev/zero, this test will ail. Then you need to nd someother way to create a le larger than 2 GiB to ensure that your system can handle them.

    See Chapter 6 [Build Problems], page 27.

    3.8 Installing NetCDF

    To install the libraries and executables, run "make install". This will install to the directoryspecied in the congure step.

    Run the installation like this:

    make install

    The install will put les in the ollowing subdirectories o the directory you provided asa prex, creating the subdirectories i needed:

    lib Libraries will be installed here. I static libraries are built, without separateortran libraries, then libnetcd.a and libnetcd.la will be installed. I the C++API is built, libnetcd c++.a and libnetcd c++.la will be added. I separateortran libraries are built, libnetcdf.a and libnetcdf.la will also be added.

    Static library users should ignore the .la les, and link to the .a les.

    Shared library builds will add some .so les to this directory, as well.

    include Header les will be installed here. The C library header le is netcd.h. I theC++ library is built, ntcdcpp.h, ncvalues.h and netcd.hh will be installed here.I the F77 API is built, netcd.inc will be copied here. I the F90 API is built,the netcd.mod and typesizes.mod les will be copied here as well.

    bin Utilities ncdump and ncgen will be installed here.

  • 7/30/2019 Netcdf Install

    18/36

    14 NetCDF Installation and Porting Guide

    man The ncdump/ncgen man pages will be installed in subdirectory man1, and thethree man pages netcd.3, netcd 77.3, and netcd 90.3 will be installed in theman3 subdirectory.

    share I the congure is called with the enable-docs option, the netCDF documenta-tion set will be built, and will be installed under the share directory, under thenetcd subdirectory. This will include postscript, PDF, ino and text versionso all netCDF manuals. These manuals are also available at the netCDF website.

    Try linking your applications. Let us know i you have problems (see Section 6.4 [Re-porting Problems], page 30).

    3.9 Platorm Specifc Notes

    The ollowing platorm-specic note may be helpul when building and installing netCDF.Consult your vendor manuals or inormation about the options listed here. Compilers canchange rom version to version; the ollowing inormation may not apply to your platorm.

    Full output rom some o the platorms o the test platorms or netCDF 4.1.3 can beound at http://www.unidata.ucar.edu/netcdf/builds .

    3.9.1 AIX

    We ound the vendor compilers in /usr/vac/bin, and included this in our PATH. Compilerswere xlc, xl, xl90, xlC.

    The F90 compiler requires the qsux option to believe that F90 code les can end with.90. This is automatically turned on by congure when needed:

    FCFLAGS=-qsuffix=f=f90

    We had to use xl or F77 code, and xl90 or 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 onall AIX compilers by setting CFLAGS, FFLAGS, and CXXFLAGS to -q64.

    The ollowing is also necessary on an IBM AIX SP system or 64-bit mode:

    ARFLAGS=-X64 cru

    NMFLAGS=-X64

    There are thread-sae versions o the AIX compilers. For example, xlc r is the thread-sae C compiler. To use thread-sae compilers, override the congure script by setting CCto xlc r; similarly or FC and CXX.

    For large le support, AIX requires that the macro LARGE FILES be dened. Thecongure script does this using AC SYS LARGEFILES. Unortunately, this misres whenOBJECT MODE is 64, or the q64 option is used. The netCDF tries to x this by turningon LARGE FILES anyway in these cases.

    The GNU C compiler does not mix successully with the AIX ortran compilers.

    3.9.2 Cygwin

    NetCDF builds under Cygwin tools on Windows just as with Linux.

    http://www.unidata.ucar.edu/netcdf/buildshttp://www.unidata.ucar.edu/netcdf/builds
  • 7/30/2019 Netcdf Install

    19/36

  • 7/30/2019 Netcdf Install

    20/36

    16 NetCDF Installation and Porting Guide

    3.9.6 Macintosh

    The gFortran ag is required with GNU ortran (CPPFLAGS=-DgFortran). The NetCDFcongure script should and set this automatically.

    For IBM compilers on the Mac, the ollowing may work (we lack this test environment):CC=/usr/bin/cc

    CPPFLAGS=-DIBMR2Fortran

    F77=xlf

    FC=xlf90

    FCFLAGS=-qsuffix=cpp=f90

    3.9.7 OSF1

    NetCDF builds out o the box on OSF1.

    3.9.8 SunOS

    PATH should contain /usr/ccs/bin to nd make, nm, ar, etc.

    For large le support, FILE OFFSET BITS must be 64, also LARGEFILE64 SOURCEand LARGEFILE SOURCE must be set. Congure will turn this on automatically ornetCDF, but not or HDF5. So when building HDF5, set these variables beore runningcongure, or HDF5 will not be capable o producing large les.

    To compile in 64-bit mode, set -m64 (ormerly -xarch=v9, which works on SPARCplatorms only) on all compilers (i.e. in CFLAGS, FFLAGS, FCFLAGS, and CXXFLAGS).

    When compiling with GNU Fortran (g77), the -DgFortran ag is required or the Fortraninterace to work. The NetCDF congure script turns this on automatically i needed.

    3.9.9 Handling Fortran CompilersCommercial ortran compilers will generally require at least one ag in the CPPFLAGSvariable. The netCDF congure script tries to set this or you, but wont try i you haveused disable-ag-setting, or i you have already set CPPFLAGS, CFLAGS, CXXFLAGS,FCFLAGS, or FFLAGS yoursel.

    The rst thing to try is to set nothing and see i the netCDF congure script nds yourortran compiler, and sets the correct ags automatically.

    I it doesnt nd the correct ortran compiler, you can next try setting the FC environ-ment variable to the compiler you wish to use, and then see i the congure script can setthe correct ags or that compiler.

    I all that ails, you must set the ags yoursel.

    The Intel compiler likes the pgiFortran ag, as does the Portland Group compiler. (Au-tomatically turned on i your ortran compiler is named iort or pg90).

    Alternatively, Intel has provided a web page on Building netCDF with the Intel com-pilers at http://www.intel.com/support/performancetools/sb/CS-027812.htm , pro-viding instructions or building netCDF (without using the pgiFortran ag).

    The Portland Group also has a PGI Guide to NetCDF at http://www.pgroup.com/resources/nepgi71.htm.

    http://www.intel.com/support/performancetools/sb/CS-027812.htmhttp://www.pgroup.com/resources/netcdf/netcdf362_pgi71.htmhttp://www.pgroup.com/resources/netcdf/netcdf362_pgi71.htmhttp://www.pgroup.com/resources/netcdf/netcdf362_pgi71.htmhttp://www.pgroup.com/resources/netcdf/netcdf362_pgi71.htmhttp://www.intel.com/support/performancetools/sb/CS-027812.htm
  • 7/30/2019 Netcdf Install

    21/36

    Chapter 3: Building and Installing NetCDF on Unix Systems 17

    3.10 Additional Porting Notes

    The congure and build system should work on any system which has a modern "sh" shell,"make", and so on. The congure and build system is less portable than the "C" code

    itsel, however. You may run into problems with the "include" syntax in the Makeles.You can use GNU make to overcome this, or simply manually include the specied lesater running congure.

    Instruction or building netCDF on other platorms can be ound athttp://www.unidata.ucar.edu/netcdf/other-builds.html . I you buildnetCDF on a new platorm, please send your environment variables and any otherimportant notes to [email protected] and we will add the inormation tothe other builds page, with a credit to you.

    I you cant run the congure script, you will need to create cong.h andortran/ncong.inc. Start with nccong.in and ortran/ncong.in and set the denes asappropriate or 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(). o.c uses a speciallibrary available on CRAY systems. You could create other versions or diferent operatingsystems. The program "t ncio.c" can be used as a simple test o this layer.

    Note that we have not had a Cray to test on or some time. In particular, large lesupport is not tested with o.c.

    Numerical representation dependency is isolated in the "ncx" module. As supplied,ncx.m4 (ncx.c) supports IEEE oating point representation, VAX oating point, and CRAYoating point. BIG ENDIAN vs LITTLE ENDIAN is handled, as well as various sizes o"int", "short", and "long". We assume, however, that a "char" is eight bits.

    There is a separate implementation o the ncx interace available as ncx cray.c whichcontains optimizations or CRAY vector architectures. Move the generic ncx.c out o theway and rename ncx cray.c to ncx.c to use this module. By deault, this module does notuse the IEG2CRAY and CRAY2IEG library calls. When compiled with aggressive in-liningand optimization, it provides equivalent unctionality with comparable speed and clearererror semantics. I you wish to use the IEG library unctions, compile this module with-DUSE IEG.

    3.11 Contributing to NetCDF Source Code Development

    Most users will not be interested in working directly with the netCDF source code. Rather,they will write programs which call netCDF unctions, and delve no urther. However some

    intrepid users may wish to dig into the netCDF code to study it, to try and spot bugs, orto make modications or their own purposes.

    To work with the netCDF source code, several extra utilities are required to ully buildeverything rom source. I you are going to modiy the netCDF source code, you will needsome or all o the ollowing Unix tools.

    m4 Macro processing language used heavily in libsrc, nc test. Generates (in thesecases) C code rom m4 source. Version 1.4 works ne with release 3.5.1 through3.6.2.

    http://www.unidata.ucar.edu/netcdf/other-builds.htmlhttp://www.unidata.ucar.edu/netcdf/other-builds.html
  • 7/30/2019 Netcdf Install

    22/36

    18 NetCDF Installation and Porting Guide

    flex and yacc

    Used in ncgen directory to parse CDL les. Generates C les rom .y and .l les.You only need to use this to modiy ncgens understanding o CDL grammar.

    makeinfo Generates all documentation ormats (except man pages) rom texino source.Im using makeino version 4.8, as o release 3.6.2. I you have trouble withmakeino, upgrade to this version and try again. You only need makeino i youwant to modiy the documentation.

    tex Knuths venerable typesetting system. The version I am running (or netCDFrelease 3.6.2) is TeX 3.141592 (Web2C 7.5.4). I have ound that some recentinstallations o TeX will not build the netCDF documentation - its not clearto me why.

    The user generally will just want to download the latest version o netCDF docu-ments at the netCDF website. http://www.unidata.ucar.edu/netcdf/docs .

    autoconf Generates the congure script. Version 2.59 or later is required.

    automake Since version 3.6.2 o netCDF, automake is used to generate the Makele.inles needed by the congure script to build the Makeles.

    libtool Since version 3.6.2 o netCDF, libtool is used to help generate shared librariesplatorms which support them. Version 2.1a o libtool is required.

    sed This text processing tool is used to process some o the netCDF examples beorethey are included in the tutorial. This is only needed to build the documenta-tion, which the user generally will not need to do.

    NetCDF has a large and enterprising user community, and a long history o acceptinguser modications into the netCDF code base. Examples include the 64-bit ofset ormat,and the F90 API.

    All suggested changes and additions to netCDF code can be sent to [email protected].

    http://www.unidata.ucar.edu/netcdf/docshttp://www.unidata.ucar.edu/netcdf/docs
  • 7/30/2019 Netcdf Install

    23/36

  • 7/30/2019 Netcdf Install

    24/36

    20 NetCDF Installation and Porting Guide

    nc-config --libs

    -L/usr/local/lib -lnetcdf -L/shecky/local_post/lib -lhdf5_hl -lhdf5 -lz

    The nc-cong utility can also be used to learn about the eatures o the current netCDF

    installation. For example, it can show whether netCDF-4 is available:./nc-config --has-nc4

    yes

    Use the help option to nc-cong or a ull list o available inormation.

  • 7/30/2019 Netcdf Install

    25/36

  • 7/30/2019 Netcdf Install

    26/36

    22 NetCDF Installation and Porting Guide

    the ncgen and ncdump executables, you will be able to use the DLL and utilities withouturther work, because compilers already look there or DLLs and EXEs.

    Instead o putting the DLL and EXEs into the system directory, you can leave them

    wherever you want, and every development project that uses the dll will have to be toldto search the netCDF directory when its linking, or, the chosen directory can be added toyour path.

    On the .NET platorm, you can also try to use the global assembly cache. (To learnhow, see MSDN topic Global Assembly Cache, at www.msdn.microsoft.com).

    Following Windows conventions, the netCDF les belong in the ollowing places:

    File(s) Description Location

    netcd.dll C and Fortran unction in DLL Windows\System(98/ME) or

    Windows\System32(2000/XP)

    netcd.lib Library le Windows\System(98/ME) orWindows\System32(2000/XP)

    ncgen.exe,ncdump.exe

    NetCDF utilities Windows\System(98/ME) orWindows\System32(2000/XP)

    netcd-3 netCDF source code ProgramFiles\Unidata

    5.3 Building netcd.dll with VC++ 6.0

    The most recent releases o netCDF arent tested under VC++ 6.0. (They are tested withVC++.NET). Older versions o the library, notably 3.5.0, did compile with VC++ 6.0, andthe instructions or doing so are presented below.

    Note that the introduction o better large le support (or les larger than 2 GiB) in

    version 3.6.0 and greater requires an of t type o 8 bytes, and its not clear how, or i, thiscan be ound in VC++ 6.0.

    To build the library yoursel, get the le tp://tp.unidata.ucar.edu/pub/netcd/contrib/win32/netcd3.5.0.win32make.VC6.zip

    The makeles there describe how to build netcd-3.5 using the using Microsot Visual C ++6.x and (optionally) Digital Visual Fortran 6.x. Because o diculties in getting MicrosotVisual Studio to all in line with our existing source directory scheme, we chose not tobuild the system "inside" Visual Studio. Instead, we provide a simple group o "msot.mak"

    http://www.msdn.microsoft.com/http://www.msdn.microsoft.com/
  • 7/30/2019 Netcdf Install

    27/36

  • 7/30/2019 Netcdf Install

    28/36

  • 7/30/2019 Netcdf Install

    29/36

    Chapter 5: Building and Installing NetCDF on Windows 25

    5.6 Using netcd.dll with VC++.NET

    Load-time linking to the DLL is the most straightorward rom C++. This means thenetcd.lib le has to end up on the compile command line. This being Windows, thats

    hidden by a GUI.In Visual Studio 2003 this can be done by modiying three o the projects properties.

    Open the project properties window rom the project menu. Go to the linker older andlook at the general properties. Modiy the property Additional Library Directories byadding the directory which contains the netcd.dll and netcd.lib les. Now go to the linkerinput properties and set the property Additional Dependencies to netcd.lib.

    Finally, still within the project properties window, go to the C/C++ older, and look atthe general properties. Modiy Additional Include Directories to add the directory withthe netcd.h le.

    Now use the netCDF unctions in your C++ code. O course any C or C++ le that wantsto use the unctions will need:

    #include

  • 7/30/2019 Netcdf Install

    30/36

  • 7/30/2019 Netcdf Install

    31/36

  • 7/30/2019 Netcdf Install

    32/36

  • 7/30/2019 Netcdf Install

    33/36

  • 7/30/2019 Netcdf Install

    34/36

  • 7/30/2019 Netcdf Install

    35/36

  • 7/30/2019 Netcdf Install

    36/36