Compiling on Mac OS X Snow Leopard¶
Updating the OCaml compiler, GSL and OCamlGSL¶
Compilation of Nmag on Mac OS X Snow Leopard requires to update the OCaml compiler to the latest version.
Indeed, some users reported problems with OCaml compiler 3.09.3, which does not seem to support the newest OS/architecture.
One thing you could try is to update to the latest version of OCaml. You'll see that this will require - in turn - to update to the latest versions of GSL and OCamlGSL. Here I explain how to do that.
Firstly, you should untar again Nmag to get a fresh copy of the nmag all-source directory.
tar xzvf nmag-0.1-all.tar.gz
Then you should enter the newly created directory (named simply nmag-0.1) and get the latest versions of the three packages:
cd nmag-0.1 cd pkgs wget http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-3.11.1.tar.bz2 wget ftp://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gsl/gsl-1.14.tar.gz wget http://oandrieu.nerim.net/ocaml/gsl/ocamlgsl-0.6.0.tar.gz cd ..
Now edit the file nmag-0.1/Makefile with your favourite editor.
Search for the string "ocaml-3.09.3", you'll find just one occurrence. Change it to "ocaml-3.11.1".
Do the same for the other two strings "gsl-1.8.tar.gz" and "ocamlgsl-0.4.0.tar.gz". Replace them with "gsl-1.14.tar.gz" and "ocamlgsl-0.6.0.tar.gz", respectively.
Patching Nmag to work with OCaml 3.11¶
The new version of the OCaml compiler introduces some incompatibilities in the camlp4 preprocessor (which is bad, I think, and is the reason why OCamlGSL didn't work anymore) and some incompatibilites in the implementation, which is acceptable, but breaks one small piece of our code.
The solution is the following. Download the file objsize.c using on the following link http://dl.dropbox.com/u/1820549/objsize.c
I now assume you downloaded it in your home directory. Then:
cd nmag-0.1 # we go into the directory where nmag was unpacked cd nsim/snippets mv objsize.c old-objsize.c mv ~/objsize.c .
As you see you are basically replacing the file nmag-0.1/nsim/snippets/objsize.c with the one you just downloaded before.
Patching Petsc¶
There are some more steps to do in order to get Nmag working on your Mac Snow Leopard:
cd nmag-0.1 # you should get inside the directory nmag-0.1 make .deps_petsc_patch
Your system will now spend some minutes compiling some libraries.
When it finishes you should do as follows:
cd lib/petsc/bmake/common mv rules.shared.basic old-rules.shared.basic wget http://dl.dropbox.com/u/1820549/rules.shared.basic
This line will replace the file bmake/common/rules.shared.basic
in the Petsc distribution.
After this you should be able to finally compile Nmag:
make