Skip to content

Commit fd0875c

Browse files
author
meihuisu
committed
merge the linking of netcdf and hdf5 libraries
1 parent 42ef71f commit fd0875c

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

configure.ac

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,18 +301,37 @@ AC_ARG_WITH([proj-lib-path],
301301
[PROJ_LIB="-lproj -lpthread"])
302302

303303
# Get optional netCDF library and include locations
304+
##if test "x$enable_netcdf" = xyes; then
305+
## AC_ARG_WITH([netcdf-include-path],
306+
## [AS_HELP_STRING([--with-netcdf-include-path],
307+
## [location of the netCDF headers])],
308+
## [NETCDF_INCL="-I$withval"],
309+
## [NETCDF_INCL=""])
310+
## AC_ARG_WITH([netcdf-lib-path],
311+
## [AS_HELP_STRING([--with-netcdf-lib-path], [location of the netCDF libraries])],
312+
## [NETCDF_LIB="-L$withval -lnetcdf -lhdf5 -lm -lz -ldl -lxml2"],
313+
## [NETCDF_LIB=" -lnetcdf -lhdf5 -lm -lz -ldl -lxml2"])
314+
##fi XX
315+
#
304316
if test "x$enable_netcdf" = xyes; then
305-
AC_ARG_WITH([netcdf-include-path],
306-
[AS_HELP_STRING([--with-netcdf-include-path],
307-
[location of the netCDF headers])],
308-
[NETCDF_INCL="-I$withval"],
309-
[NETCDF_INCL=""])
310-
AC_ARG_WITH([netcdf-lib-path],
311-
[AS_HELP_STRING([--with-netcdf-lib-path], [location of the netCDF libraries])],
312-
[NETCDF_LIB="-L$withval -lnetcdf -lm -ldl -lxml2 -lcurl"],
313-
[NETCDF_LIB="-lnetcdf -lm -ldl -lxml2 -lcurl"])
317+
AC_ARG_WITH([netcdf-include-path],
318+
[AS_HELP_STRING([--with-netcdf-include-path],[location of NetCDF headers])],
319+
[NETCDF_INCL="-I$withval"],
320+
[NETCDF_INCL=""])
321+
322+
AC_ARG_WITH([netcdf-lib-path],
323+
[AS_HELP_STRING([--with-netcdf-lib-path],[location of NetCDF libraries])],
324+
[NETCDF_LIB="-L$withval -lnetcdf"],
325+
[NETCDF_LIB="-lnetcdf"])
326+
327+
# Optional: HDF5 support if NetCDF-4 is enabled
328+
AC_ARG_WITH([netcdf-extra-libs],
329+
[AS_HELP_STRING([--netcdf-extra-libs],[location of NetCDF extra libraries, ie hdf5])],
330+
[NETCDF_EXTRALIBS="-L$withval -lhdf5 -lhdf5_hl -lz -ldl -lm -lxml2"],
331+
[NETCDF_EXTRALIBS=""])
314332
fi
315333

