SORTIE Core C++ Documentation
|
OUTPUT - Version 1.3. More...
#include <Output.h>
Classes | |
struct | stcGridOutputInfo |
Data structure for defining what grid output data to save. More... | |
struct | stcSubplotInfo |
Data structure for saving subplot data. More... | |
struct | stcTreeOutputInfo |
Defines what tree output data to save. More... | |
Public Member Functions | |
clOutput (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clOutput () | |
Destructor. More... | |
void | Action () |
Performs output data collection file writing. More... | |
string | GetDetailedOutputFilename () |
Gets the detailed output filename. More... | |
string | GetTimestepFilename (int iTimestep, int iSubplot) |
Figures out the filename for the detailed output timestep file and places it in cFilename. More... | |
Public Member Functions inherited from clBehaviorBase | |
virtual float | GetBehaviorVersion () |
Gets the behavior version number. More... | |
clBehaviorBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clBehaviorBase () |
Destructor. More... | |
virtual short int | ValidateVersionNumber (float fTestVersion) |
Makes sure that the version number of a file passed is between the minimum and current version numbers. More... | |
virtual void | RegisterTreeDataMembers () |
Registers tree data members. More... | |
virtual void | SetSpeciesTypeCombos (short int iNumCombos, stcSpeciesTypeCombo *p_whatCombos) |
Sets the species/type combos for a behavior. More... | |
virtual void | SetNameData (std::string sNameString) |
Sets the string for the parameter file behavior. More... | |
virtual short int | GetNewTreeInts () |
Gets the number of new tree integer data members this behavior wants to register. More... | |
virtual short int | GetNewTreeFloats () |
Gets the number of new tree float data members this behavior wants to register. More... | |
virtual short int | GetNewTreeChars () |
Gets the number of new tree character data members this behavior wants to register. More... | |
virtual short int | GetNewTreeBools () |
Gets the number of new tree bool data members this behavior wants to register. More... | |
virtual short int | GetNumSpeciesTypeCombos () |
Gets the number of species/type combos to which this behavior applies. More... | |
virtual short int | GetNumBehaviorSpecies () |
Gets the number of unique tree species to which this behavior applies. More... | |
struct stcSpeciesTypeCombo | GetSpeciesTypeCombo (short int iIndex) |
Gets one of this behavior's type/species combos. More... | |
virtual short int | GetBehaviorSpecies (short int iIndex) |
Gets one of the behavior's species. More... | |
short int | GetBehaviorListNumber () |
Gets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
void | SetBehaviorListNumber (short int iNumber) |
Sets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
std::string | FormatSpeciesTypeQueryString () |
Formats the string for species/types query. More... | |
virtual DOMElement * | GetParentParametersElement (xercesc::DOMDocument *p_oDoc) |
This will get the correct set of parameters for this behavior based on the behavior list position number. More... | |
Public Member Functions inherited from clWorkerBase | |
clWorkerBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clWorkerBase () |
Destructor. More... | |
std::string | GetName () |
Gets the object's namestring. More... | |
clSimManager * | GetSimManager () |
void | DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType) |
Triggers the setup process. More... | |
virtual void | TimestepCleanup () |
Performs any necessary cleanup operations at the end of a timestep. More... | |
virtual void | EndOfRunCleanup () |
Performs any necessary cleanup operations at the end of a run. More... | |
Protected Member Functions | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Reads in the parameter file values. More... | |
void | WriteDetailedOutputHeader () |
Writes the detailed output header file. More... | |
void | WriteTimestepHeader (string sFilename) |
Sets up the timestep file and writes the header data. More... | |
void | WriteTimestepFooter (string sFilename) |
Writes the closing tag for the timestep file. More... | |
void | WriteTreeData (string *p_sFilename) |
Appends the tree data to the file. More... | |
void | WriteGridData (string sFilename) |
Appends the grid data to the file. More... | |
void | ExtractLiveTreeInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to tree saving. More... | |
void | ExtractDeadTreeInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to dead tree saving. More... | |
void | ExtractGridInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to grid saving. More... | |
void | ExtractSubplotInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the subplot data. More... | |
void | MakeMasterTreeSettings () |
Makes the master tree settings, for writing to the treemap header. More... | |
void | WriteTree (clTree *p_oTree, char *cBuf, char *cTemp, FILE *oOut) |
Writes the XML for a single tree. More... | |
void | WriteGhost (clDeadTree *p_oTree, char *cBuf, char *cTemp, FILE *oOut) |
Writes the XML for a single dead tree. More... | |
void | AddToBuffer (char *cBuf, char *cToAdd, FILE *out, int iBufferSize) |
Adds a string to a buffer string. More... | |
Protected Member Functions inherited from clWorkerBase | |
void | AssembleFileCode (int iFileType, int iFileVersion, char *cCode) |
Creates the proper identifying filecode for an XML file. More... | |
Protected Attributes | |
string | m_sFileRoot |
Root name of the detailed output file with no file extension on it. More... | |
string | m_sTarball |
Root detailed output file name plus extension for tarball (gzip'ed and tar'ed) More... | |
struct clOutput::stcTreeOutputInfo ** | mp_treeSettings |
Array of stcTreeOutputInfo's, number of species by number of types. More... | |
struct clOutput::stcTreeOutputInfo ** | mp_masterTreeSettings |
Compiled settings across live and dead trees for tree map writing - if any tree type/species, live or dead, saves a data member, it will be here, so that it can be written. More... | |
struct clOutput::stcTreeOutputInfo *** | mp_deadTreeSettings |
Array for dead trees, # species by # types by # dead reason codes. More... | |
struct clOutput::stcGridOutputInfo * | mp_gridSettings |
array of stcGridOutputInfo's, one for each grid object that we're saving data for More... | |
short int | m_iNumGridsToSave |
number of grid objects we're saving data for More... | |
struct clOutput::stcSubplotInfo * | mp_subplots |
An array of stcSubplotInfos, one for each subplot to save. More... | |
short int | m_iNumSubplotsToSave |
Number of subplots we're saving data for. More... | |
short int | m_iNumSpecies |
Number of species. More... | |
short int | m_iNumTypes |
Number of types. More... | |
short int | m_iNumXCells |
Number of plot cells in the X direction - for subplots. More... | |
short int | m_iNumYCells |
Number of plot cells in the Y direction - for subplots. More... | |
float | m_fXCellLength |
Length of subplot cells in X direction - defaults to match tree population. More... | |
float | m_fYCellLength |
Length of subplot cells in Y direction - defaults to match tree population. More... | |
Protected Attributes inherited from clBehaviorBase | |
short int | m_iNumSpeciesTypeCombos |
How many type/species combos a behavior will act on. More... | |
short int | m_iNumBehaviorSpecies |
How many distinct species are in the combo list - important for filling species-specific values from parameter file. More... | |
short int * | mp_iWhatSpecies |
List of distinct species - for filling species-specific values from parameter file. More... | |
stcSpeciesTypeCombo * | mp_whatSpeciesTypeCombos |
Array of species/type combos that the behavior will act on. More... | |
short int | m_iNewTreeInts |
The number of new tree integer data members this behavior wants to add. More... | |
short int | m_iNewTreeFloats |
The number of new tree float data members this behavior wants to add. More... | |
short int | m_iNewTreeChars |
The number of new tree character data members this behavior wants to add. More... | |
short int | m_iNewTreeBools |
The number of new tree boolean data members this behavior wants to add. More... | |
short int | m_iBehaviorListNumber |
The number of this behavior in the behavior list, to differentiate between possible multiple copies of this behavior. More... | |
float | m_fVersionNumber |
Version number - this will be rounded to 2 digits after the decimal place. More... | |
std::string | m_sXMLRoot |
XML root that encloses the parameters for this behavior. More... | |
float | m_fMinimumVersionNumber |
Minimum version number - this behavior will run parameter data for a file marked between this number and the current version number, inclusive. More... | |
Protected Attributes inherited from clWorkerBase | |
std::string | m_sNameString |
If a behavior has registered a command line command with the sim manager, this allows it to be called. More... | |
clSimManager * | mp_oSimManager |
Pointer to the simulation manager object. More... | |
int * | mp_iAllowedFileTypes |
List of the input file types this object can handle. More... | |
int | m_iNumAllowedTypes |
Number of input file types this object can handle. More... | |
OUTPUT - Version 1.3.
This is a behavior which saves output from the model run. It would normally be run last in a timestep.
This behavior supports saving tree data and generic grid data. Tree data is defined separately for each type (seed, seedling, sapling, adult, or dead).
Filenames must be specified for the detailed output file. The user can also define subplots. Each of these is stored in its own separate file.
Note - all file writing is done using the old C library functions instead of the newer C++ functions (fstream and family). The code was originally written with C++ functions and ran unacceptably slow.
The behavior's namestring and parameter file callstring are both "Output".
Copyright 2003 Charles D. Canham.
Changes:
--------------—
April 28, 2004 - Submitted as beta (LEM)
October 24, 2005 - Changed the way we search for trees; the results should be the same.
May 10, 2006 - Added support for subplots and updated to version 1.1 (LEM)
June 20, 2007 - Changed to strings along with Linux port (LEM)
January 2, 2008 - Support for user-defined subplot resolution and made version 1.2 (LEM)
January 24, 2008 - Made all path separators forward slashes for gzip and tar - this fixes a bug with escape characters (LEM)
January 25, 2011 - Added support for dead trees (LEM)
clOutput::clOutput | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clOutput::~clOutput | ( | ) |
Destructor.
|
virtual |
Performs output data collection file writing.
It begins by examining all of the desired output types and seeing which ones are ready for updating for this timestep.
Reimplemented from clBehaviorBase.
|
inlineprotected |
Adds a string to a buffer string.
If the buffer is full, it is flushed to file before the new string is added.
cBuf | Buffer string. |
cToAdd | String to add to buffer. |
out | File to flush buffer to. |
iBufferSize | Size of the buffer. |
|
protected |
Extracts the output data relating to dead tree saving.
p_oDoc | DOM tree of parsed input file. |
|
protected |
Extracts the output data relating to grid saving.
p_oDoc | DOM tree of parsed input file. |
|
protected |
Extracts the output data relating to tree saving.
p_oDoc | DOM tree of parsed input file. |
|
protected |
Extracts the subplot data.
p_oDoc | DOM tree of parsed input file. |
|
protectedvirtual |
Reads in the parameter file values.
p_oDoc | DOM tree of parsed input file. |
modelErr | if the filename is too long. |
Implements clWorkerBase.
|
inline |
Gets the detailed output filename.
string clOutput::GetTimestepFilename | ( | int | iTimestep, |
int | iSubplot | ||
) |
Figures out the filename for the detailed output timestep file and places it in cFilename.
This will produce the name for subplots as well.
iTimestep | Timestep. |
iSubplot | Index of the subplot - -1 = no subplot. |
|
protected |
Makes the master tree settings, for writing to the treemap header.
|
protected |
Writes the detailed output header file.
|
protected |
Writes the XML for a single dead tree.
p_oTree | The tree to write. |
cBuf | The buffer to write to. |
cTemp | Temp char string. |
oOut | File to write. |
|
protected |
Appends the grid data to the file.
Why is this here when grid reading is in the grid object? Because we don't necessarily want to save the whole grid. Output may have a subset of data members to save. Subset or no, all data members are always saved in the settings list so that the map can be used as input.
sFilename | to write to. |
|
protected |
Writes the closing tag for the timestep file.
sFilename | to write to. |
|
protected |
Sets up the timestep file and writes the header data.
sFilename | to write to. |
|
protected |
Writes the XML for a single tree.
p_oTree | The tree to write. |
cBuf | The buffer to write to. |
cTemp | Temp char string. |
oOut | File to write. |
|
protected |
Appends the tree data to the file.
p_sFilename | Array of files to write to. The first is the whole plot, the rest are subplots in order. |
|
protected |
Length of subplot cells in X direction - defaults to match tree population.
|
protected |
Length of subplot cells in Y direction - defaults to match tree population.
|
protected |
number of grid objects we're saving data for
|
protected |
Number of species.
|
protected |
Number of subplots we're saving data for.
|
protected |
Number of types.
|
protected |
Number of plot cells in the X direction - for subplots.
|
protected |
Number of plot cells in the Y direction - for subplots.
|
protected |
Root name of the detailed output file with no file extension on it.
|
protected |
Root detailed output file name plus extension for tarball (gzip'ed and tar'ed)
|
protected |
Array for dead trees, # species by # types by # dead reason codes.
|
protected |
array of stcGridOutputInfo's, one for each grid object that we're saving data for
|
protected |
Compiled settings across live and dead trees for tree map writing - if any tree type/species, live or dead, saves a data member, it will be here, so that it can be written.
|
protected |
An array of stcSubplotInfos, one for each subplot to save.
|
protected |
Array of stcTreeOutputInfo's, number of species by number of types.