Information for Off-Site Bmad Simulation
, (also called a Bmad Distribution
), is a stand-alone subset of the ACC Code Libraries
used for accelerator/X-ray simulations.
- A Distribution is meant for use on machines that are not part of the CLASSE laboratory network.
- Distributions are freely available for download from the web. No CLASSE account is required.
- New Distributions are generated approximately weekly.
- Distributions contain a subset of the code in a Release. The code that is left out of Distributions is CESR specific and therefore not of interest to outside people.
- Distributions can be built on Linux or Mac OS X (intel) computers. Note: The ACC Build System does not work on Windows but it is possible to build some subset of a Distribution. Please contact David Sagan if interested.
- All " OFF-site" work is done using Distributions.
A Distribution contains:
- The Bmad source code to build a collection of libraries and executables. (The term " Bmad source code" includes not only the Bmad code library as well as the subsidiary libraries, like cesr_utils, but also the code for programs like Tao.)
- Script files to build the libraries and executables.
Distribution names are generally of the form: bmad_dist_YYYY_MMDD.tgz
where YYYY_MMDD is the year_month-day tag of the release.
has been successfully been compiled on:
- Linux / Intel ifort compiler (v 188.8.131.529 or later).
- Linux / gcc gfortran compiler (v 5.3 or later).
- Mac (intel) / gcc gfortran compiler (v 5.3 or later).
ifort and gcc versions earlier than what is stated above are known to fail.
Note: Bmad has, with restrictions, been built on Windows.
For more information on Bmad
, please see http://www.lepp.cornell.edu/~dcs/bmad/
Updating a Distribution
To upgrade to more recent code, the safest way is to download (see below) the latest Distribution. Having multiple Distributions is advantageous if there are problems with the latest code which, while very rare, has happened.
The alternative to downloading a new Distribution is to use the "svn update *
" command in the root directory of a Distribution. Unless you have a specific reason to do this, it is recommended that instead you preserve your old distribution and download a new distribution.
Downloading a Distribution tarball
- Check compiler requirements for compiling Distributions.
- Download a distribution tarball from the Distributions Directory. The latest distribution is recommended.
- Unpack the tarball (substitute the actual file name for bmad_dist_YYYY_MMDD.tgz):
tar xzf bmad_dist_YYYY_MMDD.tgz
BMADZ Lattice Design Program
One program that is not included in the Distribution is BMADZ
which is used for designing storage ring lattices and control room knobs. BMADZ was developed for designing Cornell CESR lattices but it can be applied to other storage rings as well. [Note: The Tao
program can also be used for lattice design but BMADZ has been optimized for designing lattices where there is a "pretzeled" (non-zero) orbit and where there are long range beam-beam interactions due to counter-rotating beams sharing the same beam pipe.]
To download BMADZ: First download a Distribution. Then, in the distribution root directory, download the cesr_utils and bmadz directories:
svn co https://accserv.lepp.cornell.edu/svn/CESR/CESR_libs/cesr_utils
svn co https://accserv.lepp.cornell.edu/svn/trunk/src/bmadz
To compile, use the following commands:
Updating the Distribution directly from the Repository
Sometimes it is useful to update files directly from the repository as opposed to downloading a tarball. For example, if a bug fix has been uploaded to the repository but that fix is not yet available in any tarball. However,
updating via tarballs is to be preferred since code in the repository is generally not as stable as the code in the tarballs.
To update directly from the Repository, go to the distribution root directory and issue the command:
svn update *
This does not
require a CLASSE
Installation instructions here
Running the Tao program is problematical on Windows. Also building on Windows is not supported by Cornell. It is therefore recommended that Distributions be built on Linux or Mac OSX instead.
or later) and GCC
, there are several standard unix/linux tools needed for compiling the xraylib
library. They are:
program needs the following standard packages:
- X11 Core and Development Libraries (libX11 and libX11-devel)
(if it is used instead of PGPLOT) requires two more packages installed on your system:
- libXt-devel (usually installs as a dependency for cairo/pango)
Use the appropriate package manager (yum
for Red Hat based systems, etc.) to install any needed tools. Note: The name of the package can vary from platform to platform. For example, the readline
package is installed with yum using the command
yum install readline-devel
For Ubuntu, the ncurses package is installed by:
sudo apt-get install libncurses-dev
A google search will generally reveal the appropriate name.
Note: The relevant compilers for your platform must appear in each user's default PATH , otherwise the scripts in the Distribution will not work!
Mac OS X
UPDATE 04-Nov-2019 - Xcode 11 BUG ALERT.
- Due to a bug in Xcode 11, building the Bmad Distribution on macOS 10.14 Mojave will fail - Please do not upgrade to Xcode 11 with macOS 10.14 Mojave.
- Bmad will build using Xcode 11.2 and macOS 10.15 Catalina - However gcc9 is required, using the lastest MacPorts version 2.6.2 for Catalina
The following tools are needed in addition to the above
- XQuartz -- provides core and development libraries for X11 X-Windows graphics support for tao and other packages that require graphical output.
- Xcode -- Install the latest version from the Apple developer website or get it using the Mac App Store. Once you have Xcode installed, open a terminal, run
sudo xcode-select --install Then click the Install button to install the required command line developer tools.
- To complete the Apple Xcode License Agreement, please type:
sudo xcodebuild -license
- MacPorts -- package management system. See the installation site for downloads and instructions.
If the version of the default GCC gfortran compiler is less than 5.3
, you should install one of the RHEL Developer Toolset Software Collections
, at least devtoolset-4
To install devtoolset-6
(provides GCC gfortran version 6.2.1
), see basic information below:
That page gives instructions for RHEL and CentOS. For straight Scientific Linux (not the CERN version), replace the first step of the instructions with the instructions from:
For CERN SLC 6, follow the instructions here:
is installed, the Bmad Distribution build system will find and initialize the devtoolset environment. If this fails, you can manually initialize the devtoolset environment (for bash
shell users) by typing:
scl enable devtoolset-6 bash
Debain Variants (Ubuntu, etc.)
Distribution Environment Setup
The distribution environment setup must be done before building programs and must be done before running any programs. It is recommended that the setup commands be put in the appropriate shell startup file so that the setup is done automatically when logging in.
- Users should add the following text to their local account login or profile files.
- Run your initialization file by simply logging out and logging back in again.
To see information about the Distribution that is being used by a terminal session, use the command:
Either command will display a summary of the active Distribution's information, build architecture, selected Fortran compiler and enviromental configuration.
Compiling a Distribution
- Unzip and extract the tar archive into a working directory of your choice with the command:
tar -zxf bmad_dist_YYYY_MMDD.tgz
- Set up the Distribution envionment as explained in the Distribution Environment Setup section. Notice that the environmental variable DIST_BASE_DIR points to the root directory (with a name like to bmad_dist_YYYY_MMDD).
- Change to the root directory:
- A file named $DIST_BASE_DIR/util/dist_prefs is provided and contains the supported preferences that you may adjust to alter the behavior of the build. In particular, the compiler and plotting library are set in this file. Also whether a shared-object version of the libraries is built and whether MPI and/or OpenMP is supported is determined by the settings in this file. Documentation for dist_prefs is contained in the file itself. Edit this file as needed. For information on setting the plotting library, please click here.
- After editing dist_prefs, run your initialization file by loggin out and logging back in again.
- The final step is to build the source. For building production libraries and executables, type:
util/dist_build_production For building debug libraries and executables, type:
- Note: To remove compiled files and restart from scratch run:
Directories in a Distribution
Directories Containing Executables
|| Production executables are meant for ordinary use.
|| Debug executables are meant for debugging code. Debug executables run slower but do more error checking and can be used with a debugger.
Cornell Developed Library Directories:
|| Main simulation library.
|| C++ interface to Bmad
|| Helper routines (matrix , plotting, file manipulation, etc.)
Cornell Developed Directories containing programs:
|| Beam simulation programs
|| Example programs and example lattices.
|| Bmad regression testing suite.
|| General simulation program.
|| Utility programs (EG lattice format converters, etc.)
Other Cornell Developed Directories:
|| Lattice files for various machines.
|| Utility scripts.
|| Build system script.
3rd-Party Libraries ("Packages"):
|| FPP/PTC Full Polymorphic Package/Particle Tracking Code from Etienne Forest
|| A Fortran interface to the GNU Scientific Library
|| GNU Scientific Library
|| library for storing and managing data.
|| Linear Algebra PACKage
|| A F90 double precision version of Numerical Recipes
|| "the Pretty Good Plotting Package". For setup information, see the Plotting Packages wiki page.
|| A cross-platform software package for creating scientific plots. For setup information, see the Plotting Packages wiki page.
|| A library for X-ray matter interaction cross sections for X-ray fluorescence applications
|| A Library for Parsing the Extended Standard Input Format of Accelerator Beamlines
Building your own code using a Distribution
To build your own code, after successfully installing a Distribution, please see the Code Development
The following is the ordered list of libraries to link to. Different programs will need different subsets of this list for linking. The libraries that the linker uses is specified by the LINK_LIBS
variable in the cmake.XXX
file used to compile and link your program. See the file bmad_dist/tao/cmake.tao for an example. The linker at link time will notify you if there are any missing libraries from the LINK_LIBS list. The order of the libraries in the LINK_LIBS list is important.
Issues with building a Distribution
Please see our wiki page on Troubleshooting ACC Code Issues
This distribution includes a modified version of the Numerical Recipes
It is the responsibility of the end user to ensure that they have a valid
license for any computer on which they build the Bmad
distribution. Numerical Recipes
licensing information (for individual
computers or sites) can be obtained at www.nr.com
FPP/PTC (Polymorphic Tracking Code) package, from Etienne Forest, has no licensing issues.
(pretty good plotting) package from Tim Pearson, states on the PGPLOT web page:
PGPLOT is not public-domain software. However, it is freely available for non-commercial use.
The source code and documentation are copyrighted by California Institute of Technology,
and may not be redistributed or placed on public Web servers without permission.
The software is provided ``as is'' with no warranty.
To request help, Please see our Help and Mailing List Information
wiki page for email contacts.