334+
316335
# Get optional HDF5 library and include locations
317336
if test "x$enable_hdf5" = xyes; then
318337
AC_ARG_WITH([hdf5-include-path],
@@ -961,20 +980,19 @@ AC_CHECK_LIB(proj, proj_create_crs_to_crs, [AC_CHECK_HEADER([proj.h], [], [AC_MS
961980
# ], [AC_INCLUDES_DEFAULT])],[AC_MSG_ERROR(["Curl library not found; use --with-curl-lib-path"])], [???? -lssl -lcrypto])
962981

963982

964-
# Check optional NetCDF library
983+
## Check optional NetCDF library
965984
if test "x$enable_netcdf" = xyes; then
966985
echo "Checking for NetCDF library"
967986
CFLAGS="$NETCDF_INCL $CHECK_CFLAGS"
968-
LDFLAGS="$CHECK_LDFLAGS $NETCDF_LIB"
987+
LDFLAGS="$CHECK_LDFLAGS $NETCDF_LIB $NETCDF_EXTRALIBS"
969988
AC_CHECK_LIB(netcdf, nc_create,
970989
[AM_CONDITIONAL(UCVM_HAVE_NETCDF, true)],
971990
[AC_MSG_ERROR([NetCDF library not found; use --with-netcdf-include-path"])],
972-
[-lm -ldl -lxml2 -lcurl])
991+
[])
973992
AC_CHECK_HEADER(netcdf.h,
974993
[],
975994
[AC_MSG_ERROR([NetCDF header not found; use --with-netcdf-lib-path"])],
976995
[AC_INCLUDES_DEFAULT])
977-
978996
else
979997
AM_CONDITIONAL(UCVM_HAVE_NETCDF, false)
980998
fi
@@ -1001,7 +1019,7 @@ fi
10011019
#
10021020

10031021
CFLAGS="$CHECK_CFLAGS $ETREE_INCL $CURL_INCL $OPENSSL_INCL $PROJ_INCL $FFTW_INCL $NETCDF_INCL $HDF5_INCL"
1004-
LDFLAGS="$CHECK_LDFLAGS $ETREE_LIB $CURL_LIB $OPENSSL_LIB $PROJ_LIB $FFTW_LIB $NETCDF_LIB $HDF5_LIB"
1022+
LDFLAGS="$CHECK_LDFLAGS $ETREE_LIB $CURL_LIB $OPENSSL_LIB $PROJ_LIB $FFTW_LIB $NETCDF_LIB $NETCDF_EXTRALIBS $HDF5_LIB"
10051023
LDFLAGS="$LDFLAGS -lm"
10061024

10071025
# Check optional USGS CenCalVM installation

setup/note

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ GENERAL:
1212

1313
Preprocess: Action dependency (example: bring in external code)
1414

15-
NOTE:
16-
SFCVM
15+
1716

17+
NOTE:

setup/setup.list

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@
436436
"Path": "netcdf",
437437
"Lib": "netcdf-c-4.9.2",
438438
"URL": "https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netcdf-c-4.9.2.tar.gz",
439-
"Required": "no",
439+
"Required": "yes",
440+
"Libraries": ["hdf5"],
440441
"Prerequisites": "Dynamic",
441-
"oConfigureFlags": "--disable-byterange",
442-
"ConfigureFlags": "--disable-byterange --disable-hdf5",
442+
"ConfigureFlags": "--enable-shared --disable-static --enable-netcdf4 --disable-dap --disable-byterange --disable-doxygen CPPFLAGS='-I${UCVM_INSTALL_PATH}/lib/hdf5/include' LDFLAGS='-L${UCVM_INSTALL_PATH}/lib/hdf5/lib -Wl,-rpath,${UCVM_INSTALL_PATH}/lib/hdf5/lib' PKG_CONFIG_PATH='${UCVM_INSTALL_PATH}/lib/hdf5/lib/pkgconfig:${PKG_CONFIG_PATH}'",
443443
"oUCVMConfigureFlags": "--enable-netcdf --with-netcdf-include-path=${UCVM_INSTALL_PATH}/lib/netcdf/include --with-netcdf-lib-path=${UCVM_INSTALL_PATH}/lib/netcdf/lib",
444444
"UCVMConfigureFlags": "--with-netcdf-include-path=${UCVM_INSTALL_PATH}/lib/netcdf/include --with-netcdf-lib-path=${UCVM_INSTALL_PATH}/lib/netcdf/lib",
445445
"md5sum": "f48ee01534365006934f0c63d4055ea0",

src/ucvm2mesh/mesh2hdf5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
mesh2hdf5.c
33
4+
to mimick geomodelgrids' hdf5 file
45
**/
56

67
#include <stdio.h>

ucvm_setup.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,18 @@ def installConfigMakeInstall(tarname, ucvmpath, type, config_data):
280280

281281
createInstallTargetPath( ucvmpath + "/" + pathname + "/" + config_data["Path"])
282282

283+
## mainly to pass environment variable available in setup.list environment
284+
## to the configure environment
283285
if "ConfigureEnv" in config_data.keys():
284286
needs_env = config_data["ConfigureEnv"]
285287
else:
286288
needs_env = []
287289

288290
if "ConfigureFlags" in config_data and config_data["ConfigureFlags"] != "" :
289-
configure_array += config_data["ConfigureFlags"].split(" ")
291+
tmp = config_data["ConfigureFlags"].split(" ")
292+
configure_array +=shlex.split(config_data["ConfigureFlags"])
290293
elif "Libraries" in config_data:
294+
## this is to work with our embedded libraries being installed in UCVM_INSTALL_PATH
291295
needs_array = config_data["Libraries"]
292296
if "euclid3" in needs_array:
293297
configure_array.append("--with-etree-lib-path=" + ucvmpath + "/lib/euclid3/lib")
@@ -296,8 +300,11 @@ def installConfigMakeInstall(tarname, ucvmpath, type, config_data):
296300
configure_array.append("--with-proj-lib-path=" + ucvmpath + "/lib/proj/lib")
297301
configure_array.append("--with-proj-include-path=" + ucvmpath + "/lib/proj/include")
298302
if "netcdf" in needs_array:
299-
configure_array.append("LDFLAGS=-L" + ucvmpath + "/lib/netcdf/lib")
300-
configure_array.append("CPPFLAGS=-I" + ucvmpath + "/lib/netcdf/include")
303+
configure_array.append("LDFLAGS=-L" + ucvmpath + "/lib/netcdf/lib -L" + ucvmpath + "/lib/hdf5/lib")
304+
configure_array.append("CPPFLAGS=-I" + ucvmpath + "/lib/netcdf/include -I" + ucvmpath + "/lib/hdf5/include")
305+
if "hdf5" in needs_array:
306+
configure_array.append("LDFLAGS=-L" + ucvmpath + "/lib/hdf5/lib")
307+
configure_array.append("CPPFLAGS=-I" + ucvmpath + "/lib/hdf5/include")
301308

302309
## special case ??
303310
if config_data["Path"] == "cencal":
@@ -1030,11 +1037,11 @@ def _addPROJ_LIB_python() :
10301037
if use_iobuf == True:
10311038
ucvm_conf_command.append("--enable-iobuf")
10321039

1033-
#if "NetCDF" in librariesToInstall:
1034-
# ucvm_conf_command.append("--enable-netcdf")
1035-
# ucvm_conf_command.append("--with-netcdf-include-path=" + ucvmpath + "/lib/netcdf/include")
1036-
# ucvm_conf_command.append("--with-netcdf-lib-path=" + ucvmpath + "/lib/netcdf/lib")
1037-
# ucvm_conf_command.append("LDFLAGS=-L" + ucvmpath + "/lib/hdf5/lib")
1040+
if "NetCDF" in librariesToInstall:
1041+
ucvm_conf_command.append("--enable-netcdf")
1042+
ucvm_conf_command.append("--with-netcdf-include-path=" + ucvmpath + "/lib/netcdf/include")
1043+
ucvm_conf_command.append("--with-netcdf-lib-path=" + ucvmpath + "/lib/netcdf/lib")
1044+
ucvm_conf_command.append("--with-netcdf-extra-libs=" + ucvmpath + "/lib/hdf5/lib")
10381045

10391046
#ucvm_conf_command.append("UCVM_INSTALL_PATH=" + ucvmpath)
10401047

0 commit comments

Comments
 (0)