Skip to content


Build WPS

Required libraries

WPS (specifically grib.exe) uses three external libraries: JasPer, zlib, and PNG (libpng). For most users using netCDF for file I/O, the netCDF libraries are also required; while building WPS, environmental variable NETCDF needs to be set to the path of the NetCDF installation. We can use the environmental variable $NETCDF_DIR set by the cray-netcdf module:


On Perlmutter, zlib and libpng are available in /usr, so the configure tool can find them automatically. JasPer is not available in a standard path nor as a module yet, so a user needs to install it from the downloaded source code (example script below).

Example build script for the JasPer external library

#build the three libraries used by WPS's ungrib.exe
#the script is based on  the direction here:

#on Perlmutter, zlib and libpng are available in /usr, 
#so configure should find them
#jaspser can be compiled by this script, or 
#one could use the one installed under the Spack module/environment
#%module load cpu
#%module load spack
#%spack load jasper
#(will be tested)

# WRF/WPS directories, using the WRF-SIG directory as example

export WRF_DIR=${wrfroot}/WRF
export WPS_DIR=${wrfroot}/WPS

#Load the same modules used for WRF, saved in a bash script ---------------------------
source ${loading_script}

#directory for the external libraries, here using a global common for WRF-SIG
export EXDIR=/global/common/software/m4232/test/LIBRARIES
mkdir -p ${EXDIR}

libcodedir=/global/cfs/cdirs/m4232/model/external #where source code of external library is downloaded 

#compiler wrappers fail when the configure script check for cross-compilation
#so use the base compiler to build the external library

export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran

echo "installing JasPer"

cd ${libcodedir}/jasper-1.900.1
./configure --prefix=${EXDIR}/grib2
make install

Compile WPS

To build the three WPS programs: geogrid, ungrib, and metgrid, we first run the configure script in the top WPS directory. Configure collects system information and also asks a user to select a model configuration. For a standard use-case of running WPS on a log-in node, option #1 (in WPS v4.4) is appropriate for Perlmutter,

 1.  Linux x86_64, gfortran    (serial)

After the system information and WPS configuration are saved in configure.wps, we use the "compile" script in the top WPS directory to compile the three WPS programs. The compile script has to be run while loading the same modules (libraries) as those used to build WRF, because WPS uses WRF's I/O libraries. See below for an example script for Perlmutter.


If WRF was compiled with the dm+sm option, then we need to add a compiler flag related to shared-memory library (-lgomp) to "WRF_LIB" in configure.wps (see this WRF forum post).

set -e
set -o pipefail

#based on  the direction here

imach="pm" #system name, pm for perlmutter

config_wps=true   #set true to run configure script

build_wps=true   #set true to compile WPS

# WRF directories, taken from WRF-SIG project directory (only open to WRF SIG members)

export WRF_DIR=${wrfroot}/${imach}/${mversion}/WRF
export WPS_DIR=${wrfroot}/${imach}/${mversion}/WPS

#Modules --------------------------------------------------------------------
source ${loading_script}

##capture starting time for log file name
idate=$(date "+%Y-%m-%d-%H%M")
echo $idate

#directory for the external libraries are built
#only jasper needs to be installed on Perlmutter

export WRF_EXTERNAL_LIBS=/global/common/software/m4232/test/LIBRARIES

export FCFLAGS="-m64" 
export FFLAGS="-m64"

#from the netcdf module

#jasper path to be used to set COMPRESSION_LIBS and COMPRESSION_INC
#environment variables, which are used by the configure script
#local installation
export JASPERINC="$WRF_EXTERNAL_LIBS/grib2/include"

########### build WPS; requires WRF being built first to use the WRF IO routines
if [ "$config_wps" = true ]; then

    echo "Configuring WPS"

    cd ${WPS_DIR}

    ./clean -a

    ./configure SCC=gcc SFC=gfortran  #using base compilers for serial run
    #other compilers are set equal to SCC and SFC in the configure script

    #choose option 1 to run  WPS on a log-in node as a serial executable 
    #   1.  Linux x86_64, gfortran    (serial)

    #if using compute node with MPI, then 
    #./configure SCC=cc SFC=ftn
    #   3.  Linux x86_64, gfortran    (dmpar) 

    #if WRF was compiled with the dm+sm option, then we 
    #need to add a compiler flag related to shared-memory library to "WRF_LIB" in configure.wps
    #based on a WRF forum post
    sed -i 's/lnetcdff/lnetcdff -lgomp/' configure.wps


if [ "$build_wps" = true ]; then

    echo "Building WPS"

    cd ${WPS_DIR}
    #here saving the compile log in the specified directory for record
    echo  "compile log file is ${bldlog}"

    ./compile &> ${bldlog}

Static data

For WRF-SIG members, most of the static data for geogrid.exe are stored locally on NERSC: /global/cfs/cdirs/m4232/data/static_data/WPS_GEOG_V4