WRF icon indicating copy to clipboard operation
WRF copied to clipboard

Should WRF/Makefile pass the NETCDF4_DEP_LIB to external/io_netcdf/makefile?

Open Roadelse opened this issue 1 year ago • 5 comments

I was compiling WRF and encounter the error of "undefined H5... " in producing external/io_netcdf/diffwrf. I find the detailed statement doesn't contain "-lhdf5_hl -lhdf5", and the NETCDF4_DEP_LIB in external/io_netcdf/makefile is empty. Since the NETCDF4_DEP_LIB in WRF/Makefile is an internal variable rather than environment variable, it will not be inherited when calling a "make" in some places. When I added NETCDF4_DEP_LIB=$(NETCDF4_DEP_LIB) to this statement ($(MAKE) ... ... diffwrf, near Line 927 of WRF/Makefile):

$(MAKE) NETCDFPATH="$(NETCDFPATH)" \
               FC="$(FC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \
               CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \
               LIB_LOCAL="$(LIB_LOCAL)" \
               ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR" diffwrf; \

the compilation then work correctly.

Roadelse avatar Dec 05 '23 09:12 Roadelse

I forgot to say, the version is WRF 4.5.1

Roadelse avatar Dec 05 '23 09:12 Roadelse

@islas Do you think PR#1935 would address this?

weiwangncar avatar Dec 05 '23 09:12 weiwangncar

@weiwangncar Not exactly but it is in the same scope of issue - NETCDF4_DEP_LIB as it is written right now tries to do a lot of extra logic that nc-config --libs already provides. Ideally we should only be using nc-config --libs to inform any netCDF linkage and not providing anything on top of that.

The way this affects this issue is that NETCDF4_DEP_LIB is being used as a stand-in for nc-config --libs in a particular area where -lnetcdf is being used.

islas avatar Dec 05 '23 20:12 islas

considering the line in external/io_netcdf/makefile : LIBFFS = $(LIB_LOCAL) -L$(NETCDFPATH)/lib -lnetcdff -lnetcdf $(NETCDF4_DEP_LIB) however, the $(NETCDF4_DEP_LIB) just makes no sense since it is empty if we don't pass the variable to it, when calling this makefile from WRF/Makefile

Roadelse avatar Dec 06 '23 01:12 Roadelse

Going through PRs for v4.5.2, I realized #1923 should solve this. It also slightly addresses my previous point of better utilizing nc-config --libs as the main way to link in netCDF

islas avatar Dec 07 '23 19:12 islas