Source

SHTns /

The default branch has multiple heads

Filename Size Date modified Message
SHT
devtools
150 B
728 B
1.6 KB
607 B
20.6 KB
4.5 KB
51.1 KB
85.2 KB
3.9 KB
2.7 KB
2.6 KB
13.5 KB
64.4 KB
4.5 KB
7.1 KB
2.4 KB
16.6 KB
1.5 KB
1.4 KB
1.7 KB
11.2 KB
1.3 KB
1.6 KB
10.6 KB
4.0 KB
5.8 KB
792 B
21.0 KB
850 B
Run "make docs" to generate documentation with doxygen.
Then browse the html documentation starting with doc/html/index.html

/** \mainpage SHTns : Spherical Harmonic Transform for numerical simulations.
 *
 * SHTns is a library for Spherical Harmonic Transform written in C, aimed at
 * numerical simulation (fluid flows, mhd, ...) in spherical geometries.
 *
 * Available soon under <a href="http://www.cecill.info/index.en.html">CeCILL Licence</a> (GPL compatible french Licence).
 * Send an email to nathanael.schaeffer@ujf-grenoble.fr to be informed on release or request a pre-version.
 *
 * Main features :
 * - both <b>scalar and vector transforms</b>
 * - backward and forward (synthesis and analysis) functions
 * - flexible truncation
 * - spatial data can be stored in latitude-major or longitude-major order arrays.
 * - various conventions (normalization and Condon-Shortley phase)
 * - can be used from <b>fortran or c/c++</b> programs
 * - a highly efficient Gauss algorithm working with <b>Gauss nodes</b> (based on Gauss-Legendre quadrature)
 * - an even faster algorithm using DCT for <b>regular nodes</b> (based on a generalized Fejer quadrature)
 * - support for SSE2, SSE3 and <b>AVX</b> vectorization with gcc.
 * - synthesis (inverse transform) at any coordinate (not constrained to a grid) useful for rendering purposes.
 * - ability to choose the optimal spatial sizes for a given spherical harmonic truncation.
 * - <b>on-the-fly transforms</b> : saving memory and bandwidth, and can even be faster depending on architecture.
 * - accurate up to spherical harmonic degree l=2700 (at least).
 *
 * Using DCT acceleration and other classical \link opt optimizations\endlink, it is intended to be \link bench very fast\endlink.
 *
 * It uses the <a href="http://www.fftw.org/">FFTW</a> library for Fast Fourier Transforms, and is distributed under the open source CeCILL License.
 *
 * \see shtns.h for the definitions of variables, macros and functions.
 * \see The example programs (in \link SHT_example.f Fortran \endlink and \link SHT_example.c C \endlink) to get started.
 * \see The organisation of data used by SHTns is described in \ref spat.
 * \see The description of \ref opt.
 *
 * \author SHTns is written by Nathanael Schaeffer (CNRS)
 *
 * \image html logo_cnrs_small.png
 *
*/


/** \page compil Compiling and installing SHTns

To compile SHTns, you need a C compiler and the FFTW library version 3.3 or later carefully installed.
We recommend using GCC 4.0 or later as it will produce the fastest vectorized code on x86_64 architecture.

You should edit the Makefile to adapt it to your architecture and compiler. In particular, using gcc or icc will not lead to the same performance, and you
should test on your system what gives the best result.

\li type \code make \endcode to compile SHTns. it will produce the library \c libshtns.a

\li type \code make PREFIX=/usr/local install \endcode to install the library in your system (set PREFIX to the desired location, default is $HOME).

\li type \code make docs \endcode to generate this documentation, placed in the doc/html/ subdirectory.

\section cflags Compilation flags and options

A few compilation options can be set in \ref sht_config.h


<b> SHTns uses FFTW. If FFTW has not been compiled and tuned carefuly for your machine, you may get bad performance with SHTns (down to 50% slower !).
Look at the FFTW manual for compilation advice.</b>

*/



