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 ./degrib/src
  • ~taylor/degrib/src> ./config-linux.sh
  • ~taylor/degrib/src> make

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

  • ~/taylor/degrib/src> make clean

Compiling with dependencies(tcl, tk, tcltls)

(Assuming the base folder for degrib tool is /opt/degrib)

 

Step 1: Install tcl

  1. > /opt/degrib

  2. > mkdir /opt/degrib/tcltk

  3. > cd /opt/degrib/tcltk

  4. # Download the sources for Tcl/Tk

  5. /opt/degrib/tcltk> wget https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz

  6. /opt/degrib/tcltk> wget https://prdownloads.sourceforge.net/tcl/tk8.6.9.1-src.tar.gz

  7. /opt/degrib/tcltk> wget https://core.tcl.tk/tcltls/uv/tcltls-1.7.16.tar.gz

  8. /opt/degrib/tcltk> gunzip -c tcl8.6.9-src.tar.gz | tar -xf - (or "tar -xzf tcl8.6.9-src.tar.gz")

  9. /opt/degrib/tcltk> cd /opt/degrib/tcltk/tcl8.6.9/unix/

  10. /opt/degrib/tcltk/tcl8.6.9/unix/> ./configure --prefix=/opt/degrib/tcltk

  11. /opt/degrib/tcltk/tcl8.6.9/unix/> make

  12. /opt/degrib/tcltk/tcl8.6.9/unix/> make install

Step 2: Install tk

  1. /opt/degrib/tcltk/tcl8.6.9/unix/> cd /opt/degrib/tcltk/ (to extract tk tar )  

  2. /opt/degrib/tcltk> gunzip -c tk8.6.9.1-src.tar.gz | tar -xf - (or "tar -xzf tk8.6.9.1-src.tar.gz")

  3. /opt/degrib/tcltk> cd /opt/degrib/tcltk/tk8.6.9/unix 

  4. /opt/degrib/tcltk/tk8.6.9/unix> ./configure --prefix=/opt/degrib/tcltk

  5. /opt/degrib/tcltk/tk8.6.9/unix> make

  6. /opt/degrib/tcltk/tk8.6.9/unix> make install

Step 3: Install tcltls

  1. /opt/degrib/tcltk/tk8.6.9/unix> cd /opt/degrib/tcltk/ (to extract tcltls tar)

  2. /opt/degrib/tcltk> gunzip -c tcltls-1.7.16.tar.gz | tar -xf -  (or "tar -xzf tcltls-1.7.16.tar.gz")

  3. /opt/degrib/tcltk> cd /opt/degrib/tcltk/tcltls-1.7.16/

  4. /opt/degrib/tcltk/tcltls-1.7.16> ./configure --prefix=/opt/degrib/tcltk --with-tcl=/opt/degrib/tcltk/lib

  5. Note if degrib throws an error of something along the lines of “unable to get OpenSSL Configuration”, fix this by installing OPenSSL as [optional step]: /opt/degrib/tcltk/tcltls-1.7.16> apt-get install libssl-dev

  6. /opt/degrib/tcltk/tcltls-1.7.16> make

  7. /opt/degrib/tcltk/tcltls-1.7.16/lib> make install tls

Step 4: Make the executable

  1. /opt/degrib/tcltk/tcltls-1.7.16/lib> cd /opt/degrib/src

  2. /opt/degrib/src> ./configure --prefix=/opt/degrib TCL_PREFIX=/opt/degrib/tcltk TK_VERSION=8.6 TCL_VERSION=8.6

  3. /opt/degrib/src> cd /opt/degrib/src/degrib

  4. /opt/degrib/src/degrib> vi Makefile

  5. Disable(comment) lines "20 - 24" (below)

    ############################
    #XML Dependence    
    #XML_DEF = -D_DWML_
    #XML_INC = -I../degrib -I../libxml/include -I../dwmllib
    #XML_LIB = -L../dwmllib -ldwml -L../libxml/.libs/ -lxml2
    #XML_LIBDEP = ../dwmllib/libdwml.a ../libxml/.libs/libxml2.a
    #XML_CLEAN = (cd ../dwmllib && make -f makefile clean)
    ############################

  6. /opt/degrib/src/degrib> cd .. (in src dir now)

  7. /opt/degrib/src> make

  8. /opt/degrib/src> cp -r /opt/degrib/tcltk/lib/tcltls1.7.16 /opt/degrib/lib/ (tls is a library built in the prevous step)

  9. Done enjoy!

  10. # You can test by downloading some files (12., below, is an example)  

  11. /opt/degrib/src> cd ../bin

  12. /opt/degrib/bin> tcldegrib /opt/degrib/degrib/bin/web.tcl -dataSet ndfd -sector conus -variable wx -day d17 (or try downloading from the Test Suite)

  13. If you run into an error such as "tcldegrib: error while loading shared libraries: libtk8.6.so: cannot open shared object file: No such file or directory" then:

    • > ldd tcldegrib

    • > LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/degrib/tcltk/lib

 

Useful links: http://www.tcl.tk/software/tcltk/download.htmlhttp://www.tcl.tk/doc/howto/compile.html

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.12) (07/06/2017)

    • Author: Arthur Taylor (MDL/OST/NWS/NOAA)

    • Purpose: Main Program

    • Web Site: Degrib Home

    • 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: https://www.arl.noaa.gov/hysplit/hysplit/

  • 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)

    • Purpose: (Library) Provide low level image drawing capabilities.

    • Web Site: http://www.boutell.com/gd/

    • Depends on: libpng, zlib

  • 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)

    • Purpose: (Library) Provides XML interface for DWML code.

    • Web Site: ftp://xmlsoft.org/

  • Tcl/Tk (optional)

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

 

Troubleshooting (i.e. 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".

DeGRIB