|Version 1 (modified by dcollins, 5 years ago)|
Adding a new parameter to Enzo
If your parameter is only used for a problem initialization, this page is not relevant for you. You should just read it in during ProblemInitialize.C See the New Test Problem pages on this.?
If you're extending Enzo for any reason, you'll probably need to add a new switch or parameter to the code. Currently, this page describes the simplest, most brute force method. There are 4 files you'll need to edit to make this happen.
They're kind of self explanitory.
- global_data.h holds all the global data. It's contained in almost all Enzo files. Your parameter should be added like this:
EXTERN int MyInt; EXTERN float MyFloat;EXTERN is a macro that either maps to extern if USE_STORAGE is defined, or nothing if USE_STORAGE is not defined. USE_STORAGE is defined in enzo.C before the inclusion of global_data.h, and undefined after.
- SetDefaultGlobalValues.C sets the default global values. Set your value here.
- ReadParamaterFile.C reads the parameter file. In this routine, each line is read from the file and is compared to the given parameters with sscanf. Your line should look like this:
ret += sscanf(line, "MyFloat = %"FSYM, &MyFloat); ret += sscanf(line, "MyInt = %"ISYM, &MyInteger);and should be inserted somewhere in the loop where line is relevant. Note that ISYM and FSYM are the generalized integer and float I/O macro, which exist to take care of the dynamic hijacking of 'float'. See this page for more information?. The ret += controls whether the line has been read, or if Enzo should issue a warning about the line.
- WriteParameterFile.C writes the restart parameter file. Somewhere before the end of the routine, you should add something that looks like
fprintf(fptr, "MyFloat = %"GSYM"\n", MyFloat); fprintf(fptr, "MyInt = %"ISYM"\n", MyInt);Note the use of quotes here and in the previous code snippet. This is correct.
That's the simplest way to install a new routine.