/** \page spat Spatial data layouts and grids used by SHTns

The angular coordinates on a spherical shell are the co-latitude \f$ \theta \f$ and the longitude \f$ \phi \f$.

The spatial discretization is defined by a call to \ref shtns_init; or to \ref shtns_set_grid or \ref shtns_set_grid_auto after \ref shtns_create.

A field \e A (or one of its component in case of a vector field) is discretized on an ordered grid, which consists of
 - NPHI equally spaced nodes in longitude, spanning the range of angle between 0 and \f$2\pi\f$/MRES,
 - NLAT gauss nodes or equally spaced nodes (depending on \ref shtns_type) in latitude, spanning angles from 0 to \f$ \pi \f$.

There are constraints on the sizes NLAT and NPHI. The sampling theorem requires NPHI > 2*MMAX, with MMAX the highest Fourier mode to be resolved.
Similarly NLAT > LMAX is required.

When dealing with non-linear equation, or more generally when analysing data that is not band-limited to LMAX and/or MMAX, anti-aliasing constraints
exist. For a given non-linear order of the equation N (typically 2), the anti-aliasing conditions are :
 - NPHI > (N+1)*MMAX
 - NLAT > (N+1)*LMAX/2 for Gauss-Legendre quadrature
 - NLAT > N*LMAX for our DCT quadrature

Furthermore, FFT is more efficient for certain values of NPHI and/or NLAT. If you do not require specific NLAT or NPHI, you can let SHTns choose them
for you, by using \ref shtns_set_grid_auto with nphi and or nlat set to zero.

Identifying a grid point with its indices \c it and \c ip in latitudinal and longitudinal direction respectively (indices start at 0), one has :
 - \f$ \theta \f$ = \c acos(ct[it]) where \ref ct is initialized by the call to \ref shtns_init
 - \f$ \phi \f$ = \c ip * 2\f$\pi\f$/(NPHI*MRES)  and \ref PHI_RAD and \ref PHI_DEG can be used to get the phi angle corresponding to \c ip.
 - How to access \f$ A(\theta,\phi) \f$ depends on the data layout, but it is always <b>a contiguous array of double precision floating point values</b> (64 bit)

Currently, three data layouts are supported. \ref phi_fast, \ref theta_fast, and \ref native.

\section phi_fast Contiguous longitudes

In this layout, increasing longitudes are stored next to each other for each latitude.
That is \f$ A(\theta,\phi) \f$ = \c A[it*NPHI + ip] in C or \c A(ip,it) in Fortran.
Use \ref SHT_PHI_CONTIGUOUS to instruct \ref shtns_init to use this spatial data layout :

\code shtns_init ( sht_gauss | SHT_PHI_CONTIGUOUS, ... ) \endcode will tell shtns to
precompute everything for a gauss nodes in latitude, and spatial data stored with phi varying
fastest.

\section theta_fast Contiguous latitudes

In this layout, increasing latitude are stored next to each other for each longitude.
That is \f$ A(\theta,\phi) \f$ = \c A[ip*NLAT + it] in C or \c A(it,ip) in Fortran.
Use \ref SHT_THETA_CONTIGUOUS to instruct \ref shtns_init to use this spatial data layout.

\section native Native layout

The native way of storing spatial field data (which will help you achieve the best performance with SHTns)
is the same as the \ref theta_fast layout, except that it requires you to allocate slightly more
memory for a field than the NLAT*NPHI double values.
Namely NLAT*(NPHI/2+1)*2 doubles are required (instead of NLAT*NPHI) to be able tu use the in-place FFT of FFTW.

In Fortran this means you will allocate data as if the phi direction had (NPHI/2+1)*2 points instead fo NPHI.
The aditional space, is located at the end of the useful data, and you don't need to worry about it.

To instruct \ref shtns_init that your spatial data has been set up using this layout, use \ref SHT_NATIVE_LAYOUT.

One must be careful when allocating spatial data, as the Fourier transform requires some aditional space.\n Precisely, the number
of required \c double is \ref NSPAT_ALLOC = NLAT*(NPHI/2+1)*2. The first NLAT*NPHI values are the spatial data.

In addition, spatial data must be allocated using the \c fftw_malloc function, for example using :
\code A = fftw_malloc( NSPAT_ALLOC * sizeof(double) );\endcode


*/


/** \page spec Spherical Harmonics storage and normalization

\section spec_data Spherical Harmonic coefficients layout

<b>The collection of Alm (spherical harmonics coefficient of degree \e l and order \e m) is stored in an array of \c complex \c double floating point values.</b>
The spherical harmonic truncation is defined by a call to \ref shtns_init or to \ref shtns_create which returns the size NLM of the array.

The field \em A is decomposed on the basis of spherical harmonics Ylm (degree \e l, order \e m) :
\f[ A(\theta,\phi) = \sum_{l,m} A_l^m Y_l^m(\theta,\phi)\f]
The series is truncated at degree LMAX and order MMAX*MRES,
and only order that are multiple of MRES are described.

The NLM coefficients Alm are stored in a one-dimensional array, grouped by \e m.\n
The details of the storage may depend on the algorithm, and to access a particular coefficient, you should always use the following macros :
 - \ref LM(l,m) gives the index in the array for coefficient of degree \e l and order \e m.
 - \ref LiM(l,im) gives the index in the array for coefficient of degree \e l and order \e im*MRES.

Hence \c Alm[LM(l,m)] is the SH coefficient of degree \e l and order \e m.

\note Since SHTns only deals with real spatial data, the Spherical Harmonic coefficients wiht negative \e m are the complex conjugate of the
positive \e m coefficents : \f$ A_l^{-m} = (A_l^m)^*\f$. For efficiency purposes, only the coefficients with positive \e m are stored.

\note There is no test on bounds, so that LM(l,m) with \e l or \e m that is not described, will give undefined result
(in particular for an \e m that is not a multiple of \c MRES)

To perform loops on all coefficients, use the macros \ref LM_LOOP and \ref LM_L_LOOP
in combination of the arrays \ref li, \ref el and \ref l2 which give the degree \e l and functions of it for any array index.

\section Allocation
Allocation for a SH description is simply done with :
\code Alm = fftw_malloc( NLM * sizeof(complex double) );\endcode
The use of fftw_malloc ensures proper alignement of data for SSE vectorization.

\section norm Normalization

Several normalizations for the spherical harmonics exist (<a href="http://en.wikipedia.org/wiki/Spherical_harmonics#Conventions">details on wikipedia</a>).
SHTns lets you choose one of the following :
<ul>
<li><b>Orthonormalized</b> is the default (also used in the <a href="http://www.gnu.org/software/gsl/">GSL</a>)

\f[ Y_l^m(\theta, \phi) = \sqrt{\frac{2l+1}{4\pi}} \sqrt{\frac{(l-m)!}{(l+m)!}} \, P_l^m(\cos \theta) \, \exp(im\phi) \f]

</li><li><b>Four-pi normalized</b>

\f[ Y_l^m(\theta, \phi) = \sqrt{2l+1} \sqrt{\frac{(l-m)!}{(l+m)!}} \, P_l^m(\cos \theta) \, \exp(im\phi) \f]

</li><li><b>Schmidt semi-normalized</b>

\f[ Y_l^m(\theta, \phi) = \sqrt{\frac{(l-m)!}{(l+m)!}} \, P_l^m(\cos \theta) \, \exp(im\phi) \f]

</li></ul>

\ref shtns_init uses the default (defined by \ref SHT_DEFAULT_NORM) but you can choose another normalization
by calling \ref shtns_create instead.

The legendre associated functions are defined by :

\f[ P_l^m (x) = (-1)^m\ (1-x^2)^{m/2}\ \frac{d^m}{dx^m}P_l(x) \f]

which includes the Condon-Shortley phase \f$ (-1)^m \f$ by default.

For reference, function \ref SH_to_point gives a simple explicit implementation of the inverse SH transform (synthesis).

\subsection norm_opt Normalization variations

Use \ref shtns_create with \ref SHT_NO_CS_PHASE to disable the <b>Condon-Shortley phase</b>.
For example, to initialize a Schmidt semi-normalized transform of maximum degree 16 without Condon-Shortrley phase, use
\code shtns_create(16, 16, 1, sht_schmidt | SHT_NO_CS_PHASE); \endcode

By default, SHTns uses "complex" spherical harmonic normalization. However, as it deals only with real functions,
the m<0 coefficients are not stored, since they are complex conjugate of the m>0 ones.
Thus, one must pay attention, that the m>0 coefficient have to be counted twice in a total energy calculation.

An alternative to this "complex" normalization is the "real" normalization, for which the energy is simply
the sum of the coefficients (m>=0) squared. Use \ref shtns_create with \ref SHT_REAL_NORM to use a "real" spherical harmonic normalization.
This is the usual "real" spherical harmonics, if one takes the complex conjugate of the coefficients.

A few useful examples, for orthonormal spherical harmonics :
 - a constant unit value on the sphere is represented by the coefficient \f$ c_0^0 = \sqrt{4\pi} \f$.
 - \f$ \cos \theta \f$ is represented by the coefficient \f$ c_1^0 = \sqrt{4\pi/3} \f$.
 - \f$ \sin \theta \, \cos \phi \f$ is represented by \f$ c_1^1 =  -\sqrt{2\pi/3} \f$ (with Condon-Shortley phase)
 - with a "real" normalization instead, one would have \f$ c_1^1 = -\sqrt{4\pi/3} = -c_1^0 \f$.

The functions \ref sh00_1(), \ref sh10_ct(), \ref sh11_st() will help to build simple
spectral fields, no matter what normalization you choose.

\subsection Troubleshooting
If you have problem in getting your spherical harmonic coefficient right, you may check the following :
 - Schmit semi-normalization ? try multiplying or dividing by \f$ \sqrt{2l+1} \f$
 - Condon-Shortley phase ? try multiplying by \f$ (-1)^m \f$
 - Real or Complex ? try multiplying or dividing the m>0 coefficients by \f$ \sqrt{2} \f$
 - Relative sign ? try to take the complex conjugate of the coefficients.
 - Does the array include l=0 ?

*/



