WRF installation using intel compiler on HPC

Introduction

  Here we are going to install WRF 4.5.1 which is released on 25 July 2023. It will be helpful to those who want to install WRF from scratch in an HPC environment.
  WRF is a regional forecasting model developed by NCAR. You can refer more on: https://www.mmm.ucar.edu/models/wrf

Required Libraries for WRF installation


  1. szip

  2. zlib

  3. HDF5

  4. NetCDF-C

  5. NetCDF-Fortran

  6. lib-png

  7. Jasper

Setting up the environment for intel compilers


Type following command in your terminal one by one to set the environment variable in bash.


  export CC=icc
  export CXX='icpc -E'
  export CPP='icpc -E'
  export FC=ifort
  export F77=ifort
  export F90=ifort


Before going ahead we will set the WRF library installation directory Path and that Path we will use in further installation.


  export DIR=/home/user         # Replace bold path with your computer path.
  cd $DIR
  mkdir wrf_lib_install
  cd $DIR

1. Installing szip



  wget https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz
  tar -zxvf szip-2.1.1.tar.gz
  cd szip-2.1.1
  ./configure --prefix=${DIR}/wrf_lib_install
  make
  make check
  make install
  cd ../

2. Installing ZLIB



  wget https://zlib.net/zlib-1.3.tar.gz
  tar -zxvf zlib-1.3.tar.gz
  cd zlib-1.3
  ./configure --prefix=${DIR}/wrf_lib_install
  make
  make check
  make install
  cd ../

3. Installing HDF5



  wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.2/src/hdf5-1.14.2.tar.gz
  tar -zxvf hdf5-1.14.2.tar.gz
  cd hdf5-1.14.2

  ./configure --prefix=${DIR}/wrf_lib_install --enable-fortran --enable-hl --enable-shared --with-szlib=${DIR}/wrf_lib_install --with-zlib=${DIR}/wrf_lib_install

  make
  make -j 4 check
  make -j 4 install
  cd ../


For setting the paths of HDF5 library enter the following lines at your terminal:


  export PATH=${DIR}/wrf_lib_install/bin:$PATH
  export LD_LIBRARY_PATH=${DIR}/wrf_lib_install/lib:$LD_LIBRARY_PATH
  export HDF5=${DIR}/wrf_lib_install
  export LDFLAGS=-L${DIR}/wrf_lib_install/lib
  export CPPFLAGS=-I${DIR}/wrf_lib_install/include

4. Installing NetCDF-C



  wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netcdf-c-4.9.2.tar.gz
  tar -zxvf netcdf-c-4.9.2.tar.gz
  cd netcdf-c-4.9.2
  ./configure --prefix=${DIR}/wrf_lib_install --disable-libxml2 --disable-byterange
  make
  make -j 4 check
  make -j 4 install
  cd ../

5. Installing NetCDF-Fortran



  wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.tar.gz
  tar -zxvf netcdf-fortran-4.6.1.tar.gz
  cd netcdf-fortran-4.6.1
  ./configure --prefix=${DIR}/wrf_lib_install
  make
  make -j 4 check
  make -j 4 install
  cd ../

6. Installing lib-png



  wget https://excellmedia.dl.sourceforge.net/project/libpng/libpng16/1.6.40/libpng-1.6.40.tar.gz
  tar -zxvf libpng-1.6.40.tar.gz
  cd libpng-1.6.40
  ./configure --prefix=${DIR}/wrf_lib_install
  make
  make check
  make install
  cd ../

7. Installing Jasper



  wget https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.29.tar.gz
  tar -zxvf jasper-1.900.29.tar.gz
  cd jasper-1.900.29
  ./configure --prefix=${DIR}/wrf_lib_install
  make
  make check
  make install

To set up your bashrc for future library use, execute the following lines as it is:


  echo "export CC=icc" >> ~/.bashrc
  echo "export CXX='icpc -E'" >> ~/.bashrc
  echo "export CPP='icpc -E'" >> ~/.bashrc
  echo "export FC=ifort" >> ~/.bashrc
  echo "export F77=ifort" >> ~/.bashrc
  echo "export F90=ifort" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export MPICC=mpiicc" >> ~/.bashrc
  echo "export MPICXX=mpiicxx" >> ~/.bashrc
  echo "export MPIF77=mpiifort" >> ~/.bashrc
  echo "export MPIF90=mpiifort" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export PATH="${DIR}"/wrf_lib_install/bin:$""PATH" >> ~/.bashrc
  echo "export LD_LIBRARY_PATH="${DIR}"/wrf_lib_install/lib:$""LD_LIBRARY_PATH" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export HDF5="${DIR}"/wrf_lib_install" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export LDFLAGS=-L"${DIR}"/wrf_lib_install/lib" >> ~/.bashrc
  echo "export CPPFLAGS=-I"${DIR}"/wrf_lib_install/include" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export NETCDF="${DIR}"/wrf_lib_install" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "" >> ~/.bashrc
  echo "export JASPERLIB="${DIR}"/wrf_lib_install/lib" >> ~/.bashrc
  echo "export JASPERINC="${DIR}"/wrf_lib_install/include" >> ~/.bashrc

Now you are all set to go ahead for WRF Installation.

WRF Installation


  cd $DIR
  wget https://github.com/wrf-model/WRF/releases/download/v4.5.1/v4.5.1.tar.gz
  tar -zxvf v4.5.1.tar.gz
  cd WRFV4.5.1
  ./configure

Output:



Edit configure.wrf


In configure.wrf edit the following lines using your favourite editor (vim,nano,gedit etc.):


  DM_FC      =     mpiifort
  DM_CC      =     mpiicc

compile the WRF code



  ./compile -j 4 em_real

This step will take around 30-45 min to complete. After sucessful compilation you will get 4 executables generated at your WRFV4.5.1/run folder

WPS Installation


  cd $DIR
  wget https://github.com/wrf-model/WPS/archive/refs/tags/v4.5.tar.gz
  tar -zxvf v4.5.tar.gz
  cd WPS-4.5
  export WRF_DIR=$DIR/WRFV4.5.1
  ./configure

Output:



Edit configure.wps


In configure.wps edit the following lines using your favourite editor (vim,nano,gedit etc.):


  DM_FC      =     mpiifort
  DM_CC      =     mpiicc

compile the WPS code



  ./compile

After sucessful compilation you will get 3 executables (i.e. ungrib.exe, geogrid.exe and metgrid.exe) generated at your WPS-4.5 folder.

Congratulations! You have installed WRF sucessfully. Now go ahead and run WRF.


Prepaired by "Team Meteokite" for free educational purpose.
Design by team METEOKITE.COM