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

Compiling with alternative netCDF libs

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

bartbrashers

New member
I'm trying to compile WRF-4.1.3 on CentOS 7.4 with netCDF libs that are different from the defaults for the system (which are defined in /etc/profile.d/netcdf.csh). Here's my compile script:
Code:
# cat my.compile 
#!/bin/csh -f
setenv NETCDF     /usr/local/src/wrf/netcdf-4.3.0/build
setenv NETCDFHOME $NETCDF
setenv NETCDF_DIR $NETCDF

if !($?LD_LIBRARY_PATH) then
    setenv LD_LIBRARY_PATH $NETCDF_DIR/lib
else
    if ( "$LD_LIBRARY_PATH" !~ *$NETCDF_DIR/lib* ) then
        setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$NETCDF_DIR/lib
    endif
endif

setenv NETCDF4 0
setenv WRFIO_NCD_LARGE_FILE_SUPPORT 1

echo "Cleaning"
clean -a >& /dev/null
if (-e my.configure.wrf) then
    cp my.configure.wrf configure.wrf
    echo "Using existing my.configure.wrf"
else
    configure
    cp configure.wrf my.configure.wrf
    echo "Edit my.configure.wrf and re-run $0:t"
    exit
endif
echo "Compiling"
./compile em_real >&! compile.out.`date +%Y-%m-%d`
echo "Done"

I've set the correct paths in configure.wrf:
Code:
# grep /usr/local my.configure.wrf
                      -L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/loca/src/wrf/netcdf-4.3.0/build/lib -lnetcdff -lnetcdf  -L/usr/local/src/hdf5-1.8.20.pgi.sandybridge/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz
NETCDFPATH      =    /usr/local/src/wrf/netcdf-4.3.0/build
HDF5PATH        =    /usr/local/src/hdf5-1.8.20.pgi.sandybridge

After it's done, ldd says:
Code:
# ldd run/wrf.exe | grep netcdf
        libnetcdff.so.5 => not found
        libnetcdf.so.7 => not found

Do I have to manipulate $LD_LIBRARY_PATH to eliminate the system version?
Code:
# echo $LD_LIBRARY_PATH | tr ":" "\n"
/usr/local/src/szip-2.1.1/lib
/usr/local/lib
/opt/ohpc/pub/compiler/gcc/7.3.0/lib64
/usr/local/src/hdf5-1.8.20.pgi/lib
/usr/local/src/netcdf-c-4.7.2.pgi.sandybridge/build/lib
/usr/local/pgi/linux86-64/2019/lib
/usr/local/pgi/linux86-64/2019/libso
/usr/lib64
/usr/local/src/netcdf-c-4.7.2.pgi.sandybridge/build/lib

Any hints for me as to what I'm missing in my compile script?
 
Hi,
Just a couple of questions:
1) Is the netcdf that you are using the separate netcdf-c and netcdf-fortran type, or is it all in one?
2) Was the netcdf that you're trying to use built with the same compiler (and version) you are planning to use to build WRF?
3) Did you get compiling errors? If you have a compile log, can you attach that?
Thanks!
 
Hi,
A couple of answers ;-)
1) Yes, netcdf-4.2.0 and netcdf-fortran-4.2, both configured with the same --prefix.
2) Yes, PGI version 19.10-0, the nollvm version. The llvm version has a compiler bug that prevents compilation of WRF-4.1.3. See https://www.pgroup.com/userforum/viewtopic.php?f=4&t=6831&p=27070&hilit=WRF#p27070.
3) No errors. I grepped for the PGI error codes (PGC-E and PGF-E).

I tried with more recent versions of the netCDF libs, with and without HDF5, and found I had to change /etc/profile.d/netcdf.csh to get ldd run/wrf.exe to report using the correct ones.

This is one small step in a larger effort to track down a memory leak in metgrid.exe. A 6-day run (using 6-hour inputs) keeps increasing the virtual memory usage (as reported by top) until both physical memory and swap are used up, then the process gets killed. One of my libs must be bad, so I'm trying to figure out which one, step-by-step.

Thanks!
 
Hi,
Thanks for that information.

I tried with more recent versions of the netCDF libs, with and without HDF5, and found I had to change /etc/profile.d/netcdf.csh to get ldd run/wrf.exe to report using the correct ones.
Does this mean that you were able to get past the original problem mentioned on the first post?
 
Top