Add optional netcdf/hdf5-free, library-only build - #2
Open
rljacob wants to merge 1 commit into
Open
Conversation
Add a --disable-netcdf configure option that builds libTempestRemap with no NetCDF or HDF5 dependency. The default build is unchanged. NetCDF is required by default, and HDF5 comes along with it transitively: config/netcdf.m4 does AC_REQUIRE([ACX_HDF5]) and folds $HDF5_LIBS into NETCDF_LIBS, since netCDF-4 files are HDF5 containers. Skipping ACX_NETCDF therefore drops both dependencies at once. The numerical core is already netcdf-independent in its logic: mesh generation into in-memory Mesh objects, overlap-mesh construction, FV/SE weight generation, and the sparse-matrix apply/analysis in OfflineMap. NetCDF is confined to the vendored netcdf-cxx-4.2 files, the file-I/O methods of GridElements/OfflineMap/NetCDFUtilities, the write tails of the generators, and NcFile::FileFormat leaking into public signatures. Those are now guarded by TEMPEST_NETCDF. Because every file format here is NetCDF-based (Exodus/SCRIP/UGRID meshes, SCRIP map files), --disable-netcdf implies a library-only build: no command-line tools are produced and the library does in-memory remapping only. Downstream users feed and extract data through the Mesh/OfflineMap API; the ...WithMeshes API variants are the netcdf-free entry points, while the file-path variants are guarded out. Where a caller passes an output filename to such a build, the guarded path raises an exception naming the option instead of silently ignoring the request. Supporting changes: - Defines.h now includes the generated TempestConfig.h. It was previously never included anywhere, so an AC_DEFINE'd macro would have been invisible; routing it through Defines.h also makes TEMPEST_NETCDF self-carrying for consumers of the installed headers, so they cannot see a different API surface than the library was built with. - OVERLAPMESH_USE_UNSORTED_MAP is now an #ifndef fallback in Defines.h, since configure also defines it and TempestConfig.h is now included. - Add missing <iostream> to LinearRemapFV.cpp and <climits>/<iostream> to OfflineMap.cpp. Both relied on netcdfcpp.h to supply these transitively. - GenerateRectilinearMeshFromFile.cpp moves to the netcdf-only source list; it derives the mesh from a NetCDF input file, so unlike the other generators it has no in-memory-only behavior. Verified both configurations: the default build compiles clean with all 26 tools and a working remap pipeline; --disable-netcdf compiles clean, builds no executables, and yields an archive with zero netcdf/hdf5 undefined symbols. A test program linking only the netcdf-free library (confirmed by ldd to pull in neither) generates meshes, builds the overlap mesh, and produces FV-to-FV weights identical to the default build, with no consistency or conservation violations. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds an optional Autotools library-only build without NetCDF/HDF5.
Changes:
- Adds
--disable-netcdfconfiguration and conditional build targets. - Guards NetCDF-dependent APIs and file I/O.
- Adds direct standard-library includes previously supplied transitively.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
configure.ac |
Adds the NetCDF build option. |
Makefile.am |
Conditionally builds NetCDF sources and tools. |
src/Defines.h |
Includes generated feature configuration. |
src/TempestRemapAPI.h |
Conditionally exposes NetCDF APIs. |
src/GridElements.h |
Guards mesh file-I/O declarations. |
src/GridElements.cpp |
Guards mesh file-I/O implementations. |
src/OfflineMap.h |
Guards map file-I/O declarations. |
src/OfflineMap.cpp |
Guards map file-I/O implementations. |
src/LinearRemapFV.cpp |
Adds the direct iostream dependency. |
src/GenerateCSMesh.cpp |
Handles unavailable NetCDF output. |
src/GenerateGLLMetaData.cpp |
Guards file-based metadata generation. |
src/GenerateICOMesh.cpp |
Handles unavailable NetCDF output. |
src/GenerateLambertConfConicMesh.cpp |
Handles unavailable NetCDF output. |
src/GenerateOfflineMap.cpp |
Separates in-memory mapping from file I/O. |
src/GenerateOverlapMesh.cpp |
Retains in-memory overlap generation. |
src/GenerateOverlapMesh_v1.cpp |
Guards the file-based legacy API. |
src/GenerateRLLMesh.cpp |
Guards NetCDF input and output. |
src/GenerateStereographicMesh.cpp |
Handles unavailable NetCDF output. |
src/GenerateTransectMesh.cpp |
Handles unavailable NetCDF output. |
src/GenerateUTMMesh.cpp |
Handles unavailable NetCDF output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // TEMPEST_NETCDF visible both when building TempestRemap and to downstream | ||
| // consumers of the installed headers, so that both see the same API surface. | ||
| // | ||
| #include "TempestConfig.h" |
| bool fgll; | ||
| }; | ||
|
|
||
| #if defined(TEMPEST_NETCDF) |
Collaborator
There was a problem hiding this comment.
I can verify that this is a valid comment and fails during MOAB configure/linkage. I'm fixing MOAB but this should not even be exposed when netcdf is disabled. @rljacob
Comment on lines
+900
to
+902
| _EXCEPTIONT("Cannot write map file: TempestRemap was built without " | ||
| "NetCDF support (--disable-netcdf). The offline map is available " | ||
| "in the \"mapRemap\" argument."); |
Collaborator
|
This is pretty good. Will test this today and cross-check with the MOAB link. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
--disable-netcdfconfigure option that buildslibTempestRemapwith no NetCDF or HDF5 dependency. The default build is unchanged — this is purely additive.Why disabling NetCDF also drops HDF5
configure.acnever mentions HDF5, butconfig/netcdf.m4doesAC_REQUIRE([ACX_HDF5])and folds$HDF5_LIBSintoNETCDF_LIBS— netCDF-4 files are HDF5 containers, so the probe fornc_inq_libverslinks HDF5 too. SkippingACX_NETCDFtherefore drops both dependencies at once.Approach
The numerical core is already netcdf-independent in its logic: mesh generation into in-memory
Meshobjects, overlap-mesh construction, FV/SE weight generation, and the sparse-matrix apply/analysis inOfflineMap. NetCDF is confined to the vendored netcdf-cxx-4.2 files, the file-I/O methods ofGridElements/OfflineMap/NetCDFUtilities, the write tails of the generators, andNcFile::FileFormatleaking into public signatures. Those are now guarded byTEMPEST_NETCDF.Scope: library-only, in-memory remapping
Because every file format here is NetCDF-based (Exodus/SCRIP/UGRID meshes, SCRIP map files),
--disable-netcdfimplies a library-only build: no command-line tools are produced, and the library does in-memory remapping only. Downstream users (e.g. MOAB) feed and extract data through theMesh/OfflineMapAPI — the...WithMeshesvariants are the netcdf-free entry points, while the file-path variants are guarded out.Where a caller passes an output filename to such a build, the guarded path raises an exception naming the option rather than silently ignoring the request.
Supporting changes
Defines.hnow includes the generatedTempestConfig.h. It was previously never included anywhere, so anAC_DEFINE'd macro would have been invisible. Routing it throughDefines.halso makesTEMPEST_NETCDFself-carrying for consumers of the installed headers, so they cannot see a different API surface than the library was built with.OVERLAPMESH_USE_UNSORTED_MAPis now an#ifndeffallback, sinceconfigurealso defines it andTempestConfig.his now included.LinearRemapFV.cppusedstd::coutandOfflineMap.cppusedINT_MAX/INT_MIN, both relying onnetcdfcpp.hto supply<iostream>/<climits>transitively. Added direct includes.GenerateRectilinearMeshFromFile.cppmoves to the netcdf-only source list — it derives the mesh from a NetCDF input file, so unlike the other generators it has no in-memory-only behavior.Verification
Both configurations were built and run:
--with-netcdf=/usr --with-hdf5=/usr): compiles clean, all 26 tools built, full CS→RLL overlap→map pipeline produces a working 218 KBmap.nc.--disable-netcdf): compiles clean, no executables, andnmreports zero netcdf/hdf5 undefined symbols in the archive.lddconfirms neither is pulled in): generates CS + RLL meshes, builds the overlap mesh, and produces FV→FV weights (8584 nnz, 200×384) identical to the default build's, with 0 consistency and 0 conservation violations; applying the operator to a constant field returns exactly 1.0.make distfrom a--disable-netcdftree still ships all conditional sources and all 23 test scripts, so the tarball stays configure-independent.Note for reviewers
The
Makefile.gmake/mk/legacy HPC build is intentionally untouched; this option is autotools-only. One judgment call worth a look: the file-path API variants (GenerateOfflineMap,GenerateOverlapMesh,GenerateGLLMetaData,GenerateOverlapMesh_v1) are guarded out since they read from disk at entry. If a downstream consumer depends on one of those signatures, that's the piece to revisit.🤖 Generated with Claude Code