#include <Output.h>
Public Member Functions | |
clOutput (clSimManager *p_oSimManager) | |
Constructor. | |
~clOutput () | |
Destructor. | |
void | Action () |
Performs output data collection file writing. | |
string | GetDetailedOutputFilename () |
Gets the detailed output filename. | |
string | GetTimestepFilename (int iTimestep, int iSubplot) |
Figures out the filename for the detailed output timestep file and places it in cFilename. | |
Protected Member Functions | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Reads in the parameter file values. | |
void | WriteDetailedOutputHeader () |
Writes the detailed output header file. | |
void | WriteTimestepHeader (string sFilename) |
Sets up the timestep file and writes the header data. | |
void | WriteTimestepFooter (string sFilename) |
Writes the closing tag for the timestep file. | |
void | WriteTreeData (string *p_sFilename) |
Appends the tree data to the file. | |
void | WriteGridData (string sFilename) |
Appends the grid data to the file. | |
void | ExtractLiveTreeInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to tree saving. | |
void | ExtractDeadTreeInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to dead tree saving. | |
void | ExtractGridInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the output data relating to grid saving. | |
void | ExtractSubplotInfo (xercesc::DOMDocument *p_oDoc) |
Extracts the subplot data. | |
void | MakeMasterTreeSettings () |
Makes the master tree settings, for writing to the treemap header. | |
void | WriteTree (clTree *p_oTree, char *cBuf, char *cTemp, FILE *oOut) |
Writes the XML for a single tree. | |
void | WriteGhost (clDeadTree *p_oTree, char *cBuf, char *cTemp, FILE *oOut) |
Writes the XML for a single dead tree. | |
void | AddToBuffer (char *cBuf, char *cToAdd, FILE *out, int iBufferSize) |
Adds a string to a buffer string. | |
Protected Attributes | |
string | m_sFileRoot |
Root name of the detailed output file with no file extension on it. | |
string | m_sTarball |
Root detailed output file name plus extension for tarball (gzip'ed and tar'ed). | |
struct clOutput::stcTreeOutputInfo ** | mp_treeSettings |
Defines what tree output data to save. | |
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. | |
struct clOutput::stcTreeOutputInfo *** | mp_deadTreeSettings |
Array for dead trees, # species by # types by # dead reason codes. | |
struct clOutput::stcGridOutputInfo * | mp_gridSettings |
Data structure for defining what grid output data to save. | |
short int | m_iNumGridsToSave |
number of grid objects we're saving data for | |
struct clOutput::stcSubplotInfo * | mp_subplots |
Data structure for saving subplot data. | |
short int | m_iNumSubplotsToSave |
Number of subplots we're saving data for. | |
short int | m_iNumSpecies |
Number of species. | |
short int | m_iNumTypes |
Number of types. | |
short int | m_iNumXCells |
Number of plot cells in the X direction - for subplots. | |
short int | m_iNumYCells |
Number of plot cells in the Y direction - for subplots. | |
float | m_fXCellLength |
Length of subplot cells in X direction - defaults to match tree population. | |
float | m_fYCellLength |
Length of subplot cells in Y direction - defaults to match tree population. | |
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... |
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.
clOutput::clOutput | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clOutput::~clOutput | ( | ) |
Destructor.
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.
string clOutput::GetDetailedOutputFilename | ( | ) | [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. |
void clOutput::GetData | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected, virtual] |
Reads in the parameter file values.
p_oDoc | DOM tree of parsed input file. |
modelErr | if the filename is too long. |
Implements clWorkerBase.
void clOutput::WriteDetailedOutputHeader | ( | ) | [protected] |
Writes the detailed output header file.
void clOutput::WriteTimestepHeader | ( | string | sFilename | ) | [protected] |
Sets up the timestep file and writes the header data.
sFilename | to write to. |
void clOutput::WriteTimestepFooter | ( | string | sFilename | ) | [protected] |
Writes the closing tag for the timestep file.
sFilename | to write to. |
void clOutput::WriteTreeData | ( | string * | p_sFilename | ) | [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. |
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.
sFilename | to write to. |
void clOutput::ExtractLiveTreeInfo | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected] |
Extracts the output data relating to tree saving.
p_oDoc | DOM tree of parsed input file. |
void clOutput::ExtractDeadTreeInfo | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected] |
Extracts the output data relating to dead tree saving.
p_oDoc | DOM tree of parsed input file. |
void clOutput::ExtractGridInfo | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected] |
Extracts the output data relating to grid saving.
p_oDoc | DOM tree of parsed input file. |
void clOutput::ExtractSubplotInfo | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected] |
Extracts the subplot data.
p_oDoc | DOM tree of parsed input file. |
void clOutput::MakeMasterTreeSettings | ( | ) | [protected] |
Makes the master tree settings, for writing to the treemap header.
void clOutput::WriteTree | ( | clTree * | p_oTree, | |
char * | cBuf, | |||
char * | cTemp, | |||
FILE * | oOut | |||
) | [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. |
void clOutput::WriteGhost | ( | clDeadTree * | p_oTree, | |
char * | cBuf, | |||
char * | cTemp, | |||
FILE * | oOut | |||
) | [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. |
void clOutput::AddToBuffer | ( | char * | cBuf, | |
char * | cToAdd, | |||
FILE * | out, | |||
int | iBufferSize | |||
) | [inline, protected] |
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. |
string clOutput::m_sFileRoot [protected] |
Root name of the detailed output file with no file extension on it.
string clOutput::m_sTarball [protected] |
Root detailed output file name plus extension for tarball (gzip'ed and tar'ed).
struct clOutput::stcTreeOutputInfo
** clOutput::mp_treeSettings [protected] |
Defines what tree output data to save.
Array of stcTreeOutputInfo's, number of species by number of types
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.
struct clOutput::stcTreeOutputInfo
*** clOutput::mp_deadTreeSettings [protected] |
Array for dead trees, # species by # types by # dead reason codes.
struct clOutput::stcGridOutputInfo * clOutput::mp_gridSettings [protected] |
Data structure for defining what grid output data to save.
array of stcGridOutputInfo's, one for each grid object that we're saving data for
short int clOutput::m_iNumGridsToSave [protected] |
number of grid objects we're saving data for
struct clOutput::stcSubplotInfo * clOutput::mp_subplots [protected] |
Data structure for saving subplot data.
They get the same data saved as the plot as a whole.An array of stcSubplotInfos, one for each subplot to save
short int clOutput::m_iNumSubplotsToSave [protected] |
Number of subplots we're saving data for.
short int clOutput::m_iNumSpecies [protected] |
Number of species.
short int clOutput::m_iNumTypes [protected] |
Number of types.
short int clOutput::m_iNumXCells [protected] |
Number of plot cells in the X direction - for subplots.
short int clOutput::m_iNumYCells [protected] |
Number of plot cells in the Y direction - for subplots.
float clOutput::m_fXCellLength [protected] |
Length of subplot cells in X direction - defaults to match tree population.
float clOutput::m_fYCellLength [protected] |
Length of subplot cells in Y direction - defaults to match tree population.