wiki:EditPath

Version 17 (modified by Gary J. Ferland, 10 years ago) (diff)

update makefile part

Setting the path

The skinny on editing the path If you are running Linux or a Mac you can use the a makefile to build the code. You do not need to worry about the steps on this page and you can go on to the next step, CompileCode.


There are vast amounts of atomic data that the code must reference in order to compute a model. These are the files that live in the data directory. The code must be able to find these data files. Their location is stored in a global string variable named chDataPath which is set in the file path.cpp. You need to change the string so that it gives the location of the data on your machine.

There are three ways to specify the path to the data files. The first method is by editing path.h, which should be done before you start compiling. The second method is to add an extra parameter to the compiler options, and the third method is to set an environment variable at runtime.

In Cloudy version C07 and before there were two names for the data path, CLOUDY_DATA_PATH and LOCAL_DATA_PATH. In Cloudy version C08 there is only one, CLOUDY_DATA_PATH. Use CLOUDY_DATA_PATH where LOCAL_DATA_PATH appears below for version C08.


Method 1: Setting the path by editing path.h

Edit the file path.h (located in the source directory) and locate the variable CLOUDY_DATA_PATH. There are two instances, one for windows and another for unix. If you are using Cygwin on Windows you should set the unix path. You need to edit the the path one for your operating system. Change the string within the double quotes so that it gives the location of the data on your computer.

The path would be a string within double quotes. On a Unix machine the result should look like this:

/* 
 * Specify a search path to data directories here.
 *
 * This is for Unix variants.  You can specify a search path for one or several
 * data directories using the standard colon-separated list of Unix paths. You
 * can enter as many paths as you like. One example could be: */

#define CLOUDY_DATA_PATH "/usr/local/cloudy/data:/home/user/cloudy/data"

On a Windows machine the result should look like this:

/* The following example shows the format for Windows. You can
 * specify a search path for one or several data directories using a list separated
 * by semi-colon signs ";". The path must be enclosed between double quotes.
 * NB - note that the backslash "\" always needs to be typed twice, as shown below: */

#define CLOUDY_DATA_PATH "c:\\projects\\cloudy\\data;c:\\users\\gary\\data"

The double backslash is needed on Windows systems to prevent the character following the slash from being interpreted as an escape sequence.

The string giving the path MUST have the proper directory mark as the last character before the second quote. This would be a "/" in Unix, a "
" in Windows, and a "]" in VMS.

C++ syntax for the newcomer There must be two double-quotes. The path is the series of characters between them. The line must end with a semicolon. Lines that start with are comments. One of the paths will be commented out.

If the path is longer than FILENAME_PATH_LENGTH characters then increase the size of FILENAME_PATH_LENGTH in cddefines.h and recompile the entire code. Remember that in C++ a string must have one extra byte for storing the end-of-string sentinel.

If you store your *.ini initialization files in the data directory then the ini files will be automatically found by the code.


Method 2: Setting the path with a compiler option

Robin Williams added a macro, LOCAL_DATA_PATH, that allows the path to be specified by the value of the macro. To use this you should not edit the file path.cpp, but add the following parameter to the compiler options:

-DLOCAL_DATA_PATH=\"/usr/gary/cloudy/data/\"

(for Unix) or

/DLOCAL_DATA_PATH=\"c:\\projects\\cloudy\\current\\data\\\"

(for Windows). So the complete line could e.g. be (this depends on the platform and compiler you are using, see CompileCode for more details):

g++ -ansi -c -O3 -Wall -DLOCAL_DATA_PATH=\"/usr/gary/cloudy/data/\" *.cpp

In Visual Studio you would go to Project / properties / Configuration Properties / C/C++ / Preprocessor and set the following within the Preprocessor Definitions line:

LOCAL_DATA_PATH="\"c:\\projects\\cloudy\\trunk\\data\\\\\""

Method 3: Supplying the path at runtime

You can set the path to the data files at runtime before you start up Cloudy by setting the environment variable CLOUDY_DATA_PATH. This setting will always override any settings supplied with the previous two methods. On Unix platforms the method for setting the environment variable depends on the shell you are using. For csh/tcsh use:

setenv CLOUDY_DATA_PATH "/usr/gary/cloudy/data/"

For bash/sh/ksh/etc... you should use:

export CLOUDY_DATA_PATH="/usr/gary/cloudy/data/"  (no spaces around the '='!)

In windows you would use:

set CLOUDY_DATA_PATH=c:\cloudy\trunk\data  (no spaces around the '=', no double quotes around the directory name!)

Next step: CompileCode - compile the code.

Return to StepByStep instructions

Return to nublado.org