Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
erget committed May 12, 2016
0 parents commit 9dd786e
Show file tree
Hide file tree
Showing 571 changed files with 88,493 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Developement.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Development notes for Wgrib2 1/2004



Every option for wgrib is now a function call. (Eventually some
options will be macros; for example, -s = -var -d etc.) I went
to this approach for

(1) ease of development
(2) ease of extendability
(3) more versatile

People kept making mods for wgrib, so I wanted a system where you
just drop in the code and compile.


Steps to add a new option/function:

(1) decide on the type of function
currently inv (inventory) - writes to stdout, no access to decoded data
output - writes to stdout, dump-file, access to decoded data
setup - no access to decoded data

(2) write function
functions are called several times
a) first with mode == -1 (initialization stop)
b) for each data field (mode = 0 or mode = 1 verbose)
c) finishing with mode = -2 (finializing step)

(3) write header in the source code
format is
* HEADER:sort_order:name:type:number_args:description
ex * HEADER:100:d:inv:0:date YYYYMMDDHH

For the name of the function and calling args, see
documentation in wgrib2

To compile

./function.sh updates the option table
./compile compiles the code

172 changes: 172 additions & 0 deletions INSTALLING
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
1/2013 General Installation

Quick Directions for the Default Configuration
"Any color that you like as long as it's black"

Download source code from

ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
http://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz

Untar the compressed tarball

gunzip wgrib2.tgz
tar -xvf wgrib2.tar

or if you have gnu tar: tar -xzvf wgrib2.tgz

Go to the main directory (grib2)

cd grib2

Define the C compiler that you will be using. Note icc and pgc have been
found to be incompatible with the Jasper library and are not allowed.

sh/bash: export CC=gcc
csh/tcsh: setenv CC gcc

Compile the wgrib2 using gnu make

linux: make
MacOS: gmake
Unix: ??? ask system administrators

Try executing wgrib2

wgrib2/wgrib2 -config

Copy wgrib2 to SOMEPLACE

cygwin/linux/unis: cp wgrib2/wgrib2 SOMEPLACE


Not So Quick Directions
So you want some options


Edit the file "makefile" and select the desired options:

# netcdf3: write netcdf files with netcdf-3 library
# netcdf4: write netcdf files with netcdf-4 library
# only one netcdf library can be installed. do not choose netcdf3 and ncdf4
# regex: regular expression package used by (match,not), POSIX-2
# tigge: enable -tigge option for tigge names
# mysql: write to mysql files
# ipolates: fortran interpolation library
# udf: user defined functions
# openmp: use OpemMP to thread the code
# g2clib: install g2clib decoders (allow -g2clib 2)
#
# the flags are stored in wgrib2/config.h
#

Default options

USE_NETCDF3=1
USE_NETCDF4=0
USE_REGEX=1
USE_TIGGE=1
USE_MYSQL=0
USE_IPOLATES=0
USE_UDF=0
USE_OPENMP=0
USE_G2CLIB=0

In the default configuration, all the code is compiled
using the C compiler.


On some machines, you will have to define the C compiler
and C preprocessor. On the NCEP's AIX, I have to define
them by

export CC=/usr/vacpp/bin/xlc_r
export CPP=/usr/bin/cpp

Then you have to run gnu make. (gmake on some machines, make on others)

make - on linux
gmake - on AIX



Comments on Netcdf

The makefile is set up to use either netcdf v3 or netcdf v4. Netcdf-4
makes wgrib2 much bigger, so don't install it unless you really have to.
The source code for netcdf-4 (and necessary hdf5) is also very big
and will have to be downloaded separately.

The netcdf-3 library is included with this distribution. The library is
compiled in enable-C-only mode which is not be that useful for
fortran code. Don't use try to link other codes to this library.

The netcdf-4 library has to be downloaded with the HDF5 library and
the shell variable FC has to be set to the default fortran compiler.


IPOLATES, interpolation library

