NOAA logo-Select to go to the NOAA homepage
NOAA / NWS's Meteorological Development Laboratory   
  Select to go to the NWS homepage
GRIB1 logo Degrib (NDFD GRIB2 Decoder) GRIB2 logo
 
Local forecast by
"City, St"
 
 
 
 
 
 
 

Degrib: Windows Compile

Setting up your machine to compile:

I would recommend a combination of cygwin (http://cygwin.com) and mingw (http://www.mingw.org/).  What cygwin does, is emulate a UNIX system on top of MS-Windows, and provides a Gnu C compiler.  The catch is that executables created using cygwin typically are dependent on the cygwin1.dll file.  There are ways around that, but the safest way is to use mingw which only uses MS-Windows libraries.

To use mingw, install it, and then add it to the beginning of your path.  For example, my path starts with: /cygdrive/c/mingw/bin:/usr/local/bin:/usr/bin:/bin:.  This way the copy of 'gcc', 'ld', and 'ar' that are used, are from c:/mingw/bin instead of from cygwin (which is dependent on cygwin1.dll).

Note: From here out when I refer to /degrib/, on MS-Windows I mean: c:\ndfd\degrib20 or /cygdrive/c/ndfd/degrib20.

What about Tcl/Tk?

I would recommend a version of Tcl/Tk (8.3.2 in my case) that is designed for MS-Windows.  To get the most recent version of Tcl/Tk you can go to http://www.tcl.tk/.  I installed my copy to c:\tcl832, and when I configure (more on that in a bit) I add TCL_PREFIX=c:/tcl832 to the command line.  One can compile without Tcl/Tk, by ignoring the errors at the very end, and manually copying the results from /degrib/src/degrib to /degrib/bin.

The alternative, would be to use the version of Tcl/Tk that comes with Cygwin.  I have attempted to do that in the pure cygwin compile, but have had mixed results.  First, I appear to have to set an environment variable: TCL_LIBRARY=/usr/share/tcl8.4 to get it to find init.tcl.  Next, running "tcldegrib web.tcl" from the command prompt has no output, but from a bash shell appears to work fine.  Conversely tkdegrib from a bash shell locks, while from a command prompt runs ok, but has problems exec'ing code.  Since the image generation code currently uses exec, it won't be able to generate images, but should be able to convert files.

What about Borland C++ or MS Visual C++?

Currently, I don't use them because at one point one of the libraries degrib uses required FORTRAN.  This is no longer the case, so it should be possible to compile using Borland C++ or MS Visual C++, but I have not had time to pursue it.  As an added wrinkle, degrib is dependent on a number of libraries, not all of which have instructions for compiling in Borland or MS Visual C++.  One solution to this would be to provide pre-compiled versions of those libraries, but again I have not pursued this. 

Compiling (the ideal case)

The general idea is to:

  1. Use "/degrib/src/configure" to create several Makefile's from the Makefile.in templates
  2. Use "make" to then create the executables.

If you are unfamiliar with configure, you probably should start by reading through "/degrib/src/README.config". Next, since the degrib package provides (in "/degrib/src/") sample scripts which call configure for the major computer platforms, you may want to look at the applicable one. If you have problems, you may want to try "configure --help" to see what options it accepts. If you still have problems, please contact me with the /degrib/src/config.log and /degrib/src/config.status files.

The sample scripts located in /degrib/src/ which call configure can be broken down as follows::

  • "config-aix32.sh" : Configuration options for AIX IBM using 32 bit operating system.
  • "config-aix64.sh" : Configuration options for AIX IBM using 64 bit operating system.
  • "config-cyg.sh" : : Configuration options for MS-Windows using pure cygwin.
  • "config-debug.sh" : Configuration options for MS-Windows using mingw and all the debug options.
  • "config-linux.sh" : Configuration options for Linux 32 bit operating system.
  • "config-macosx.sh" : Configuration options for Mac OS-X.
  • "config-win.sh" : Configuration options for MS-Windows using mingw.

In the ideal case you choose the right configure script and do:

  • ~taylor> cd c:/ndfd/degrib20/src
  • /cygdrive/c/ndfd/degrib20/src> ./config-win.sh
  • /cygdrive/c/ndfd/degrib20/src> make

If that worked, you can remove the temporary files by doing:

  • /cygdrive/c/ndfd/degrib20/src> make clean

Then click here to go to "How to Install".


What is a makefile?

A makefile is a file that contains instructions for the 'make' program. The 'make' program follows the instructions which typically instruct is as to how to compile a program or create a library. Typically 'make' is instructed to call a compiler ('gcc') to create object code, and then either an archiver ('ar') to create a library from the object code, or a linker ('ld') to create a program.

What do these makefiles do?

To understand what "make" does, we first need to understand that the degrib program is dependent on several libraries as follows:

  • degrib (2.02) (04/05/2013)
    • Author: Arthur Taylor (MDL/OST/NWS/NOAA)
    • Purpose: Main Program
    • Web Site: http://weather.gov/mdl/degrib/
    • Depends on: emapf-c, mdl_g2c, gd, netcdf, dwmllib, (optionally Tcl/Tk)

  • emapf-c (3.0) (3/23/2007)
    • Author: Dr. Albion Taylor (ARL/NOAA)
    • Purpose: (Library) Provides Lambert Conformal map projection capability. (This is a newer copy than the "official" one.)
    • Web Site: http://www.arl.noaa.gov/HYSPLIT_cmapf.php

  • mdl_g2c
    • Author: Arthur Taylor (MDL/OST/NWS/NOAA)
    • Purpose: (Library) Replaces the "grib2lib" library by providing API wrappers around the g2clib library which match the original grib2lib API's.
    • Depends on: libaat, g2clib

  • libaat
    • Author: Arthur Taylor (MDL/OST/NWS/NOAA)
    • Purpose: (Library) Provides several generic utility functions.

  • g2clib (1.0.5) (9/24/2007)

  • jpeg2000 (1.700.5) (12/17/2003)

  • libpng (1.2.5) (5/30/2003)

  • zlib (1.1.4) (5/31/2003)

  • gd (2.0.33) (7/12/2005)

  • netcdf (3.5.1) (4/2/2004)

  • dwmllib
    • Purpose: (Library) Provides DWML support to degrib.
    • Author: Paul Hershberg (MDL/OST/NWS/NOAA)
    • Depends on: libxml

  • libxml (2.6.23) (2/16/2006)

  • Tcl/Tk (optional)

The makefile and configure script in /degrib/src/ are aware of the dependencies, so it does the following:

  1. Configure determines setting shared by the following modules: zlib, libpng, libaat, mdl_g2c, gd, and degrib. This should create "Makefile" files in each directory
  2. For: jpeg2000, emapf-c, netcdf, and libxml, it calls 'configure' multiple times to create "Makefile" files for each library.
  3. Complies zlib
  4. Complies libpng
  5. Complies jpeg2000
  6. Complies libaat
  7. Complies mdl_g2c & g2clib
  8. Complies gd
  9. Complies emapf-c
  10. Complies netcdf
  11. Complies dwmllib
  12. Complies libxml
  13. Complies degrib, degrib_DP, clock, drawshp, tcldegrib, and tkdegrib
  14. Installs degrib, degrib_DP, clock, drawshp, tcldegrib, and tkdegrib by copying them from /degrib/src/degrib/ to /degrib/bin/

What can go wrong?

You can't find the right config-???.sh flavor in "/degrib/src/".

  • Solution 1: Ideally, you will find a similar sample script file, modify it, use it, test it, and email it to me so I can release it in the future.
  • Solution 2: I may have left subdirectories called "scripts". These would contain the original makefile.??? files. You may fine one applicable.
  • Solution 3: You can cd to each library and create it using the library specific configure (if applicable) and makefile.
  • Solution 4: Some libraries are probably already on your system (most likely zlib, libpng), so all you need is to make sure that the dependent libraries, or programs know where to find them, by modifying their makefiles.
  • Solution 5: Manually take the Makefile.in files and convert them to Makefile files.

You don't have a C compiler.

  • Solution 1: Ask your system administrator to install it.

'configure' doesn't work.

  • Solution 1: 'configure' can depend on some other programs (specifically it may use 'cat' and 'diff').  Occassionally these are installed incorrectly. 'configure' will let you know if this is the case, in which case you should see your system administrator.

'make' doesn't work.

  • Solution 1: Ask your system administrator for help.  While it is theoretically possible to manually do the compiles, it is a lot easier with 'make'.  The main problem is that the libraries are complex, so figuring out the right options would take a lot of effort.

'zlib' doesn't compile.

  • Solution 1: Manually compile each .c file using something like:
    "gcc -O3 -DHAVE_UNISTD_H -DUSE_MMAP -c -o trees.o trees.c".
    Then link using:
    "ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o"
  • Solution 2: You can probably find a version of zlib in /usr/lib. You should be able to copy /usr/lib/libz.a to /degrib/src/zlib.
  • Solution 3: Most GRIB2 messages don't use zlib compression, so it is theoretically possible to create degrib with zlib disabled. It would require modifying some makefiles, which I haven't tried yet, so please email me if you want to try.

'libpng' doesn't compile.

  • Solution 1: It might not be able to find the right script in "/degrib/src/libpng/scripts".  If so, you need to go to the libpng site and either download the right one, or ask them for help.
  • Solution 2: You can probably find a version of libpng in "/usr/lib". You should be able to copy /usr/lib/libpng.a to /degrib/src/libpng.
  • Solution 3: Most GRIB2 messages don't use png compression, so it is theoretically possible to create degrib with png disabled. It would require modifying some makefiles, which I haven't tried yet, so please email me if you want to try.

'emapf-c' doesn't compile.

  • Solution 1: Check on "ARFLAGS". Do "echo $ARFLAGS". If it is not "", you can try:
    • cd /degrib/src/emapf-c
    • configure ARFLAGS=
    • make
  • Solution 2: Manually compile each .c file using something like:
    "gcc -O -g -O2 -c -o cc2gll.o cc2gll.c".
    Then link using:
    "ar r libemapf.a cc2gll.o cc2gxy.o ccurv.o cg2cll.o cgszll.o cgszxy.o cpolll.o cpolxy.o eqvlat.o logabova.o mkgeoid.o stcm1p.o stcm2p.o stlmbr.o ymercfns.o"
    "ranlib libemapf.a"

'jpeg2000' doesn't compile

  • Solution 1: jpeg2000 is a subset of the jasper library. Go to the jasper web site, and try compiling the entire program.
  • Solution 2: It is theoretically possible to run degrib with jpeg2000 disabled, as it could still handle NDFD data, but I don't recommend it as NCEP generally uses jpeg2000.

'grib2lib' doesn't compile

  • Solution 1: Attempt to compile without FORTRAN (by modifying some makefiles). Email me if you want to try this.
  • Solution 2: Email me for help.

'netcdf' doesn't compile

  • Solution 1: degrib doesn't rely on netCDF except as one output option, so it is theoretically possible to compile degrib with netcdf disabled. It would require modifying some makefiles, which I haven't tried yet, so please email me if you want to try.

'gdl' doesn't compile

  • Solution 1: degrib doesn't rely on gd except when as part of the map creation option, so it is theoretically possible to compile degrib with libxml disabled. It would require modifying some makefiles, which I haven't tried yet, so please email me if you want to try.

'libxml' doesn't compile

  • Solution 1: degrib doesn't rely on libxml except as part of the DWML XML generation option, so it is theoretically possible to compile degrib with libxml disabled. It would require modifying some makefiles, which I haven't tried yet, so please email me if you want to try.

'degrib' doesn't compile

  • Solution 1: Email me for help.

'tcldegrib' couldn't find Tcl.h

  • Solution 1: Skip the optional GUI part, (ie tcldegrib, and tkdegrib), and simply copy degrib from /degrib/src/degrib to /degrib/bin/.
  • Solution 2a: You need Tcl/Tk to be installed on the system. To find out if it is, you can try which wish or which tclsh. Also, whereis wish sometimes helps. If you can not find it, ask your system administrator to either install it or let you know where it is. Source code for Tcl/Tk can be found at www.tcl.tk.
  • Solution 2b: You need to find: tk.h, tcl.h, as well as where libtcl*.a and libtk*.a are. Unfortunately I don't have any nice ways to find them, other than the "find" command. On the hp they were in:
    • /global/local/include/(tcl.h and tk.h)
    • /global/local/lib/(libtcl8.0.a and libtk8.0.a)
    On the Linux system they were in:
    • /usr/local/tcltk/include/(tcl.h and tk.h)
    • /usr/local/tcltk/lib/(libtcl8.3.a and libtk8.3.a)
  • Solution 2c: You now need to let the makefiles in "/degrib/src/degrib/" know where to find Tcl/Tk. Specifically you need to modify them with the correct location for: "TCL_PREFIX". "Tcl.h" should be located in "$TCL_PREFIX/include".

'tcldegrib' or 'tkdegrib' couldn't find "init.tcl"

  • Solution 1: Find "init.tcl", and add an environment variable for it.
    Example: a pure cygwin compile of tkdegrib or tcldegrib appears to need:
    "setenv TCL_LIBRARY /usr/share/tcl8.4", or
    "export TCL_LIBRARY=/usr/share/tcl8.4".

Where do I go from here?


    US Dept of Commerce
    National Oceanic and Atmospheric Administration
    National Weather Service
    Meteorological Development Laboratory
    1325 East West Highway
    Silver Spring, MD 20910
    Page last Modified: April 16, 2010.
Degrib Questions? Arthur Taylor
NDFD Questions? nws.ndfd@noaa.gov
XML Questions? Paul Hershberg & John Schattel
Disclaimer
Information Quality
Credits
Glossary
Privacy Policy
Freedom of Information Act (FOIA)
About Us
Career Opportunities