/** \page opt Optimizations implemented in SHTns

SHTns is an implementation of the Spherical Harmonic Transform which aims at being accurate and fast,
with direct numerical simulations in mind. As such, the following optimizations are implemented :

\section opt_fft Use the Fast-Fourier Transform

Any serious SHT should use the FFT, as it improves accuracy and speed.
SHTns uses the <a href="http://www.fftw.org/">FFTW library</a> for the fast Fourier transform, a portable,
flexible and blazingly fast FFT implementation.

\section opt_mirror Take advantage of mirror symmetry

This is also a classical optimization. Due to the defined symmetry of spherical harmonics with respect
to a reflexion about the equator, one can reduce by a factor 2 the operation count of both direct and reverse
transforms.

\section opt_polar Polar optimization

A less common, but still classic optimization : high m's spherical harmonics have their magnitude descrease exponentially
when aproaching the poles. SHTns use a threshold below which the SH is taken to be zero.
The default value for this threshold is defined by \ref SHT_DEFAULT_POLAR_OPT,
but you can also choose it with the \c eps parameter of the \ref shtns_set_grid function,
trading some accuracy for more speed.
Around 5% to 15% speed increase are typical values for a SHT with a large MMAX.

\section opt_cache Cache optimizations

Cache optimizations have been carried out throughout the code.
This means ordering coefficients and stripping out systematic zeros.

\section opt_size Spatial Size optimization

When using \ref shtns_set_grid_auto, you can let SHTns choose the optimal spatial sizes for
the spherical harmonic truncation you specified with \ref shtns_create.
The spatial sizes are chosen so that no aliasing occurs, and ensuring FFTW will perform as fast
as possible.

\section opt_dct Discrete Cosine Transform optimization

This is a non-trivial optimization mostly efficient on small m's,
which can significantly decrease the operation count.

It can be noticed that Spherical Harmonics are polynomials
of order \f$ l \f$ in \f$ \cos \theta \f$ (multiplied by \f$ \sin \theta \f$ for odd m's).
Thus, going to DCT space and summing there can help to further reduce the number of operations.

Using a DCT requires a regular grid instead of the usual Gauss grid, and this
means doubling the number of grid points to keep an equally accurate quadrature (Tchebychev quadrature), reducing
the performance gain from the DCT to zero, when not performing worse.

However, SHTns uses a quadrature inspired by the Fejer quadrature (or Clenshaw-Curtis), which allows exact result
using only one more grid-point than the classical Gauss-Legendre quadrature.
This allows SHTns to efficiently use the DCT optimization, but also to use regular grids with
almost half the grid points as usual.

The theoretical result is that for a function band-limited by L, L+2 equispaced grid-points allow us
to fully recover the spectral content.
There is, however, a drawback for non-linear terms : for a product of two functions band-limited to L,
we would require L*2+2 grid points, whereas the Gauss-Legendre quadrature would only require (L+1)*3/2 grid-points if we
are interested in only the first L modes of the product.

There is a slight loss of accuracy due to round-off errors (as an example, relative errors
with DCT are around \c 1.e-11 instead of \c 1.e-12 without for lmax around 500).
If you can live with it (you really should), the DCT-based algorithm performs much faster on small m's :
twice to four times faster for axisymmetric transforms, and between 1.5 and 1.2 times faster on non-axisymmetric ones.
For large m's however, the spatial-domain polar optimization takes the lead.

Note also that the DCT algorithm, while beeing usually faster, requires significantly larger init time. It
is then suitable for performing many transforms (as in a direct numerical simulations).

\section opt_runtime Runtime tuning of algorithm

The default mode used by SHTns is to measure performance of the different algorithms, and choose
the one that performs best (it will also check that the accuracy is good enough).
However, there are situation where either the Gauss-Legendre algorithm or a regular grid is required, and you
can choose to do so using the adequate \ref shtns_type when calling \ref shtns_init or \ref shtns_set_grid.

*/

