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.&nbsp 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:

Use "/degrib/src/configure" to create several Makefile's from the Makefile.in templates

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::

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:

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

Configure determines setting shared by the following modules:
zlib, libpng, libaat, mdl_g2c, gd,
and degrib. This should create "Makefile" files in each directory

For: jpeg2000, emapf-c, netcdf, and libxml,
it calls 'configure' multiple times to create "Makefile" files for each library.

Complies zlib

Complies libpng

Complies jpeg2000

Complies libaat

Complies mdl_g2c & g2clib

Complies gd

Complies emapf-c

Complies netcdf

Complies dwmllib

Complies libxml

Complies degrib, degrib_DP, clock, drawshp,
tcldegrib, and tkdegrib

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.

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:

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.

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".