Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

WRF hindered compilation by netCDF and curl issues when using gcc and gfortran

Hello WRF community! I've been stuck on compiling issues for a week and I'm reaching out as none of the solutions I've tried so far seem to work.

I am trying to compile WRF in a WSL that runs Ubuntu 22.04.5. I followed the steps in the WRF Tutorial after setting up the machine with

Code:
$ sudo apt-get update
$ sudo apt-get install -y build-essential csh gfortran m4 curl perl mpich libhdf5-mpich-dev libpng-dev netcdf-bin libnetcdff-dev libxml2-dev

The system passed all the tests suggested in the WRF Tutorial.

Following this, I came across the issues with the compilation of netCDF-c v 4.7.2 and followed the recommendations here as the error was similar. However, as pointed out at the end of the thread, the change of $CC -V for $CC -v and the commenting out of the section for tests did not work either.

Digging further, a more recent post suggests a work around by modifying the FFLAGS and FCFLAGS (recommended here) to ensure compatibility with legacy Fortran code. This seemed to solve the issue and netCDF-c v 4.7.2 and netcdf-fortran v 4.5.2 compiled (the current -Sep 2024- suggested versions in the tutorial). All the other libraries compiled with no issues (i.e., zlib, lipbng and jasper). The environment variables that I used throughout the process are in the attached file "variables.txt" file and follow the recommendations made by another post in this forum ("Build_WRF_GNU_Environment.pdf"). Note that I have not tried to compile HDF5 as suggested in the pdf file attached based on the fact that the WRF tutorial does not consider it.

However, WRF compilation failed and upon inspecting the log file the error seemed to be related with a faulty compilation of netCDF - see error below

Code:
F90:2201: undefined reference to `nc_set_var_chunk_cache_ints'
collect2: error: ld returned 1 exit status
Command exited with non-zero status 1
0.03user 0.04system 0:00.11elapsed 66%CPU (0avgtext+0avgdata 17812maxresident)k
0inputs+0outputs (0major+7242minor)pagefaults 0swaps
make[2]: [makefile:45: diffwrf] Error 1 (ignored)

Moving forward, I decided to clean the entire WSL set-up, begin again and update the netCDF-c and fortran to the later versions 4.9.2 and 4.6.1 respectively. The compilation of netCDF remains faulty although dependencies are created in the netcdf/ folder. Plagued with errors (see attached the config_netCDFc.log) both netCDF c and fortran compiled, and I wanted to explore further what would the error be in WRF. Clearly it does not compile, but it also gives another error related with curl (inherited from the faulty netCDF compilation?):

Code:
/usr/bin/ld: /mnt/d/Build_WRF/LIBRARIES/netcdf/lib/libnetcdf.a(libdispatch_la-dhttp.o): undefined reference to symbol 'curl_easy_cleanup@@CURL_OPENSSL_4'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcurl.so.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Command exited with non-zero status 1
0.01user 0.03system 0:00.08elapsed 55%CPU (0avgtext+0avgdata 17896maxresident)k
0inputs+0outputs (0major+7480minor)pagefaults 0swaps

The "compile.WRF.log" file shows a set of errors like the one above.

This is (I think) clearly a set up issue from the start, but I am lost as to how to solve it, as I've tried cleaning all up, but the steps are the same and in turn I keep running into the same problem. So, after this lengthy story, I would really appreciate it ✨:

1) Any suggestion(s) or insight on how to set up the WSL environment properly other than what I've described above.
2) If you can advise on the use of the latest netCDF libraries to compile WRF or if this should be avoided and just the previous versions are the ones to use.
3) If it is preferable to install HDF5 and build netCDF with it
4) The consistency of the environment variables across the compilation of the libraries, I am using the same ones for all but (and this is clearly not my area of expertise) I don't know if they should be changed depending on the library being compiled.

P.D I know that the forum is not supposed to address netCDF issues but I've explored as much as I could on netCDF forums and other places and was hoping that someone here in the community has a better grasp on how to overcome these issues.

Thank you so much for taking the time to read and answer, it is greatly appreciated.

Cheers,
 

Attachments

  • variables.txt
    784 bytes · Views: 2
  • config_netCDFc.log
    178.8 KB · Views: 0
  • compile_WRF.log
    827.5 KB · Views: 2
  • Build_WRF_GNU_Environment.pdf
    65.5 KB · Views: 2
Hi,
I will try to answer your questions the best I can. This is clearly an issue with the environment setup, which can be difficult for us to diagnose. First, regarding the "curl" issue, can you check to see if you have curl installed in the system? Something like 'which curl' should provide a path if you do. If not, try installing that. If it's there, make sure it's also in your PATH. Regarding netCDF and your paths, try printing them out to make sure there isn't some sort of underlying path to another netcdf location that may be at the end of the path, and therefore overriding settings at the beginning of the path.

1) Any suggestion(s) or insight on how to set up the WSL environment properly other than what I've described above.
Unfortunately we don't have any experience with Windows machines, and I do know that sometimes you can have settings in your Linux environment that are being overridden by settings in the Windows environment, which can make this tricky.

2) If you can advise on the use of the latest netCDF libraries to compile WRF or if this should be avoided and just the previous versions are the ones to use.
In theory, any version of netCDF 3 or 4 should be able to work properly.

3) If it is preferable to install HDF5 and build netCDF with it
Unless you're planning to use any of the HDF5 features, like compression, it's not necessary to install HDF5 to be able to build and run WRF, and actually, it could further complicate things for your build if you try to add in another library.

4) The consistency of the environment variables across the compilation of the libraries, I am using the same ones for all but (and this is clearly not my area of expertise) I don't know if they should be changed depending on the library being compiled.
If you're able to get all the libraries installed without errors, then you're probably doing it okay. Typically you only need to set the environment variables once and won't need to change any, but occasionally you may, depending on the system. But these errors typically arise when installing the libraries, so you would know if they were causing any problems.

If you have a systems administrator at your institution that you could ask for help, that would be ideal. They would know a lot more about your specific setup and would hopefully be able to help you to get everything installed.
 
Top