Executing C96
Home Up C94.00 Other versions Revision history The future etcetera Acknowledgements Contacts, Mailing list Links Site map, search




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.

Checking whether it runs at all

First check whether the code runs at all.  At a command prompt enter the name of the executable, probably "cloudy.exe", followed by an enter, type the word "test", followed by a few carriage returns.  The code will do a set of self tests, calculate a simple model, and should complete with a line saying 
[Stop in maincl, Cloudy exited OK]

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. 

To execute the code as a stand-alone program:

Method 1

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
blackbody 120,000K
luminosity 37
radius 17
hden 4

Method 2

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, write results to the file  input.out.  It will also add the string "input" to the beginning of all punch file names.

Method 3

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:

run input

This will read commands from the file input.in and write results to the file input.out.

To run Cloudy as a subroutine of other, larger, codes

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 

Hit Counter
Last changed 03/31/03.
Return to the Cloudy Home Page.
Copyright 1978-2003 Gary J. Ferland