SORTIE Core C++ Documentation
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clOutput Class Reference

OUTPUT - Version 1.3. More...

#include <Output.h>

Inheritance diagram for clOutput:
clBehaviorBase clWorkerBase

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...
 
clSimManagerGetSimManager ()
 
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::stcGridOutputInfomp_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::stcSubplotInfomp_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...
 
stcSpeciesTypeCombomp_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...
 
clSimManagermp_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...
 

Detailed Description

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.

Author
Lora E. Murphy


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)

Constructor & Destructor Documentation

◆ clOutput()

clOutput::clOutput ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clOutput()

clOutput::~clOutput ( )

Destructor.

Member Function Documentation

◆ Action()

void clOutput::Action ( )
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.

◆ AddToBuffer()

void clOutput::AddToBuffer ( char *  cBuf,
char *  cToAdd,
FILE *  out,
int  iBufferSize 
)
inlineprotected

Adds a string to a buffer string.

If the buffer is full, it is flushed to file before the new string is added.

Parameters
cBufBuffer string.
cToAddString to add to buffer.
outFile to flush buffer to.
iBufferSizeSize of the buffer.

◆ ExtractDeadTreeInfo()

void clOutput::ExtractDeadTreeInfo ( xercesc::DOMDocument *  p_oDoc)
protected

Extracts the output data relating to dead tree saving.

Parameters
p_oDocDOM tree of parsed input file.

◆ ExtractGridInfo()

void clOutput::ExtractGridInfo ( xercesc::DOMDocument *  p_oDoc)
protected

Extracts the output data relating to grid saving.

Parameters
p_oDocDOM tree of parsed input file.

◆ ExtractLiveTreeInfo()

void clOutput::ExtractLiveTreeInfo ( xercesc::DOMDocument *  p_oDoc)
protected

Extracts the output data relating to tree saving.

Parameters
p_oDocDOM tree of parsed input file.

◆ ExtractSubplotInfo()

void clOutput::ExtractSubplotInfo ( xercesc::DOMDocument *  p_oDoc)
protected

Extracts the subplot data.

Parameters
p_oDocDOM tree of parsed input file.

◆ GetData()

void clOutput::GetData ( xercesc::DOMDocument *  p_oDoc)
protectedvirtual

Reads in the parameter file values.

Parameters
p_oDocDOM tree of parsed input file.
Exceptions
modelErrif the filename is too long.

Implements clWorkerBase.

◆ GetDetailedOutputFilename()

string clOutput::GetDetailedOutputFilename ( )
inline

Gets the detailed output filename.

Returns
Detailed output filename.

◆ GetTimestepFilename()

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.

Parameters
iTimestepTimestep.
iSubplotIndex of the subplot - -1 = no subplot.
Returns
The completed filename.

◆ MakeMasterTreeSettings()

void clOutput::MakeMasterTreeSettings ( )
protected

Makes the master tree settings, for writing to the treemap header.

◆ WriteDetailedOutputHeader()

void clOutput::WriteDetailedOutputHeader ( )
protected

Writes the detailed output header file.

◆ WriteGhost()

void clOutput::WriteGhost ( clDeadTree p_oTree,
char *  cBuf,
char *  cTemp,
FILE *  oOut 
)
protected

Writes the XML for a single dead tree.

Parameters
p_oTreeThe tree to write.
cBufThe buffer to write to.
cTempTemp char string.
oOutFile to write.

◆ WriteGridData()

void clOutput::WriteGridData ( string  sFilename)
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.

Parameters
sFilenameto write to.

◆ WriteTimestepFooter()

void clOutput::WriteTimestepFooter ( string  sFilename)
protected

Writes the closing tag for the timestep file.

Parameters
sFilenameto write to.

◆ WriteTimestepHeader()

void clOutput::WriteTimestepHeader ( string  sFilename)
protected

Sets up the timestep file and writes the header data.

Parameters
sFilenameto write to.

◆ WriteTree()

void clOutput::WriteTree ( clTree p_oTree,
char *  cBuf,
char *  cTemp,
FILE *  oOut 
)
protected

Writes the XML for a single tree.

Parameters
p_oTreeThe tree to write.
cBufThe buffer to write to.
cTempTemp char string.
oOutFile to write.

◆ WriteTreeData()

void clOutput::WriteTreeData ( string *  p_sFilename)
protected

Appends the tree data to the file.

Parameters
p_sFilenameArray of files to write to. The first is the whole plot, the rest are subplots in order.

Member Data Documentation

◆ m_fXCellLength

float clOutput::m_fXCellLength
protected

Length of subplot cells in X direction - defaults to match tree population.

◆ m_fYCellLength

float clOutput::m_fYCellLength
protected

Length of subplot cells in Y direction - defaults to match tree population.

◆ m_iNumGridsToSave

short int clOutput::m_iNumGridsToSave
protected

number of grid objects we're saving data for

◆ m_iNumSpecies

short int clOutput::m_iNumSpecies
protected

Number of species.

◆ m_iNumSubplotsToSave

short int clOutput::m_iNumSubplotsToSave
protected

Number of subplots we're saving data for.

◆ m_iNumTypes

short int clOutput::m_iNumTypes
protected

Number of types.

◆ m_iNumXCells

short int clOutput::m_iNumXCells
protected

Number of plot cells in the X direction - for subplots.

◆ m_iNumYCells

short int clOutput::m_iNumYCells
protected

Number of plot cells in the Y direction - for subplots.

◆ m_sFileRoot

string clOutput::m_sFileRoot
protected

Root name of the detailed output file with no file extension on it.

◆ m_sTarball

string clOutput::m_sTarball
protected

Root detailed output file name plus extension for tarball (gzip'ed and tar'ed)

◆ mp_deadTreeSettings

struct clOutput::stcTreeOutputInfo *** clOutput::mp_deadTreeSettings
protected

Array for dead trees, # species by # types by # dead reason codes.

◆ mp_gridSettings

struct clOutput::stcGridOutputInfo * clOutput::mp_gridSettings
protected

array of stcGridOutputInfo's, one for each grid object that we're saving data for

◆ mp_masterTreeSettings

struct clOutput::stcTreeOutputInfo ** clOutput::mp_masterTreeSettings
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.

◆ mp_subplots

struct clOutput::stcSubplotInfo * clOutput::mp_subplots
protected

An array of stcSubplotInfos, one for each subplot to save.

◆ mp_treeSettings

struct clOutput::stcTreeOutputInfo ** clOutput::mp_treeSettings
protected

Array of stcTreeOutputInfo's, number of species by number of types.


The documentation for this class was generated from the following file: