Building GrADS under NestedVM from Sources

From OpenGrADS
Jump to: navigation, search

GrADS/VM is a version of GrADS that runs entirely under the Java Virtual Machine. GrADS/VM is based on the same C source code used in the other versions of GrADS and uses NestedVM for binary translation into Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

The NestedVM Toolchain[edit]

As of this writing the NestedVM developers do not provide binaries for the NestedVM toolchain (gcc, g++, linker, etc). Instructions for building NestVM from sources can be found on their website. We have been using a slightly patched version of a 2008 snapshop built on Mac OS X 10.5 (Leopard). It can be downloaded from the OpenGrADS developer site:

It is recommended that you install this tarball under /usr/local

  % cd /usr/local
  % tar xvfz NestedVM_toolchain-macosx-10.5.tar.gz

If you choose to install the NestedVM tool chain in a separate directory make sure to edit and env.csh in the top directory to reflect this fact.

The Supplibs for NestedVM[edit]

A hand built version of the supplibs v2.1.0 have been prepared using the above toolchain on Mac OS X 10.5 (Leopard). It can be downloaded from

Although built on Mac OS X, these supplibs should be portable.

Building GrADS/VM[edit]

This instructions have only been tested with the NestedVM toolchain above on Mac OS X 10.5, although in principle in should work on different operating systems. Needles to say, you must have the Java Development Kit (JDK) installed; make sure that commands java, javac and jar are available. The general procedure is to cross-compile GrADS using NestedVM, followed by compilation of supporting Java classes and assembly of a Java Archive (jar). Start by untar-ing the supplibs

% tar xvfz supplibs-2.1.0-nestedvm.tar.gz

This will create a supplibs/ directory. Next, check out GrADS and make symlink for supplibs:

% mkdir gvm
% cd gvm
% gacvs co -P grads
% ln -s ../supplibs/mips-unknown-nestedvm supplibs

This requires OpenGrADS v2.0.a7.oga.3.1 (of 11/15/2009) or later. Assuming you installed the NestedVM toolchain above, prepare your environment

% source /usr/local/NestedVM/


% source /usr/local/NestedVM/env.csh

and cross-compile

% cd grads
% ./configure --host mips
% make

If you are lucky this will create grads and utilities under src/. The next step is to create the Java Archive

% make java-dist

This will create grads-$version.jar in the top directory.

Testing your build[edit]

Try running this:

% java -jar grads-2.0.a7.oga.3.1.jar

(replace 2.0.a7.oga.3.1 with whatever version you have.)

Outstanding Development Issues[edit]

So far we have been able to build a somewhat limitted version of grads which can read GRIB-1/2, HDF-4 and NetCDF-3. Any attempt to build it more complex libraries (like DAP, HDF-5 and NetCDF-4) ran into a limitation of NestedVM engine: too many symbols. This may be circumveted by tinkering with the NestVM code but it requires a deeper undertanding of it. Another possibility (which I have not explored) is to use the NetCDF Java package and build interfaces to GrADS under NestVM. This runs contrary to the philosophy of building java byte code com C sources, but it may represented a more promising avenue as the NetCDF Java package is feature rich and stable. In any event, the graphics engine is already done in pure Java, so there is some precedence for mixing C/NestedVM code and Java already. If anyone would like to volunteer to further develop this concept please get in touch with the developers.