IPOLATES is the interpolation library used by the -new_grid options.
In order to use this library, you must have a f90/f95/f2003 fortran compiler.
In order to enable the -new_grid options, the makefile has to have USE_IPOLATES
enabled and the shell variable, FC, must have the name of the fortran compiler.
You will have to change the source code if you are not using g95, gfortran,
openf95 or xlf.

MYSQL

Install MySQL requires the appropriate headers and libraries to be installed.
The makefile may have to be modified to reflect the locations of the headers
and libraries.



INSTALLING on windows XP

The code including the IPOLATES option compiles in the cygwin development
system. You'll have to install extra packages such as the C, gfortran
compilers and various scripting utilities.

Before you compile, you set the default compilers.

export CC=gcc
export FC=gfortran
make

INSTALLING on FreeBSD

Set appropriate CC and FC environment variables and try make. wgrib2 v1.9.8
was compiled with clang and gfortran.


INSTALLING on Apple OS-X

Has been done. No details.


INSTALLING on NCEP's AIX

Define default C, C preprocessor and fortran

export CC=/usr/vacpp/bin/xlc_r
export CPP=/usr/bin/cpp
export FC=xlf_r
gmake


Static vs Dynamic Libraries

The various libraries can be created in both dynamic and static versions.
I've tried to make the add-on libraries static.

Testing Package

Have a testing script that tests an known-good version with a test
version. For new machines, I use the gcc compiled version as the
"known-good" version. Not ideal.

Problems

Some optional packages require changes to makefile

60 changes: 60 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
wgrib2

wgrib2 is a program to read/write grib2 files.


For documentation, see

http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/index.html


For documentation of commonly used program options, type

wgrib2


For documentation of all program options, type

wgrib2 -help all

For documenation of any program option that is poorly described on-line
or by the "wgrib2 -help all", check the source code by searching
for "f_{option}" where the option does not include the minus sign.


Default makefile options

USE_NETCDF4=0
USE_NETCDF3=1
USE_REGEX=1
USE_TIGGE=1
USE_MYSQL=0
USE_IPOLATES=0
USE_UDF=1

To compile without netcdf, use USE_NETCDF3=0 and USE_NETCDF4=0
To compile without netcdf v3, set USE_NETCDF3=1 and USE_NETCDF4=0
To compile without netcdf v4, set USE_NETCDF3=0 and USE_NETCDF4=1
For netcdf4, the netcdf4 and hdf5 libraries are usually not included
in the wgrib2.tgz file to save space.

If you have an old C compiler system that doesn't include <regex.h>, then
you have to set USE_REGEX=0. This turns off all the regular expressions
which would be a pain.

No harm to keep TIGGE support on. USE_TIGGE=1

Support for Mysql is an option. You have to modify the makefile to indicate
the locations of the mysql includes and libraries and set USE_MYSQL=1

The option -new_grid uses the ipolates library to do the interpolation.
The required libraries are written in fortran and their is no support
for compiling these libraries. The source code and makefile will
have to be modified to use the ipolates option. Consult a local
expert if you want to install this optional package. No help is available
from NCEP for installing the package.

User Defined Functions (UDF) allow you to run shell commands from
within wgrib2. UDF are not available on windows machines unless
<unistd.h> is implimented by the compiler (cygwin, MinGW). For
the security paranoid, turn off UDF by USE_UDF=0.
87 changes: 87 additions & 0 deletions README.EUMETSAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Using EUMETSAT grib2 fields


Some of the EUMETSAT data is on a space view perspective grid.

-sh-3.00$ wgrib2 LMPEF_CLM_110328_0945.grib2 -grid
1:0:grid_template=90:winds(N/S):
Space view perspective or orographic grid (3712 x 3712) units 1e-06
input EW:SN output WE:SN res 0
sub-sat point: lat 0.000000 lon 0.000000 ix=1856.000000 iy=1856.000000
diameter of earth dx=3622 dy=3610 grid cells ori_angle 0.000000
sat. altitude=6.610700 (equatorial radii) grid_origin Xo=0 Yo=0

