WRF installation 2022-09-14T06:17:34+00:00

Installing WRF 4.2 on Ubuntu 20.04/20.10 LTS

1) Install dependencies – csh, gfortran, m4, mpich, libhdf5-mpich-dev, libpng-dev, libnetcdff-dev, netcdf-bin, ncl-ncarg

2) Add the following flags to bashrc

setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv FCFLAGS -m64
setenv F77 gfortran
setenv FFLAGS -m64

3) Jasper-dev must be installed from Xenial Sources using the following commands
sudo add-apt-repository “deb https://security.ubuntu.com/ubuntu xenial-security main”
sudo apt update
sudo apt install libjasper1 libjasper-dev

4) Find the following files to ensure that they are installed

locate netcdf.inc
Result: /usr/include/netcdf.inc

locate mpich/lib
Result: /usr/lib/mpich/lib

5) Update environment variables

export NETCDF=/usr
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mpich/lib

Add variables to the ./bashrc file to set them permanently. Rerun source ./bashrc to reload the variables

6) To avoid recompiling NETCDF add the following environment variable to the ./bashrc

export NETCDF_classic=1

7) Download WRF from Github “git clone https://github.com/wrf-model/WRF.git”

8) Configure WRF by running “./configure”, choosing option 33 and option 1. For nesyed domains use 2

Important Notes on Multiprocessing
• Serial – one core only.
• SMpar (Shared-Memory) – you can use all the cores in a multi-core computer (you’ll need openMP for this).
• DMpar (Distributed-Memory) – you can use all the cores in every computer of a cluster (you’ll need MPI for this).
If you only have one processor, SMpar will be the only choice.
Options for “./ configure” script
• –d build the code with debugging turned on
• –D same as –d, plus bounds and range checking, uninitialized variables, floating traps
• –r8 build the code to use 64 bit reals for computation and output

9) Edit the Configure.wrf file, in the line “LIB_EXTERNAL” add the commands “-lnetcdff -lnetcdf” after “-L/usr/local/lib” so that it becomes

LIB_EXTERNAL =\-L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/lib -lnetcdff -lnetcdf

10) Compile by running “./compile -j 12 em_real >& compile.log&”. The file “compile.log” will hold compilation details. The ‘-j 12’ indicates the number of processors used in the compilation.

To clean an unsucessful compile use ‘./clean’. For deep cleaning including the configure.wrf file use ‘./clean -a’
Installing WPS 4.2

NOTE : you need gcc,g++ and gfortan 9.3 fro a sucessful compile

  1. Download from git repo
  2. Run ./configure and choose option 4
  3. Edit configure.wps and add –lnetcdff after the option -lnetcdf
  4. Compile by running ./compile >& compile.log&