Correct issues with netCDF library linking and loading in mesh_tools/grid_rotate
#556
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.
This PR makes changes to the
Makefile
for thegrid_rotate
tool to address issues with netCDF library linking and loading.Prior to this PR, the
grid_rotate
program'sMakefile
assumed that the output ofnf-config --flibs
was sufficient to provide all library linking flags related to the netCDF library. In netCDF-Fortran 4.6.1, however, thenf-config --flibs
output includes the netCDF-C library (-lnetcdf
), but it does not include the library search path for this library, leading to compilation errors likeAs a workaround, this PR adds
-L$(shell nc-config --libdir)
to the definition ofFCLIBS
in theMakefile
.Even after addressing linking errors, on systems that provide netCDF shared libraries, it was in some cases still necessary
to manually set the
LD_LIBRARY_PATH
environment variable to ensure that the netCDF libraries could be found by the loader. To work around this issue, theMakefile
now tries to extract linker rpath flags from the output ofnf-config --flibs
andnc-config --libs
. These flags are stored in theRPATH_FLAGS
make variable, which is then appended to theFCLIBS
variable. With the search paths for the netCDF shared libraries included in thegrid_rotate
executable, it should no longer be necessary to manipulate theLD_LIBRARY_PATH
environment variable.