wgrib2 v1.9.3 adds support for space view perspective grids with the restriction
that orientation angle (ori_angle) is 0 and sub-sat point has a latitude of 0.

The rest of the text assumes that you have a space view perspective file.


Displaying with GrADS

My version of GrADS is not using the latest g2clib can couldn't handle product
definition template 4.30. So here is what I did.

* make a copy of the grib file product with def template 4.0
wgrib2 LMPEF_CLM_110328_0945.grib2 -set_pdt 0 -set_var CLOUDM -grib new.grb
1:0:d=2011032809:CLOUDM:no_level:-1 missing fcst:

* make a control file
g2ctl -raw new.grb >new.ctl

* make a index file
gribmap -i new.ctl

Note that my grib file only had one field. Some EUMETSAT grib files have
mutiple fields on different grids. g2ctl will get confused files that have
more than one grid. Your grib file must only have one grid.

When you run GrADS on your file, you will see the raw satellite data.


Getting grid point information


To get the value of the grid point nearest to a specified lat-lon.

-sh-3.00$ wgrib2 new.grb -lon 10 30
experimental space_view2ll scan=12
experimental space_view2ij
1:0:lon=10.009994,lat=30.005756,val=1

To get the value of a grid point

-sh-3.00$ wgrib2 new.grb -ijlat 1 1
experimental space_view2ll scan=12
1:0:(1,1),lon=999.000000,lat=999.000000,val=3
-sh-3.00$ wgrib2 new.grb -ijlat 1000 1000
experimental space_view2ll scan=12
1:0:(1000,1000),lon=-27.386283,lat=-24.929402,val=0

If the grid point is off the earth, a lat-lon of 999 is used.
The convention of (i,j) is different that used by EUMETSAT. (1,1) is
the bottom left corner which is consistent with wgrib2 convention.


Regridding the data


To space view perspective is not as convenient as a latitude-longitude grid
for many plotting programs. You can use the -lola option to regrid the
data to a lola grid.

* converting to lola grid by nearest neighbor
-sh-3.00$ wgrib2 new.grb -lola -60:1201:.1 -60:1201:.1 lola.grb grib
experimental space_view2ll scan=12
experimental space_view2ij
1:0:d=2011032809:CLOUDM:no_level:-1 missing fcst:

* the grid of lola.grb
-sh-3.00$ wgrib2 -V lola.grb
1:0:vt=2011032809:no_level:-1 missing fcst:CLOUDM Cloud Mask [-]:
ndata=1442401:undef=0:mean=1.53046:min=0:max=3
grid_template=0:winds(N/S):
lat-lon grid:(1201 x 1201) units 1e-06 input WE:SN output WE:SN res 48
lat -60.000000 to 60.000000 by 0.100000
lon 300.000000 to 60.000000 by 0.100000 #points=1442401

25 changes: 25 additions & 0 deletions README.Mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
A user had trouble making a 64 bit version of wgrib2 with the Leopard OS.
Some of the libraries where 32 and other 64 bits. To get everything
to work, he had to get the "-m64" flag to all the compiles. He
did this by setting the following environment variables before
doing the "gmake -f makefile"

export CC=/usr/bin/gcc
export CXX=/usr/bin/c++
export F77=ifort
export CFLAGS="-O2 -m64"
export CXXFLAGS="-O2 -m64"
export FFLAGS="-O2 -m64"

Another user had to the above and change makefile

wCPPFLAGS=-O2

to

wCPPFLAGS=-O2 -m64

-------------------------------------------------

Another user Mac user had 32-bit MySQL libraries and had to
remove the -m64 (2/2010)
8 changes: 8 additions & 0 deletions README.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Compiling with clang (C language frontend for LLVM)

tested with a Ubuntu 12.04 system

export CC=clang
export FC=gfortran -fplugin=dragonegg

note: at time of testing, clang did not have OpenMP support
Loading

0 comments on commit 9dd786e

Please sign in to comment.