Compiling Nmag with OCaml 3.11.1

The newer version of the OCaml (3.11.1) compiler introduces two problems with the compilation of Nmag.
The first is connected with the changes to the Camlp4 preprocessor, which break version 0.4.0 of ocamlgsl. This can be solved by updating gsl and ocamlgsl to the latest versions (1.13 for gsl and 0.6.0 for ocamlgsl). Alternatively the old version of gsl (1.8) can be used together with version 0.5.3 of ocamlgsl.
The second problem has to do with changes in the implementation of OCaml, which break the code used to find the size of an OCaml data structure, i.e. the file nsim/snippets/objsize.c. The problem can be solved by replacing the content of the file nsim/snippets/objsize.c (or nmag-0.1/nsim/snippets/objsize.c for those who compiled everything from source) with the following:
#include <stdlib.h>

#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>

CAMLprim value caml_memory_footprint(value start) {
      CAMLparam1(start);
      CAMLlocal1(res);
      size_t s = 0;

      res = caml_alloc_tuple(3);
      Store_field(res, 0, copy_double(s));
      Store_field(res, 1, copy_double(s));
      Store_field(res, 2, copy_double(s));
      CAMLreturn(res);
}

Also available in: HTML TXT