Skip to content

Comments

add support for non-static libnetcdff compilation#203

Open
bakamotokatas wants to merge 1 commit intowrf-model:developfrom
bakamotokatas:patch-1
Open

add support for non-static libnetcdff compilation#203
bakamotokatas wants to merge 1 commit intowrf-model:developfrom
bakamotokatas:patch-1

Conversation

@bakamotokatas
Copy link
Contributor

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.

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.
@HathewayWill
Copy link

@bakamotokatas I agree this would be more useful and streamlines the building of WRF and WPS

@mgduda mgduda requested review from islas and mgduda April 22, 2025 03:23
Copy link
Contributor

@islas islas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants