Skip to content

Instantly share code, notes, and snippets.

@bruceh48
Created April 15, 2017 08:26
Show Gist options
  • Save bruceh48/b5c67f6db6e4ee161ed6364a97c81d9f to your computer and use it in GitHub Desktop.
Save bruceh48/b5c67f6db6e4ee161ed6364a97c81d9f to your computer and use it in GitHub Desktop.
Compile and install WGRIB2
#!/bin/bash
apt-get update
apt-get install -y build-essential libaec-dev zlib1g-dev libcurl4-openssl-dev libboost-dev curl wget zip unzip bzip2 gfortran gcc g++
rm -rf /usr/local/grib2/
mkdir -p /usr/local/grib2/
cd /code/
if [ ! -f "/tmp/wgrib2.tgz" ]; then
wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v2.0.6c -O /tmp/wgrib2.tgz
fi
tar -xf /tmp/wgrib2.tgz
mv /tmp/grib2/ /usr/local/grib2/
cd /usr/local/grib2/grib2
export FC=gfortran && export CC=gcc
make && rm -rf /usr/local/bin/wgrib2
ln -s /usr/local/grib2/grib2/wgrib2/wgrib2 /usr/local/bin/wgrib2
rm /tmp/wgrib2.tgz
@tomholford
Copy link

@bruceh48 FYI the latest version is now 2.0.8, per this index:

ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2

@anikfal
Copy link

anikfal commented Jun 24, 2024

There are some compile errors with reference to grib2/wgrib2/config.h:

In file included from wgrib2.h:8,
                 from AAIG.c:6:
config.h:2:1: error: stray ‘\’ in program
    2 | \#define USE_REGEX
      | ^
config.h:2:2: error: stray ‘#’ in program
    2 | \#define USE_REGEX
      |  ^
config.h:2:3: error: unknown type name ‘define’
    2 | \#define USE_REGEX
      |   ^~~~~~
config.h:3:1: error: stray ‘\’ in program
    3 | \#define USE_TIGGE
      | ^
config.h:3:2: error: stray ‘#’ in program
    3 | \#define USE_TIGGE
      |  ^
config.h:3:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘define’
...
...
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment