Editing
Software Development Platforms
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===HDF5 and netCDF=== Get HDF5 from http://www.hdfgroup.org/downloads/index.html . I used the CMake build for HDF5, instead of the automake build. Note that for version 1.8.9 you have to apply a patch (or edit by hand one file) as described here: http://www.hdfgroup.org/ftp/HDF5/current/src/ . Here are some interesting cmake options: {| border="1" cellpadding="2" cellspacing="0" |- ! option ! Setting |- valign="top" | BUILD_SHARED_LIBS || ON |- valign="top" | CMAKE_BUILD_TYPE || Release |- valign="top" | CMAKE_INSTALL_PREFIX || /opt/hdf5-1.8.9 |- valign="top" | HDF5_BUILD_CPP_LIB || OFF |- valign="top" | HDF5_BUILD_FORTRAN || OFF |- valign="top" | HDF5_BUILD_HL_LIB || ON |- valign="top" | HDF5_BUILD_TOOLS || ON |- valign="top" | HDF5_ENABLE_Z_LIB_SUPPORT || ON |} Build in the usual way for CMake. Note that the automake build has all the defaults as above anyway, so it is just ./configure --prefix=/Users/Shared/install/hdf5-1.8.9 Here's a setenv script for setting environment variables: <source lang=bash> #!/bin/bash source /usr/local/bin/setenv_functions.sh remove_path PATH '/.*/hdf5(-[^/]+)?/bin/?' remove_path DYLD_LIBRARY_PATH '/.*/hdf5(-[^/]+)?/lib/?' SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export HDF5_DIR="${SCRIPT_DIR}" export HDF5_ROOT="${HDF5_DIR}" add_path PATH "${HDF5_DIR}/bin" add_path DYLD_LIBRARY_PATH "${HDF5_DIR}/lib" </source> Now for netCDF, which you can get from ftp://ftp.unidata.ucar.edu/pub/netcdf . The standard package builds only the C interface: tar xvzf netcdf-4.2.1.tar.g cd netcdf-4.2.1 source /opt/hdf5-1.8.9/setenv.sh export CPPFLAGS="-I$HDF5_DIR/include" export LDFLAGS="-L$HDF5_DIR/lib" ./configure --prefix=/opt/netcdf-4.2.1 --disable-dap --disable-doxygen make -j 4 make check sudo make install Here is a setenv.sh script: <source lang=bash> #!/bin/bash source /opt/hdf5-1.8.9/setenv.sh remove_path PATH '/.*/netcdf(-[^/]+)?/bin/?' remove_path DYLD_LIBRARY_PATH '/.*/netcdf(-[^/]+)?/lib/?' remove_path PYTHONPATH '/.*/netcdf(-[^/]+)?/lib/?' SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export NETCDF4_DIR="${SCRIPT_DIR}" add_path PATH "${NETCDF4_DIR}/bin" add_path DYLD_LIBRARY_PATH "${NETCDF4_DIR}/lib" add_path PYTHONPATH "${NETCDF4_DIR}/lib/python2.7/site-packages" </source> Now for the fortran interface: tar xvzf netcdf-fortran-4.2.tar.gz cd netcdf-fortran-4.2 source /opt/netcdf-4.2.1/setenv.sh export FC=/opt/local/bin/gfortran-mp-4.4 export CPPFLAGS="-I$NETCDF4_DIR/include -I$HDF5_DIR/include -DgFortran" Note that the -DgFortran part is to ensure correct name mangling in Fortran. See http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg09206.html . A future version may not require this. export LDFLAGS="-L$NETCDF4_DIR/lib -L$HDF5_DIR/lib" ./configure --prefix=/opt/netcdf-4.2.1 make -j 4 make check sudo make install For the python module netcdf4-python from http://code.google.com/p/netcdf4-python/ , I needed to make a link gcc-4.2 as follows (OS-X 10.7 only): cd /usr/bin sudo ln -s gcc-4.2 llvm-gcc-4.2 Then some usual stuff: tar xvzf netCDF4-1.0fix1.tar.gz mv netCDF4-1.0 netCDF4-python-1.0 # Rename to something more informative cd netCDF4-python-1.0 source /opt/netcdf-4.2.1/setenv.sh Now it turns out that with HDF 1.8.9 and python netCDF 1.0 we need to fix up the setup.py script a bit: <source lang=diff> *** setup.py.old 2012-07-11 09:40:08.603064046 -0700 --- setup.py 2012-07-11 09:40:17.566869824 -0700 *************** *** 21,26 **** --- 21,28 ---- for line in f: if line.startswith('#define H5_VERSION'): hdf5_version = line.split()[2] + elif line.startswith('#define VERSION'): + hdf5_version = line.split()[2] return hdf5_version def check_ifnetcdf4(netcdf4_includedir): </source> The build continues: python setup.py build sudo bash source /opt/netcdf-4.2.1/setenv.sh python setup.py install --prefix=/opt/netcdf-4.2.1 exit
Summary:
Please note that all contributions to bone.wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BoneWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
associated-pages
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Documents
Recent changes
Help
Tools
What links here
Related changes
Page information