/** \page bench Speed and Accuracy

\section Speed

SHTns does not implement any "fast" algorithm. However, timings with other Spherical Harmonic Transform tools (including a fast algorithm)
show that <b>SHTns performs much faster than any other</b> (non-parallel). Furthermore, even at large sizes, the fast algorithm we tested does not seem to be willing to take the lead.

<div>
<table><tr>
<td>\f$\ell_{max}\f$</td> <td><a href="http://www.ipgp.fr/~wieczor/SHTOOLS/SHTOOLS.html">shtools</a> 2.5 (Gauss)</td>
  <td><a href="http://sourceforge.net/projects/libpsht/">libpsht</a> (1 thread)</td>
  <td><a href="http://sourceforge.net/projects/libpsht/">libpsht</a> (8 parallel threads)</td>
  <td><a href="http://www.cs.dartmouth.edu/~geelong/sphere/">SpharmonicKit2</a> 2.7 (fast)</td>
  <td><b>SHTns*</b> (Gauss)</td> <td>SHTns/SpharmonicKit2</td> </tr><tr>
<td>127 </td> <td>8.9 ms</td> <td> 5.3 ms</td> <td> 10-80 ms </td> <td>5.5 ms</td>  <td><b>0.67 ms</b></td>  <td>8.2</td> </tr><tr>
<td>255 </td> <td>73 ms</td> <td> 29 ms</td> <td> 20-90ms </td> <td>27 ms</td>  <td><b>4.8 ms</b></td>  <td>5.6</td> </tr><tr>
<td>511 </td> <td>757 ms</td> <td>170 ms </td> <td>40-116 ms</td> <td>143 ms</td>  <td><b>34 ms</b></td>  <td>4.2</td> </tr><tr>
<td>1023 </td> <td>10.3 s</td> <td>1.1 s </td> <td> 130-300 ms</td> <td>860 ms</td>  <td><b>252 ms</b></td>  <td>3.4</td> </tr><tr>
<td>2047 </td> <td>NA (too slow)</td> <td>5.9 s</td> <td>0.8-0.9 s</td> <td>NA (out of memory)</td>  <td><b>2.4 s</b></td>  <td>NA</td> </tr></table>

<i>Average times for forward or backward scalar transform on an Intel Xeon E5520 (2.27GHz), with gcc 4.1.2 and "-O3 -march=core2" compilation options.</i>
<br/>*) with gcc 4.4.4
</div>

\section Accuracy

We claim that the accuracy of SHTns is as good as it can be with double precision floating point math.
For example, at LMAX=600, MMAX=600, MRES=1, a back and forth transform on random spherical harmonic coefficients, gives the following results.

\li scalar transform, polar_opt=0 : maximum error < 1.0e-12,  rms error < 1.0e-13
\li vector transform, polar_opt=0 : maximum error < 1.0e-11,  rms error < 1.0e-13
\li vector transform, polar_opt=1.0e-8 : maximum error < 2.0e-11,  rms error < 1.0e-13, but about <b>10% faster</b>.
\li vector transform, polar_opt=1.0e-8, DCT : maximum error < 1.0e-10,  rms error < 1.0e-12, but about <b>20% faster</b>.

Don't trust our word, these results are obtained by running the time_SHT program, shipped with SHTns :
\code
make time_SHT
./time_SHT 600 -iter=1 -nlorder=1 -polaropt=0 -quickinit
\endcode

SHTns has been tested on x86 architecture with SSE2 double precision floating point math (64 bit) to be <b>accurate up to l=2700</b>.

*/

/** \page usage Using SHTns in a C program

To make SHTns known by your C program, add
\code
#include <fftw3.h>
#include <shtns.h>
\endcode
in the preamble of your source file.

First of all you need to initialize SHTns. There are two ways to do this :
\li calling \ref shtns_init function,
\li or calling \ref shtns_create followed by \ref shtns_set_grid. This way lets you choose normalization and optimization.

Note that you can call initialization function(s) only once.
Then you must allocate some memory (with fftw_malloc so that the memory is properly aligned for vectorized code),
and finaly you can perform some spherical harmonic transforms.

\see Look at shtns.h for the function definitions and documentation.
\see See the \link SHT_example.c C example \endlink for a simple usage of SHTns in a C program.

When your program is ready, compile it adding these options to the compiler (gcc) :
\code
-L/path/to/lib/ -I/path/to/include/ -lshtns -lfftw3 -lm
\endcode

*/


/** \page f77 Using SHTns with Fortran 77

SHTns provides an interface to Fortran language (compatible with gfortran).

First of all you need to initialize SHTns. There are two ways to do this :
\li calling one of the shtns_init_* subroutines,
\li or calling shtns_create followed by shtns_set_grid. This way lets you choose normalization and optimization.

Note that you can call initialization function(s) only once.
Then you must allocate some memory, and finaly you can perform some spherical harmonic transforms.

\see See The full reference of the \ref fortapi
\see See the \link SHT_example.f Fortran example \endlink for a simple usage of SHTns from Fortran language.

When your program is ready, compile it adding these options to the compiler (gfortran) :
\code
-L/path/to/lib/ -I/path/to/include/ -lshtns -lfftw3 -lm -lc
\endcode

\example SHT_example.f
  \brief A Fortran example program that performs backward and forward Spherical Harmonic Transforms using SHTns.

  Compile using : \code make SHT_fort_ex \endcode
  \see fortapi
  \see \ref f77

*/

/** \page python Using SHTns with Python

<b>This is a preliminary Python interface, do not expect too much !</b>
SHTns provides a Python interface, for interactive use of the spherical harmonic transform.
It uses swig to generate the Python interface.


\li Compile using \code make python \endcode

\li Use within a python script or shell in the same directory \code from shtns import * \endcode

The functions available are the same as the \link usage C interface \endlink, plus some memory allocation functions...

*/


