Running MAD8 on OSX 10.8 to 10.11

(* Update: checked to work on 10.11 El Capitan as well *)

If you’ve worked in accelerator physics in any significant way, then you will have heard of MAD (‘Methodical Accelerator Design’) written at CERN many, many years ago, but still widely used for optics design, matching, and various tracking and nonlinear work. Quite a few working accelerators have been designed using various versions of it, including the SRS, DIAMOND, ALICE, and some parts of CLIC; I know these examples because I used MAD for them!

MAD8, the older-style code written in Fortran, has given way to MADX (it’s not considered polite to ask what happened to MAD9, but its legacy lives on in several other codes), and support for MAD8 has effectively stopped, with a few legacy versions floating around. SLAC implemented linac-style acceleration into their version 8.23acc, and a long time ago I did an optimised (and slightly debugged) version of MAD8 for Windows called 8.23dl. (By the way, you can tell which version you’re using from the code version at the top of any plot, so I know who you are if you’re using my version!). There are slight differences, but more or less you can trust what comes out of them.

MADX has taken over, but there are still reasons to use MAD8 from time to time. Most people who have used MAD8 have a love/hate relationship with it: they’ve had to get used to the code and its idiosyncrasies, but the combination of the simple XSIF file format and the relatively nice command structure means you can ‘get stuff done’. This is particularly true if you have some old input files that you don’t want to bother to convert to MADX format (yes, I hate converting files).

Whilst there are installers for MAD8 on Windows (my old friend James Jones has a really nice integrated package), and Linux is basically no problem, us poor old Mac users tend to be the poor cousins, especially with new OSes like 10.8. But fear not, here is a recipe for getting MAD8 up and running on OSX 10.8 Mountain Lion.

The procedure is as follows:

  • Grab a copy of all the files from:
    http://www.hep.manchester.ac.uk/u/hywel/codes/mad8/osx/
  • The mad8 binary is hard-wired to look for library files in one location, so you will need to create the following directory path (using sudo probably):/sw2/lib/gcc4.4/lib/
    Put the libgcc_s.1.dylib and libgfortran.3.dylib files into this directory
  • Put the other files in a directory of your choice. I chose ~/dev/mad8/
  • chmod u+x * in this directory
  • If you don’t already have a file called dict, then do cp mad8.dict dict.

That’s it! You should now be able to run MAD8. I’ve included an input file for the old Daresbury SRS called srs.mff, which you can get here: srs.mff.

You can now run MAD8 using e.g.:
./mad8s < srs.mff > echo.txt

This should create a mad.ps file that you can load, and a print file that you can see your output in. Plenty of tools are available to work these files.

You may find on first running mad8s that you get a prompt to install X windows. Go ahead and do that, or get it direct from https://www.xquartz.org/

Hope that helps!

4 thoughts on “Running MAD8 on OSX 10.8 to 10.11”

  1. Hi Hywel,
    running Mad8 on Mac-OS sounds really great, and I followed your advice with high hopes. I’m running Mac-OSX 10.9.2 though. Alas, when I try to run mad8, I get:

    ipplaplist:test blist$ mad8s < srs.mff
    dyld: Library not loaded: /sw2/lib/gcc4.4/lib/libgfortran.3.dylib
    Referenced from: /sw/bin/mad8s
    Reason: no suitable image found. Did find:
    /sw2/lib/gcc4.4/lib/libgfortran.3.dylib: stat() failed with errno=62
    Trace/BPT trap: 5

    Do you have any idea or advice what to do?

    Many thanks, Benno

  2. Thanks for the directions! I have been using MAD8 on a LINUX server for awhile but couldn’t get it moved over to my laptop. Your directions worked perfectly the first time and my files seem to compile in identical fashion! Thanks again!

  3. Hi Hywel,
    Following your post I have been able to run Mad-8 on my mac running with OS X-10.9.4. I am beginner and am just learning to use this. But I am at times facing problems with error messages that I am unable to understand. Please let me know where I can
    get some more info on this. Thanks.
    Given below is part of an output to show the problem.

    !Drift spaces
    D080: DRIFT,L=0.08

    AAATTR. *** Error *** Semicolon “;” expected.
    Statement beginning at line 19:
    D080:DRIFT,L=0.08??? ;

    AAMAIN. Entering scanning mode.

    20 D090: DRIFT,L=0.09

    AAATTR. *** Error *** Semicolon “;” expected.
    Statement beginning at line 20:
    D090:DRIFT,L=0.09??? ;

Leave a Reply