This page outlines how to use the makefile for Cloudy that is supplied in the source directory. It requires GNU make and is set up for g++, but will also work for other compilers. It is based on experiences of Peter van Hoof and Robin Williams in using g++ with the code.
Before you compile Cloudy, first inspect the file "Makefile". It has been set up for an optimized compilation with g++. It can be altered easily for other compilers by editing the "CXX", "CXXFLAGS", and "LDFLAGS" fields in the file. Alternatively you can set environment variables with the same name in your shell, these will override the default settings in the makefile if you replace "make" with "make -e" everywhere below. How to set variables depends on the shell you are using. Here is an example for some commonly used shells:
csh/tcsh:
setenv CXX pgCC
bash/sh/ksh/...
CXX="pgCC" (no spaces around the "="!)
export CXX
When you have finished inspecting the Makefile, you can compile the code by simply typing
make
The resulting executable will be named cloudy.exe. If you have a multi-core computer, you can take advantage of this by doing a parallel build with
make -j <n>
where <n> is the number of cores you want to use.
The makefile will only work with GNU make, which may be named gmake on your system.
Make will automatically set the path to the data files in path.cpp. For this to work you will have to define the environment variable CLOUDY_DATA_PATH containing the correct path (don't forget the trailing slash!).
In order for make to work, it needs to know how each of the source files depends on the various header files. This is defined in the file Makefile.dep. When you have downloaded a fresh version of Cloudy, this file will not be present. The first time you execute the make command, the compiler will automatically create the Makefile.dep file for you. This will only work if you use g++ or icc. If you want to use another compiler to create Cloudy, run
make depend
with CXX set to either g++ or icc. This will create Makefile.dep. Then change CXX to your favorite compiler (and possibly modify the compiler and linker flags) and compile Cloudy. Now that Makefile.dep exists, it will not be recreated again unless you delete the file "Makefile.dep" or issue the command "make depend" again.
If you modify Cloudy and add new source files, or add new #include statements in existing source files, the dependencies of the code will change. Make will have no way of knowing this, hence you will have to recreate Makefile.dep yourself by typing "make depend" again.
You can clean up the source directory by issuing
make clean
This will remove all the object files and the cloudy.exe binary. You can also use
make distclean
which will do the same thing, and will additionally remove Makefile.dep. Hence a full compilation from scratch can be forced by issuing the commands:
make clean
make
A full compilation forcing the reconstruction of Makefile.dep can be done with
make distclean
make