The code can be run from the command prompt or by calling it as a subroutine of other, larger programs. The first sections describe the command prompt approach.
The code will explain if something goes wrong. There are generally two sources of problems - the path does not properly point to the data directory, or the code was compiled with gcc version 2.96. For the first, check the contents of the path.c file. Recent versions of the code will detect gcc 2.96 and refuse to execute.
Run the simple test
Execute the code with the single command line
To do this create a file ("test.in") and enter this one line as the first and
only line in the file. Then execute the code with
Now examine the last line of output in the file that was produced. This test does many internal sanity checks. If the output says that Cloudy ended OK then things are set up OK. The following shows the last line of output produced in a successful run:
[Stop in maincl, Cloudy exited OK]
Check that it crashes on errors
It would be good if the code would crash on divide by zero, overflow, using NaN, and (for the debug compile) a failed assert. Compile as directed above, and run the following four tests:
Note that the "crash assert" will only fail with a thrown assert when the code is compiled in debug mode since asserts do not exist in optimized code. If the code is compiled correctly and the asserts are working, then the calculation will end with statements saying that something bad has happened, and that the input stream should be shown to Gary Ferland. This is the normal termination for a crash due to a failed assert, so it means that everything is fine.
If the code does not crash on each of these tests, then your system is quite happy with bad floating point math or failed asserts. It is quite possible that you will not be able to get your system to crash on floating point errors. (This seems to get a bit harder every year.) This is not a major problem but is something that should be kept in mind.
To execute the code as a stand-alone program:
The code reads from standard input and writes to standard output. From the command line the code would be executed as follows, if the executable is called cloudy.exe:
cloudy.exe < input_file > output_file
In this example commands would be read in from the file "input_file", and results are sent to "output_file" A typical input file is the series of commands written one per line in free format:
title typical input stream
There is a second way to accomplish the same thing. Robin Williams added a command line "-p" option that allows the input to be specified:
cloudy.exe -p input
This will read commands from the file input.in and write results to the file input.out. It will also add the string "input" to the beginning of all punch file names.
I created a shell script named "run" that contains the following:
cloudy.exe < $1.in > $1.out
Make the script executable by typing
chmod ugo+x run
then execute the code as follows:
This will read commands from the file input.in and write results to the file input.out.
Often the most insight is gained from producing a large number of models with various input parameters changing, to see how predicted quantities change. To do this you want to write your own main program, and delete the one that comes with the distribution.
Delete the old main program:
In the distribution this is the file maincl.c. Delete this file (or rename it to something like maincl.old) , and also delete maincl.o if you compiled the entire distribution.
Compile the new main program and link it with the rest of Cloudy.
This is done with the compile options described above. You will need to compile all the rest of the code, generating *.o files, then compile the new main program, and link it all together. Note that in C the main program must be called main, but it can live in a file with any name. All of the routines you need to access are declared in the header file cddrive.h. Include this file with your main. That header also describes how the various driving routines should be called.
Public routines are declared in cddrive.h
All routines that are needed drive Cloudy and examine its predictions are declared in cddrive.h. This file also describes what each routine does, and its parameters. This is in addition to the documentation in Part III of Hazy.
This page shows some examples of calling Cloudy as a subprogram to compute grids of models.
Next step, compile stellar atmospheres