/** \page license License

\htmlonly

<style type="text/css">
     h1.title {color: #008080; font-size: 200%; text-align: center}
     h2 {color: #008080; font-size: 150%}
     h3 {color: #008080; font-size: 140%}
     h4 {color: #008080; font-size: 120%}
     h5 {color: #008080; font-size: 100%}
     span.numbering {color: #008080}
     span.definition {font-weight: bold}
     div.version {font-style: italic}
     div.footnote {font-size: 80%}
     ins {text-decoration: underline; background: #AAFFA4}
     div.added {text-decoration: underline; background: #AAFFA4}
     del {text-decoration:line-through; background: #8F8F8F}
     div.deleted {text-decoration:line-through; background: #8F8F8F}
  </style>

  <h1 class="title">CeCILL FREE SOFTWARE LICENSE AGREEMENT</h1>

  <div class="notice">
    <h2>Notice</h2>

    <p>This Agreement is a Free Software license agreement that is the result of
    discussions between its authors in order to ensure compliance with the two main
    principles guiding its drafting:</p>

    <ul>
      <li>firstly, compliance with the principles governing the distribution of Free
      Software: access to source code, broad rights granted to users,</li>

      <li>secondly, the election of a governing law, French law, with which it is
      conformant, both as regards the law of torts and intellectual property law, and the
      protection that it offers to both authors and holders of the economic rights over
      software.</li>
    </ul>

    <p>The authors of the CeCILL<sup><a href="#footnote1">1</a></sup> license are:</p>

    <p>Commissariat &agrave; l'Energie Atomique - CEA, a public scientific, technical and
    industrial research establishment, having its principal place of business at 25 rue
    Leblanc, immeuble Le Ponant D, 75015 Paris, France.</p>

    <p>Centre National de la Recherche Scientifique - CNRS, a public scientific and
    technological establishment, having its principal place of business at 3 rue
    Michel-Ange, 75794 Paris cedex 16, France.</p>

    <p>Institut National de Recherche en Informatique et en Automatique - INRIA, a public
    scientific and technological establishment, having its principal place of business at
    Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay cedex, France.</p>
  </div>

  <div class="preamble">
    <h2>Preamble</h2>

    <p>The purpose of this Free Software license agreement is to grant users the right to
    modify and redistribute the software governed by this license within the framework of
    an open source distribution model.</p>

    <p>The exercising of these rights is conditional upon certain obligations for users
    so as to preserve this status for all subsequent redistributions.</p>

    <p>In consideration of access to the source code and the rights to copy, modify and
    redistribute granted by the license, users are provided only with a limited warranty
    and the software's author, the holder of the economic rights, and the successive
    licensors only have limited liability.</p>

    <p>In this respect, the risks associated with loading, using, modifying and/or
    developing or reproducing the software by the user are brought to the user's
    attention, given its Free Software status, which may make it complicated to use, with
    the result that its use is reserved for developers and experienced professionals
    having in-depth computer knowledge. Users are therefore encouraged to load and test
    the suitability of the software as regards their requirements in conditions enabling
    the security of their systems and/or data to be ensured and, more generally, to use
    and operate it in the same conditions of security. This Agreement may be freely
    reproduced and published, provided it is not altered, and that no provisions are
    either added or removed herefrom.</p>

    <p>This Agreement may apply to any or all software for which the holder of the
    economic rights decides to submit the use thereof to its provisions.</p>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">1</span> - DEFINITIONS</h2>

    <p>For the purpose of this Agreement, when the following expressions commence with a
    capital letter, they shall have the following meaning:</p>

    <p class="definition"><span class="definition">Agreement</span>: means this license
    agreement, and its possible subsequent versions and annexes.</p>

    <p class="definition"><span class="definition">Software</span>: means the software in
    its Object Code and/or Source Code form and, where applicable, its documentation, "as
    is" when the Licensee accepts the Agreement.</p>

    <p class="definition"><span class="definition">Initial Software</span>: means the
    Software in its Source Code and possibly its Object Code form and, where applicable,
    its documentation, "as is" when it is first distributed under the terms and
    conditions of the Agreement.</p>

    <p class="definition"><span class="definition">Modified Software</span>: means the
    Software modified by at least one Contribution.</p>

    <p class="definition"><span class="definition">Source Code</span>: means all the
    Software's instructions and program lines to which access is required so as to modify
    the Software.</p>

    <p class="definition"><span class="definition">Object Code</span>: means the binary
    files originating from the compilation of the Source Code.</p>

    <p class="definition"><span class="definition">Holder</span>: means the holder(s) of
    the economic rights over the Initial Software.</p>

    <p class="definition"><span class="definition">Licensee</span>: means the Software
    user(s) having accepted the Agreement.</p>

    <p class="definition"><span class="definition">Contributor</span>: means a Licensee
    having made at least one Contribution.</p>

    <p class="definition"><span class="definition">Licensor</span>: means the Holder, or
    any other individual or legal entity, who distributes the Software under the
    Agreement.</p>

    <p class="definition"><span class="definition">Contribution</span>: means any or all
    modifications, corrections, translations, adaptations and/or new functions integrated
    into the Software by any or all Contributors, as well as any or all Internal
    Modules.</p>

    <p class="definition"><span class="definition">Module</span>: means a set of sources
    files including their documentation that enables supplementary functions or services
    in addition to those offered by the Software.</p>

    <p class="definition"><span class="definition">External Module</span>: means any or
    all Modules, not derived from the Software, so that this Module and the Software run
    in separate address spaces, with one calling the other when they are run.</p>

    <p class="definition"><span class="definition">Internal Module</span>: means any or
    all Module, connected to the Software so that they both execute in the same address
    space.</p>

    <p class="definition"><span class="definition">GNU GPL</span>: means the GNU General
    Public License version 2 or any subsequent version, as published by the Free Software
    Foundation Inc.</p>

    <p class="definition"><span class="definition">Parties</span>: mean both the Licensee
    and the Licensor.</p>

    <p>These expressions may be used both in singular and plural form.</p>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">2</span> - PURPOSE</h2>

    <p>The purpose of the Agreement is the grant by the Licensor to the Licensee of a
    non-exclusive, transferable and worldwide license for the Software as set forth in
    Article <a href="#scope"><span class="numbering">5</span></a> hereinafter for the
    whole term of the protection granted by the rights over said Software.</p>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">3</span> - ACCEPTANCE</h2>

    <div class="clause">
      <p><a name="accepting" id="accepting"></a><span class="numbering">3.1</span> The
      Licensee shall be deemed as having accepted the terms and conditions of this
      Agreement upon the occurrence of the first of the following events:</p>

      <ul>
        <li>(i) loading the Software by any or all means, notably, by downloading from a
        remote server, or by loading from a physical medium;</li>

        <li>(ii) the first time the Licensee exercises any of the rights granted
        hereunder.</li>
      </ul>
    </div>

    <div class="clause">
      <p><span class="numbering">3.2</span> One copy of the Agreement, containing a
      notice relating to the characteristics of the Software, to the limited warranty,
      and to the fact that its use is restricted to experienced users has been provided
      to the Licensee prior to its acceptance as set forth in Article <a href=
      "#accepting"><span class="numbering">3.1</span></a> hereinabove, and the Licensee
      hereby acknowledges that it has read and understood it.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">4</span> - EFFECTIVE DATE AND TERM</h2>

    <div class="clause">
      <h3><span class="numbering">4.1</span> EFFECTIVE DATE</h3>

      <p>The Agreement shall become effective on the date when it is accepted by the
      Licensee as set forth in Article <a href="#accepting"><span class=
      "numbering">3.1</span></a>.</p>
    </div>

    <div class="clause">
      <h3><a name="term" id="term"></a><span class="numbering">4.2</span> TERM</h3>

      <p>The Agreement shall remain in force for the entire legal term of protection of
      the economic rights over the Software.</p>
    </div>
  </div>

  <div class="article">
    <h2><a name="scope" id="scope"></a> Article <span class="numbering">5</span> - SCOPE
    OF RIGHTS GRANTED</h2>

    <p>The Licensor hereby grants to the Licensee, who accepts, the following rights over
    the Software for any or all use, and for the term of the Agreement, on the basis of
    the terms and conditions set forth hereinafter.</p>

    <p>Besides, if the Licensor owns or comes to own one or more patents protecting all
    or part of the functions of the Software or of its components, the Licensor
    undertakes not to enforce the rights granted by these patents against successive
    Licensees using, exploiting or modifying the Software. If these patents are
    transferred, the Licensor undertakes to have the transferees subscribe to the
    obligations set forth in this paragraph.</p>

    <div class="clause">
      <h3><span class="numbering">5.1</span> RIGHT OF USE</h3>

      <p>The Licensee is authorized to use the Software, without any limitation as to its
      fields of application, with it being hereinafter specified that this comprises:</p>

      <ol>
        <li>
          <p>permanent or temporary reproduction of all or part of the Software by any or
          all means and in any or all form.</p>
        </li>

        <li>
          <p>loading, displaying, running, or storing the Software on any or all
          medium.</p>
        </li>

        <li>
          <p>entitlement to observe, study or test its operation so as to determine the
          ideas and principles behind any or all constituent elements of said Software.
          This shall apply when the Licensee carries out any or all loading, displaying,
          running, transmission or storage operation as regards the Software, that it is
          entitled to carry out hereunder.</p>
        </li>
      </ol>
    </div>

    <div class="clause">
      <h3><span class="numbering">5.2</span> ENTITLEMENT TO MAKE CONTRIBUTIONS</h3>

      <p>The right to make Contributions includes the right to translate, adapt, arrange,
      or make any or all modifications to the Software, and the right to reproduce the
      resulting software.</p>

      <p>The Licensee is authorized to make any or all Contributions to the Software
      provided that it includes an explicit notice that it is the author of said
      Contribution and indicates the date of the creation thereof.</p>
    </div>

    <div class="clause">
      <h3><span class="numbering">5.3</span> RIGHT OF DISTRIBUTION</h3>

      <p>In particular, the right of distribution includes the right to publish, transmit
      and communicate the Software to the general public on any or all medium, and by any
      or all means, and the right to market, either in consideration of a fee, or free of
      charge, one or more copies of the Software by any means.</p>

      <p>The Licensee is further authorized to distribute copies of the modified or
      unmodified Software to third parties according to the terms and conditions set
      forth hereinafter.</p>

      <div class="subclause">
        <h4><span class="numbering">5.3.1</span> DISTRIBUTION OF SOFTWARE WITHOUT
        MODIFICATION</h4>

        <p>The Licensee is authorized to distribute true copies of the Software in Source
        Code or Object Code form, provided that said distribution complies with all the
        provisions of the Agreement and is accompanied by:</p>

        <ol>
          <li>
            <p>a copy of the Agreement,</p>
          </li>

          <li>
            <p>a notice relating to the limitation of both the Licensor's warranty and
            liability as set forth in Articles 8 and 9,</p>
          </li>
        </ol>

        <p>and that, in the event that only the Object Code of the Software is
        redistributed, the Licensee allows future Licensees unhindered access to the full
        Source Code of the Software by indicating how to access it, it being understood
        that the additional cost of acquiring the Source Code shall not exceed the cost
        of transferring the data.</p>
      </div>

      <div class="subclause">
        <h4><span class="numbering">5.3.2</span> DISTRIBUTION OF MODIFIED SOFTWARE</h4>

        <p>When the Licensee makes a Contribution to the Software, the terms and
        conditions for the distribution of the resulting Modified Software become subject
        to all the provisions of this Agreement.</p>

        <p>The Licensee is authorized to distribute the Modified Software, in source code
        or object code form, provided that said distribution complies with all the
        provisions of the Agreement and is accompanied by:</p>

        <ol>
          <li>
            <p>a copy of the Agreement,</p>
          </li>

          <li>
            <p>a notice relating to the limitation of both the Licensor's warranty and
            liability as set forth in Articles 8 and 9,</p>
          </li>
        </ol>

        <p>and that, in the event that only the object code of the Modified Software is
        redistributed, the Licensee allows future Licensees unhindered access to the full
        source code of the Modified Software by indicating how to access it, it being
        understood that the additional cost of acquiring the source code shall not exceed
        the cost of transferring the data.</p>
      </div>

      <div class="subclause">
        <h4><span class="numbering">5.3.3</span> DISTRIBUTION OF EXTERNAL MODULES</h4>

        <p>When the Licensee has developed an External Module, the terms and conditions
        of this Agreement do not apply to said External Module, that may be distributed
        under a separate license agreement.</p>
      </div>

      <div class="subclause">
        <h4><a name="compatibility" id="compatibility"></a><span class=
        "numbering">5.3.4</span> COMPATIBILITY WITH THE GNU GPL</h4>

        <p>The Licensee can include a code that is subject to the provisions of one of
        the versions of the GNU GPL in the Modified or unmodified Software, and
        distribute that entire code under the terms of the same version of the GNU
        GPL.</p>

        <p>The Licensee can include the Modified or unmodified Software in a code that is
        subject to the provisions of one of the versions of the GNU GPL, and distribute
        that entire code under the terms of the same version of the GNU GPL.</p>
      </div>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">6</span> - INTELLECTUAL PROPERTY</h2>

    <div class="clause">
      <h3><span class="numbering">6.1</span> OVER THE INITIAL SOFTWARE</h3>

      <p>The Holder owns the economic rights over the Initial Software. Any or all use of
      the Initial Software is subject to compliance with the terms and conditions under
      which the Holder has elected to distribute its work and no one shall be entitled to
      modify the terms and conditions for the distribution of said Initial Software.</p>

      <p>The Holder undertakes that the Initial Software will remain ruled at least by
      this Agreement, for the duration set forth in Article <a href="#term"><span class=
      "numbering">4.2</span></a>.</p>
    </div>

    <div class="clause">
      <h3><span class="numbering">6.2</span> OVER THE CONTRIBUTIONS</h3>

      <p>The Licensee who develops a Contribution is the owner of the intellectual
      property rights over this Contribution as defined by applicable law.</p>
    </div>

    <div class="clause">
      <h3><span class="numbering">6.3</span> OVER THE EXTERNAL MODULES</h3>

      <p>The Licensee who develops an External Module is the owner of the intellectual
      property rights over this External Module as defined by applicable law and is free
      to choose the type of agreement that shall govern its distribution.</p>
    </div>

    <div class="clause">
      <h3><a name="mention" id="mention"></a><span class="numbering">6.4</span> JOINT
      PROVISIONS</h3>

      <div class="subclause">
        <p>The Licensee expressly undertakes:</p>

        <ol>
          <li>
            <p>not to remove, or modify, in any manner, the intellectual property notices
            attached to the Software;</p>
          </li>

          <li>
            <p>to reproduce said notices, in an identical manner, in the copies of the
            Software modified or not.</p>
          </li>
        </ol>
      </div>

      <div class="subclause">
        <p>The Licensee undertakes not to directly or indirectly infringe the
        intellectual property rights of the Holder and/or Contributors on the Software
        and to take, where applicable, vis-&agrave;-vis its staff, any and all measures
        required to ensure respect of said intellectual property rights of the Holder
        and/or Contributors.</p>
      </div>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">7</span> - RELATED SERVICES</h2>

    <div class="clause">
      <p><span class="numbering">7.1</span> Under no circumstances shall the Agreement
      oblige the Licensor to provide technical assistance or maintenance services for the
      Software.</p>

      <p>However, the Licensor is entitled to offer this type of services. The terms and
      conditions of such technical assistance, and/or such maintenance, shall be set
      forth in a separate instrument. Only the Licensor offering said maintenance and/or
      technical assistance services shall incur liability therefor.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">7.2</span> Similarly, any Licensor is entitled to offer
      to its licensees, under its sole responsibility, a warranty, that shall only be
      binding upon itself, for the redistribution of the Software and/or the Modified
      Software, under terms and conditions that it is free to decide. Said warranty, and
      the financial terms and conditions of its application, shall be subject of a
      separate instrument executed between the Licensor and the Licensee.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">8</span> - LIABILITY</h2>

    <div class="clause">
      <p><span class="numbering">8.1</span> Subject to the provisions of Article 8.2, the
      Licensee shall be entitled to claim compensation for any direct loss it may have
      suffered from the Software as a result of a fault on the part of the relevant
      Licensor, subject to providing evidence thereof.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">8.2</span> The Licensor's liability is limited to the
      commitments made under this Agreement and shall not be incurred as a result of in
      particular: (i) loss due the Licensee's total or partial failure to fulfill its
      obligations, (ii) direct or consequential loss that is suffered by the Licensee due
      to the use or performance of the Software, and (iii) more generally, any
      consequential loss. In particular the Parties expressly agree that any or all
      pecuniary or business loss (i.e. loss of data, loss of profits, operating loss,
      loss of customers or orders, opportunity cost, any disturbance to business
      activities) or any or all legal proceedings instituted against the Licensee by a
      third party, shall constitute consequential loss and shall not provide entitlement
      to any or all compensation from the Licensor.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">9</span> - WARRANTY</h2>

    <div class="clause">
      <p><span class="numbering">9.1</span> The Licensee acknowledges that the scientific
      and technical state-of-the-art when the Software was distributed did not enable all
      possible uses to be tested and verified, nor for the presence of possible defects
      to be detected. In this respect, the Licensee's attention has been drawn to the
      risks associated with loading, using, modifying and/or developing and reproducing
      the Software which are reserved for experienced users.</p>

      <p>The Licensee shall be responsible for verifying, by any or all means, the
      suitability of the product for its requirements, its good working order, and for
      ensuring that it shall not cause damage to either persons or properties.</p>
    </div>

    <div class="clause">
      <p><a name="good-faith" id="good-faith"></a><span class="numbering">9.2</span> The
      Licensor hereby represents, in good faith, that it is entitled to grant all the
      rights over the Software (including in particular the rights set forth in Article
      <a href="#scope"><span class="numbering">5</span></a>).</p>
    </div>

    <div class="clause">
      <p><span class="numbering">9.3</span> The Licensee acknowledges that the Software
      is supplied "as is" by the Licensor without any other express or tacit warranty,
      other than that provided for in Article <a href="#good-faith"><span class=
      "numbering">9.2</span></a> and, in particular, without any warranty as to its
      commercial value, its secured, safe, innovative or relevant nature.</p>

      <p>Specifically, the Licensor does not warrant that the Software is free from any
      error, that it will operate without interruption, that it will be compatible with
      the Licensee's own equipment and software configuration, nor that it will meet the
      Licensee's requirements.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">9.4</span> The Licensor does not either expressly or
      tacitly warrant that the Software does not infringe any third party intellectual
      property right relating to a patent, software or any other property right.
      Therefore, the Licensor disclaims any and all liability towards the Licensee
      arising out of any or all proceedings for infringement that may be instituted in
      respect of the use, modification and redistribution of the Software. Nevertheless,
      should such proceedings be instituted against the Licensee, the Licensor shall
      provide it with technical and legal assistance for its defense. Such technical and
      legal assistance shall be decided on a case-by-case basis between the relevant
      Licensor and the Licensee pursuant to a memorandum of understanding. The Licensor
      disclaims any and all liability as regards the Licensee's use of the name of the
      Software. No warranty is given as regards the existence of prior rights over the
      name of the Software or as regards the existence of a trademark.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">10</span> - TERMINATION</h2>

    <div class="clause">
      <p><span class="numbering">10.1</span> In the event of a breach by the Licensee of
      its obligations hereunder, the Licensor may automatically terminate this Agreement
      thirty (30) days after notice has been sent to the Licensee and has remained
      ineffective.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">10.2</span> A Licensee whose Agreement is terminated
      shall no longer be authorized to use, modify or distribute the Software. However,
      any licenses that it may have granted prior to termination of the Agreement shall
      remain valid subject to their having been granted in compliance with the terms and
      conditions hereof.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">11</span> - MISCELLANEOUS</h2>

    <div class="clause">
      <h3><span class="numbering">11.1</span> EXCUSABLE EVENTS</h3>

      <p>Neither Party shall be liable for any or all delay, or failure to perform the
      Agreement, that may be attributable to an event of force majeure, an act of God or
      an outside cause, such as defective functioning or interruptions of the electricity
      or telecommunications networks, network paralysis following a virus attack,
      intervention by government authorities, natural disasters, water damage,
      earthquakes, fire, explosions, strikes and labor unrest, war, etc.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">11.2</span> Any failure by either Party, on one or more
      occasions, to invoke one or more of the provisions hereof, shall under no
      circumstances be interpreted as being a waiver by the interested Party of its right
      to invoke said provision(s) subsequently.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">11.3</span> The Agreement cancels and replaces any or
      all previous agreements, whether written or oral, between the Parties and having
      the same purpose, and constitutes the entirety of the agreement between said
      Parties concerning said purpose. No supplement or modification to the terms and
      conditions hereof shall be effective as between the Parties unless it is made in
      writing and signed by their duly authorized representatives.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">11.4</span> In the event that one or more of the
      provisions hereof were to conflict with a current or future applicable act or
      legislative text, said act or legislative text shall prevail, and the Parties shall
      make the necessary amendments so as to comply with said act or legislative text.
      All other provisions shall remain effective. Similarly, invalidity of a provision
      of the Agreement, for any reason whatsoever, shall not cause the Agreement as a
      whole to be invalid.</p>
    </div>

    <div class="clause">
      <h3><span class="numbering">11.5</span> LANGUAGE</h3>

      <p>The Agreement is drafted in both French and English and both versions are deemed
      authentic.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">12</span> - NEW VERSIONS OF THE AGREEMENT</h2>

    <div class="clause">
      <p><span class="numbering">12.1</span> Any person is authorized to duplicate and
      distribute copies of this Agreement.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">12.2</span> So as to ensure coherence, the wording of
      this Agreement is protected and may only be modified by the authors of the License,
      who reserve the right to periodically publish updates or new versions of the
      Agreement, each with a separate number. These subsequent versions may address new
      issues encountered by Free Software.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">12.3</span> Any Software distributed under a given
      version of the Agreement may only be subsequently distributed under the same
      version of the Agreement or a subsequent version, subject to the provisions of
      Article <a href="#compatibility"><span class="numbering">5.3.4</span></a>.</p>
    </div>
  </div>

  <div class="article">
    <h2>Article <span class="numbering">13</span> - GOVERNING LAW AND JURISDICTION</h2>

    <div class="clause">
      <p><span class="numbering">13.1</span> The Agreement is governed by French law. The
      Parties agree to endeavor to seek an amicable solution to any disagreements or
      disputes that may arise during the performance of the Agreement.</p>
    </div>

    <div class="clause">
      <p><span class="numbering">13.2</span> Failing an amicable solution within two (2)
      months as from their occurrence, and unless emergency proceedings are necessary,
      the disagreements or disputes shall be referred to the Paris Courts having
      jurisdiction, by the more diligent Party.</p>
    </div>
  </div>

  <div class="footnote">
    <p><a name="footnote1" id="footnote1">1 CeCILL stands for Ce(a) C(nrs) I(nria)
    L(ogiciel) L(ibre)</a></p>
  </div>

  <div class="version">
    Version 2.0 dated 2006-09-05.
  </div>

\endhtmlonly

*/