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 4.3.3. Compilation on Ubuntu 21.10

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.


New member
Dear all,

I am trying to compile WRF 4.3.3 on Ubuntu 21.10 with no success. For compilation I am using the following libraries

netcdf version 4.7.4 (Came with distribution)
gcc/gfortran 11.2 (comes with OS)
jasper lib downloaded from Xenial sources

The directories for netcdf and netcdff are in /usr/lib/x86_64-linux-gnu/

The mpich library is in : /usr/lib/x86_64-linux-gnu/

The HDF5 ibrary is in : /usr/lib/x86_64-linux-gnu/hdf5/mpich

During compilation I am getting the following error when wrf.exe is being compiled which than propagates down the compilation

time mpif90  -o wrf.exe  -O2 -ftree-vectorize -funroll-loops -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz    wrf.o ../main/module_wrf_top.o libwrflib.a /home/joseph/WRF/external/fftpack/fftpack5/libfftpack.a /home/joseph/WRF/external/io_grib1/libio_grib1.a /home/joseph/WRF/external/io_grib_share/libio_grib_share.a /home/joseph/WRF/external/io_int/libwrfio_int.a -L/home/joseph/WRF/external/esmf_time_f90 -lesmf_time /home/joseph/WRF/external/RSL_LITE/librsl_lite.a /home/joseph/WRF/frame/module_internal_header_util.o /home/joseph/WRF/frame/pack_utils.o -L/home/joseph/WRF/external/io_netcdf -lwrfio_nf -L/usr/lib -lnetcdff -lnetcdf    -L/home/joseph/WRF/external/io_grib2 -lio_grib2 -L/usr/lib/x86_64-linux-gnu -ljasper  -L/usr/lib/x86_64-linux-gnu/hdf5/mpich/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz    
/usr/bin/ld: /tmp/cc9PtMZs.ltrans21.ltrans.o: in function `__module_wps_io_arw_MOD_read_wps':
<artificial>:(.text+0x1eae6b0): undefined reference to `__module_optional_input_MOD_flag_st000010'
/usr/bin/ld: <artificial>:(.text+0x1eae6bd): undefined reference to `__module_optional_input_MOD_flag_st010040''

The "undefined reference to" error repeats for different nf_ variables and results in a failure. Here are the details of the NetCDF version

This netCDF 4.7.4 has been built with the following features:

--cc -> /usr/bin/cc
--cflags -> -I/usr/include -I/usr/include/hdf5/serial
--libs -> -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf
--static -> -lhdf5_hl -lhdf5 -lpthread -lsz -lz -ldl -lm -lcurl

--has-c++ -> no
--cxx ->

--has-c++4 -> no
--cxx4 ->

--has-fortran -> yes
--fc -> gfortran
--fflags -> -I/usr/include -I/usr/include
--flibs -> -L/usr/lib/x86_64-linux-gnu -lnetcdff
--has-f90 ->
--has-f03 -> yes

--has-dap -> yes
--has-dap2 -> yes
--has-dap4 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--has-hdf5 -> yes
--has-hdf4 -> no
--has-logging -> no
--has-pnetcdf -> no
--has-szlib -> no
--has-cdf5 -> yes
--has-parallel4 -> no
--has-parallel -> no

--prefix -> /usr
--includedir -> /usr/include
--libdir -> /usr/lib/x86_64-linux-gnu
--version -> netCDF 4.7.4

I am attaching the compile log, configure.wrf and details on the


  • configure.wrf
    20.6 KB · Views: 24
  • compile.log
    1.2 MB · Views: 32
It doesn't look like you have the netcdf path set. Before configuring you must set the NETCDF environment variable to the path where all netcdf lib, bin, and include directories are. Take a look at this document to use as a template for ensuring that your environment is set up properly.
Hello !

I have similar problem, I specified export NETCDF="/usr"; export NETCDF_classic=1 and dmpar ;

But got missing libraries, looks like from netcdf-fortran, but nc-config says "--has-fortran -> yes --fc -> gfortran"

wrf_io.f:(.text+0x1c0f5): undefined reference to `nf_open_'
/usr/bin/ld: wrf_io.f:(.text+0x1c12c): undefined reference to `nf_inq_varid_'
/usr/bin/ld: wrf_io.f:(.text+0x1c174): undefined reference to `nf_inq_var_'
/usr/bin/ld: wrf_io.f:(.text+0x1c5f8): undefined reference to `nf_inq_dimlen_'
/usr/bin/ld: wrf_io.f:(.text+0x1c630): undefined reference to `nf_inq_dimlen_'
I am having a similar problem but my system build does indeed touch the NetCDF libraries (installed on /usr/local) before the compile gets to that final link for wrf.exe. ldconfig and the LD_LIBRARY_PATH both touch the compilers and they are hard pointed to the /usr/local area. This only happened to me with the GNU compilers, the Intel HPC one-api compilers were able to compile and run wrf [but only on one node and UPP-for-WRF will not build].

Is this a problem with the GCC 11.2 compiles for Umbut? 21.10 uses 11.2.0-7ubuntu2 and 22.04 LTS uses 11.2.0-19ubuntu1.

Bill Capehart
SD Mines
I was getting some different error using GCC/Gfortran version 11 and what i could find is that gcc/gfortran version 10 or later has some compatibility issues with netcdf. please try version 9
Use openmpi instead mpich for Ubuntu 21.10 and Ubuntu 22.04. Then you will be able to complete the compilation without any problems.

sudo apt install libopenmpi-dev libhdf5-openmpi-dev
This will also work.

./configure --prefix=$DIR/MPICH --with-device=ch3 FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch

But the issue is gcc/gfortran 10 or greater.
Whatheway said:
This will also work.

./configure --prefix=$DIR/MPICH --with-device=ch3 FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch

But the issue is gcc/gfortran 10 or greater.

I'm not saying there is a problem installing mpich. WRF installation fails when trying to install WRF with GCC 10+ and mpich on Ubuntu 21.10+. Currently, the only way to have a successful installation on Ubuntu 21.10+ with GCC 10+ is to use openmpi instead of mpich.

Openmpi is an alternative open source Message Passing Interface program that works the same as mpich. Many distributions like Archlinux use openmpi instead of mpich.

Using the fflags and fcflags with mpich install. Compiles wrf.