Download and Compile - pmlmodelling/WRF_installation GitHub Wiki

Download latest WRF

Latest WRF in official github repository:

ssh scylla
cd ~/Code
git clone https://github.com/wrf-model/WRF.git WRF
git clone --recurse-submodule https://github.com/wrf-model/WRF.git (I should have used this!)

Compilation and testing

The compilation Scylla specific flags are

          CPP      = /usr/bin/cpp
          COMPILER = -DIFORT
          CC       = mpiicx
          CXX      = mpicpx
          FC       = mpiifx
#         DEBFLGS  = #-check all
          OPT      = -O3 -qno-openmp-simd #-fp-model precise #-init=zero -init=arrays -ftrapuv
          CLIB     =
          CFLAGS   =

A good starting point for learning about WRF, code structure and how to use it is https://www2.mmm.ucar.edu/wrf/OnLineTutorial/Introduction/start.php And a compilation tutorial can be found in https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php

When in Scylla, load the appropriate modules for Fortra + C code.

module use /scyllapfs/sw/modulefiles/{apps,libs,toolchains,mpi,compilers,utils}
module load libfabric
module load oneapi/2024.1
module load netcdf/4.9.2-oneapi-2024.1
module load hdf5/1.14.5-oneapi-2024.1

Pre compilation tests

I ran the tests in the compilation tutorial and all were passed except for the CSH test. I ended up installing tcsh in a conda environment to run the install commands.

Additional packages needed by WRF and not provided with Scylla installation

WRF needs additional packages that I have placed in /work/shared/ I have a function in .bashrc with the required definitions for installing wrf wrf_install()

wrf_install()
{
        module purge
        prgenv=oneapi # igi
        vprgenv=2024.1
        module load ${prgenv}/${vprgenv}
        module load ucx/1.16.0.mlx
        module load hdf5-parallel/1.14.5-${prgenv}-${vprgenv}
        module load netcdf-hdf5parallel/4.9.2-${prgenv}-${vprgenv}
        module load intel_ipp_intel64/latest

        export PATH=.:/work/shared/wrf/libs/bin:${PATH}
        export LD_LIBRARY_PATH=/work/shared/wrf/libs/lib:/work/shared/wrf/libs/grib2/lib:${LD_LIBRARY_PATH}
        export JASPERLIB=/work/shared/wrf/libs/grib2/lib
        export JASPERINC=/work/shared/wrf/libs/grib2/include

        export DIR=/work/shared/wrf/libs
        export CC=mpiicx
        export CXX=mpicpx
        export CFLAGS='-O3 -march=native -qipp  -static-intel -Wno-implicit-function-declaration -Wno-incompatible-function-pointer-types -Wno-unused-command-line-argument'
        export CXXFLAGS='-O3 -march=native -qipp  -static-intel -Wno-implicit-function-declaration -Wno-incompatible-function-pointer-types -Wno-unused-command-line-argument'
        export F77=mpiifx
        export FC=mpiifx
        export F90=mpiifx
        export FFLAGS='-O3 -march=native -qipp  -static-intel -Wno-implicit-function-declaration -Wno-incompatible-function-pointer-types -Wno-unused-command-line-argument'
        export CPP='icpx -E'
        export CXXCPP='icpx -E'
        export LDFLAGS="-L/work/shared/wrf/libs/lib -L/work/shared/wrf/libs/grib2/lib"
        export CPPFLAGS="-I/work/shared/wrf/libs/include -I/work/shared/wrf/libs/grib2/include"

}

Note that the compilation options are different from what is suggested in https://forum.mmm.ucar.edu/threads/full-wrf-and-wps-installation-example-intel.15229/

Included advice from https://forum.mmm.ucar.edu/threads/wrf-arw-v4-6-0-intel-llvm-compilers.17265/

libpng compilation

After the above changes libpng compiles ok

jasper compilation

Jasper is throwing errors of undeclared functions when downloading the 1.900 version. I have instead downloaded the latest one from git clone https://github.com/jasper-software/jasper.git jasper but this throws plenty of other problems so sticking with the old version

Files that have been edited to enable compilation: src/libjasper/base/ja_getopt.c Included #include <stdarg.h> for solving va_start call issues

src/libjasper/bmp/bmp_dec.c added #include "jasper/jas_debug.h" to support jas_eprintf

Changed flags to include -Wno-implicit-function-declaration -Wno-incompatible-function-pointer-types -Wno-unused-command-line-argument

And it compiled.

wrf-awr compilation

add NETCDF and HDF5 environment variables to point to system NETCDF and HDF5 libraries. export NETCDF=${NETCDF_ROOT} and export HDF5=${HDF5_ROOT}

install tcsh in a conda environment

conda create --name wrf
conda install -c conda-forge tcsh
conda activate wrf
cd ~/Code/WRF/
./configure (choose options 78 and 1)
tcsh ./compile em_real -j 4 >& log.compile

download and compile WPS

This is the WRF preprocessing system and includes tools for handling terrain, land use, meteo data and interpolates to WRF grid. geogrid.exe → Processes static geographical data (e.g., terrain, land use). ungrib.exe → Extracts and decodes meteorological data from GRIB-formatted files. metgrid.exe → Interpolates meteorological data onto the WRF simulation domain.

git clone https://github.com/wrf-model/WPS.git
cd WPS
export WRF_DIR=~/Code/WRF
./configure (choose option 17 for serial, 19 for parallel)
The above for some reason doesn't pick mpiifx or mpiicx so manually changes configure.wps
DM_FC               = mpiifx
DM_CC               = mpiicx

tcsh ./compile >& log.compile

This finishes the compilation successfully

⚠️ **GitHub.com Fallback** ⚠️