Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Roadelse opened this issue Dec 5, 2023 · 5 comments
Assignees

Comments

@Roadelse
Copy link

Roadelse commented Dec 5, 2023

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
Copy link
Author

Roadelse commented Dec 5, 2023

I forgot to say, the version is WRF 4.5.1

@weiwangncar
Copy link
Collaborator

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

@islas
Copy link
Collaborator

islas commented Dec 5, 2023

@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.

@Roadelse
Copy link
Author

Roadelse commented Dec 6, 2023

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

@islas
Copy link
Collaborator

islas commented Dec 7, 2023

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

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

No branches or pull requests

4 participants