next up previous contents
Next: Installing under Windows Up: Directions for UNIX and Previous: Preliminaries   Contents

Compiling Spectrum

SPECTRUM is available for download as a tarred-gzipped file on http://www.phys.appstate.edu/spectrum/spectrum.html. On the download page of that website, you will find a link to a file named spectrumXXX.tar.gz, where XXX stands for the current version. This file should be downloaded and copied to a directory, say, /spectrum, and then unzipped with the command:
tar -xvzf spectrumXXX.tar.gz.
This command unzips to this directory source code for SPECTRUM in the form of a number of ``c'' files, such as spectrum.c, opacity6.c, and so on, along with a number of essential data files, such as stdatom.dat which contains basic atomic and molecular data, isotope.iso, a listing of supported isotopes and relative abundances, plus two stellar atmosphere models ( sun.mod and vega.mod) computed with the stellar atmosphere code ATLAS9 (Kurucz, 1993). You should also see a file named Makefile.

The SPECTRUM source files must be compiled first before you can use SPECTRUM. This means that you must have a C-compiler on your system. If not, see the notes above.

SPECTRUM may be compiled using the provided Makefile. Make certain you are in the directory in which you unzipped spectrumXXX.tar.gz. At the prompt, issue the command
make spectrum
and, if all goes well, in about a minute or two SPECTRUM should compile without error. If an error occurs, make certain that you are in the correct directory and that you have write permission for that directory. For other errors, which should be very rare at this point, please contact the author (see contact information in the appendix). The executable for SPECTRUM will be called spectrum (as opposed to spectrum.c or spectrum.o).

If you are interested at this point, all of the auxiliary programs (plus SPECTRUM itself, for that matter) may be compiled with the command
make all
This will produce the executables abundance, avsini, bflxsm2, blackwel, bsmooth2, customsm, gfadjust, lines, macturb, selectmod, selectmod9, spectrum, smooth2, and vsini. The use of these programs will be covered later in this document.

If your compiler is not gcc, it should be possible invoke it with the command cc (try entering cc at the prompt; if you get the response: cc: no input files, then you can use cc instead of gcc). However, you must modify the Makefile in order to compile SPECTRUM with cc. Use an editor, such as nano or emacs and modify the first line of the Makefile so that it reads
CC = cc
and then use the command
make spectrum
to compile SPECTRUM. You may also have to experiment with the second line
CFLAGS = -O3
which sets the level of optimization for the compiler. If you experience any problems running SPECTRUM, modify that line to
CFLAGS = -O
and try again. You may then work up through the various levels of optimization: O1, O2, O3 and possibly beyond.
NOTE for MAC Users (added April 8, 2021): You may experience run-time errors if you use the default -O3 optimization level!!!

To compile for a 64-bit machine, refer to the instructions for your compiler (this applies to gcc as well) for the appropriate flags which you may then add to the CFLAGS line. The Makefile includes a sample 64-bit optimization line:

CFLAGS = -O3 -m64 -mtune=native
which can be experimented with. Uncomment it (remove the leading #) and comment the default CFLAGS line and compile. The last flag -mtune=native may not work on all systems.

You should also download a spectral linelist file from the SPECTRUM distribution site. There are a number available, but luke.lst is the best to start with. This can be downloaded as a gzipped file, luke.lst.gz which will then need to be unzipped with the command
gunzip luke.lst.gz
This file, at least for now, may be placed in the /spectrum directory; later in this document we will cover placing it in a separate directory, such as /usr/local/lines.


next up previous contents
Next: Installing under Windows Up: Directions for UNIX and Previous: Preliminaries   Contents
grayro 2010-05-27