add support for non-static libnetcdff compilation#203
Open
bakamotokatas wants to merge 1 commit intowrf-model:developfrom
Open
add support for non-static libnetcdff compilation#203bakamotokatas wants to merge 1 commit intowrf-model:developfrom
bakamotokatas wants to merge 1 commit intowrf-model:developfrom
Conversation
Although libnetcdff.so is now supported in the WRF configuration file, it has not been added to WPS. When libnetcdff.a is not present, it needs to be changed to libnetcdff.so every time. Now, with this change, WPS can be compiled with netcdf libraries that are not statically compiled, without making any changes to WPS.
|
@bakamotokatas I agree this would be more useful and streamlines the building of WRF and WPS |
islas
approved these changes
Apr 25, 2025
Contributor
There was a problem hiding this comment.
This appropriately fixes compilation when using shared libraries of netCDF.
With the current develop (excerpt):
gfortran -o geogrid.exe cio.o wrf_debug.o bitarray_module.o constants_module.o module_stringutil.o geogrid.o gridinfo_module.o hash_module.o interp_module.o list_module.o llxy_module.o misc_definitions_module.o module_debug.o module_map_utils.o output_module.o parallel_module.o process_tile_module.o proc_point_module.o queue_module.o read_geogrid.o smooth_module.o source_data_module.o \
/home/aislas/wrf-model/wrf/frame/module_driver_constants.o \
/home/aislas/wrf-model/wrf/frame/pack_utils.o /home/aislas/wrf-model/wrf/frame/module_machine.o \
/home/aislas/wrf-model/wrf/frame/module_internal_header_util.o \
-I/home/aislas/wrf-model/wrf/external/io_netcdf -I/home/aislas/wrf-model/wrf/external/io_grib_share -I/home/aislas/wrf-model/wrf/external/io_grib1 -I/home/aislas/wrf-model/wrf/external/io_int -I/home/aislas/wrf-model/wrf/inc -I/home/aislas/dependencies/netcdf_for_wrf//include \
-L/home/aislas/wrf-model/wrf/external/io_grib1 -lio_grib1 -L/home/aislas/wrf-model/wrf/external/io_grib_share -lio_grib_share -L/home/aislas/wrf-model/wrf/external/io_int -lwrfio_int -L/home/aislas/wrf-model/wrf/external/io_netcdf -lwrfio_nf -L/home/aislas/dependencies/netcdf_for_wrf//lib -lnetcdf \
/usr/bin/ld: /home/aislas/wrf-model/wrf/external/io_netcdf/libwrfio_nf.a(wrf_io.o): in function `__ext_ncd_support_routines_MOD_netcdf_err.part.0':
wrf_io.f:(.text+0x3c): undefined reference to `nf_strerror_'
...many more nf_* errors...
/usr/bin/ld: field_routines.f:(.text+0x89): undefined reference to `nf_get_vara_real_'
/usr/bin/ld: /home/aislas/wrf-model/wrf/external/io_netcdf/libwrfio_nf.a(field_routines.o): in function `ext_ncd_doublefieldio_':
field_routines.f:(.text+0x1b6): undefined reference to `nf_put_vara_double_'
/usr/bin/ld: field_routines.f:(.text+0x1e9): undefined reference to `nf_get_vara_double_'
/usr/bin/ld: /home/aislas/wrf-model/wrf/external/io_netcdf/libwrfio_nf.a(field_routines.o): in function `ext_ncd_intfieldio_':
field_routines.f:(.text+0x316): undefined reference to `nf_put_vara_int_'
/usr/bin/ld: field_routines.f:(.text+0x349): undefined reference to `nf_get_vara_int_'
/usr/bin/ld: /home/aislas/wrf-model/wrf/external/io_netcdf/libwrfio_nf.a(field_routines.o): in function `ext_ncd_logicalfieldio_':
field_routines.f:(.text+0x7c6): undefined reference to `nf_put_vara_int_'
/usr/bin/ld: field_routines.f:(.text+0x8fb): undefined reference to `nf_get_vara_int_'
collect2: error: ld returned 1 exit status
make[1]: [Makefile:13: geogrid.exe] Error 1 (ignored)
make[1]: Leaving directory '/home/aislas/wrf-model/wps_base/geogrid/src'
With these changes (analogous excerpt):
read_geogrid.c: In function ‘read_geogrid_’:
read_geogrid.c:124:62: warning: left shift count >= width of type [-Wshift-count-overflow]
124 | if ((*isigned) && (ival > (1 << 31))) ival -= (1 << 32);
| ^~
gfortran -o geogrid.exe cio.o wrf_debug.o bitarray_module.o constants_module.o module_stringutil.o geogrid.o gridinfo_module.o hash_module.o interp_module.o list_module.o llxy_module.o misc_definitions_module.o module_debug.o module_map_utils.o output_module.o parallel_module.o process_tile_module.o proc_point_module.o queue_module.o read_geogrid.o smooth_module.o source_data_module.o \
/home/aislas/wrf-model/wrf/frame/module_driver_constants.o \
/home/aislas/wrf-model/wrf/frame/pack_utils.o /home/aislas/wrf-model/wrf/frame/module_machine.o \
/home/aislas/wrf-model/wrf/frame/module_internal_header_util.o \
-I/home/aislas/wrf-model/wrf/external/io_netcdf -I/home/aislas/wrf-model/wrf/external/io_grib_share -I/home/aislas/wrf-model/wrf/external/io_grib1 -I/home/aislas/wrf-model/wrf/external/io_int -I/home/aislas/wrf-model/wrf/inc -I/home/aislas/dependencies/netcdf_for_wrf//include \
-L/home/aislas/wrf-model/wrf/external/io_grib1 -lio_grib1 -L/home/aislas/wrf-model/wrf/external/io_grib_share -lio_grib_share -L/home/aislas/wrf-model/wrf/external/io_int -lwrfio_int -L/home/aislas/wrf-model/wrf/external/io_netcdf -lwrfio_nf -L/home/aislas/dependencies/netcdf_for_wrf//lib -lnetcdff -lnetcdf \
make[1]: Leaving directory '/home/aislas/wrf-model/wps_base/geogrid/src'
This was tested with the following $NETCDF/lib/ contents:
cmake/
libnetcdff.settings
libnetcdff.so -> libnetcdff.so.7*
libnetcdff.so.7 -> libnetcdff.so.7.1.0*
libnetcdff.so.7.1.0*
libnetcdf.settings
libnetcdf.so -> libnetcdf.so.19*
libnetcdf.so.19*
pkgconfig/
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.
Although libnetcdff.so is now supported in the WRF configuration file, it has not been added to WPS. When libnetcdff.a is not present, it needs to be changed to libnetcdff.so every time. Now, with this change, WPS can be compiled with netcdf libraries that are not statically compiled, without making any changes to WPS.