Simulation module settings. More...

Classes

class  PrintInfoItem
 Class stores a single output item of an OuputID. More...
 
class  PrintInfo
 Outputs of one variable, which may contain one or more PrintInfoItem More...
 
class  InputArgs
 Parse the input arguments of SEIMS. More...
 
struct  ModelClass
 Module basic description. More...
 
struct  Information
 Module development information class. More...
 
struct  baseParameter
 Basic model parameter information. More...
 
struct  Parameter
 Model parameter information class. More...
 
struct  InputVariable
 Input variable information class. More...
 
struct  OutputVariable
 Output variable information class. More...
 
struct  InOutputVariable
 Input and output variable information class. More...
 
class  ModuleFactory
 Linking user-defined modules to create the modeling workflow. More...
 
class  SimulationModule
 Base module for all simulation modules in SEIMS. More...
 

Enumerations

enum  AggregationType {
  AT_Unknown = 0 ,
  AT_Sum = 1 ,
  AT_Average = 2 ,
  AT_Minimum = 3 ,
  AT_Maximum = 4 ,
  AT_SpecificCells = 5 ,
  AT_TimeSeries = 6
}
 Aggregation type for OUTPUT. More...
 
enum  dimensionTypes {
  DT_Unknown = -1 ,
  DT_Single = 0 ,
  DT_SingleInt = 1 ,
  DT_Array1DDateValue = 2 ,
  DT_Array1D = 3 ,
  DT_Array1DInt = 4 ,
  DT_Array2D = 5 ,
  DT_Array2DInt = 6 ,
  DT_Raster1D = 7 ,
  DT_Raster1DInt = 8 ,
  DT_Raster2D = 9 ,
  DT_Raster2DInt = 10 ,
  DT_Scenario = 11 ,
  DT_Reach = 12 ,
  DT_Subbasin = 13
}
 enum of dimension data types More...
 
enum  transferTypes {
  TF_None = 0 ,
  TF_SingleValue = 1 ,
  TF_OneArray1D = 2
}
 Float values be transferred across subbasins for MPI version. More...
 
enum  TimeStepType {
  TIMESTEP_HILLSLOPE ,
  TIMESTEP_CHANNEL ,
  TIMESTEP_SIMULATION
}
 Time step types. More...
 

Detailed Description

Simulation module settings.


Class Documentation

◆ PrintInfoItem

class PrintInfoItem

Class stores a single output item of an OuputID.

Public Member Functions

 PrintInfoItem (int scenario_id=0, int calibration_id=-1)
 Constructor.
 
 ~PrintInfoItem ()
 Destructor.
 
void add1DTimeSeriesResult (time_t, int n, const FLTPT *data)
 Add 1D time series data result to TimeSeriesDataForSubbasin.
 
void add1DRasterTimeSeriesResult (time_t, int n, const float *data)
 Add 1D time series data result to TimeSeriesDataForRaster.
 
time_t getStartTime ()
 get start time time_t
 
void setStartTime (const time_t &st)
 set start time time_t
 
time_t getEndTime ()
 Get end time time_t.
 
void setEndTime (const time_t &st)
 set end time time_t
 
void Flush (const string &projectPath, MongoGridFs *gfs, IntRaster *templateRaster, const string &header)
 create "output" folder to store all results
 
bool IsDateInRange (time_t dt)
 Determine if the given date is within the date range for this item.
 
void AggregateData (int numrows, FLTPT **data, AggregationType type, FLTPT NoDataValue)
 Aggregate the 2D data from the given data parameter using the given method type. More...
 
void AggregateData (time_t time, int numrows, FLTPT *data)
 Aggregate the 1D data from the given data parameter using the given method type.
 
void AggregateData2D (time_t time, int nRows, int nCols, FLTPT **data)
 Aggregate the 2D raster data from the given data parameter using the given method type.
 
void setAggregationType (const AggregationType type)
 Set the Aggregation type.
 
AggregationType getAggregationType ()
 Get the Aggregation type.
 

Static Public Member Functions

static AggregationType MatchAggregationType (const string &type)
 convert the given string into a matching Aggregation type
 

Public Attributes

FLTPT ** m_1DDataWithRowCol
 Aggregated data, the second dimension contains: row, col, value.
 
int m_nRows
 rows number, i.e., number of valid cells
 
FLTPT * m_1DData
 For 1D raster/array data.
 
int m_nLayers
 number of layers of raster data, greater or equal than 1
 
FLTPT ** m_2DData
 For 2D raster/array data.
 
map< time_t, FLTPT > TimeSeriesData
 For time series data of a single subbasin, DT_Single.
 
map< time_t, FLTPT * > TimeSeriesDataForSubbasin
 For time series data of a single subbasin, DT_Raster1D or DT_Array1D.
 
int TimeSeriesDataForSubbasinCount
 Count of TimeSeriesDataForSubbasin.
 
map< time_t, float * > TimeSeriesDataForRaster
 For time series data of DT_Raster1D(output some .tif files. Distinct from TimeSeriesDataForSubbasin,which output some .txt files)
 
int TimeSeriesDataForRasterCount
 Count of TimeSeriesDataForRaster.
 
int SiteID
 used only by PET_TS??? The site id More...
 
int SiteIndex
 The subbasin id.
 
int SubbasinID
 The subbasin index.
 
time_t m_startTime
 Start time time_t.
 
time_t m_endTime
 End time time_t.
 
string Suffix
 file suffix, e.g., txt, tif, asc, etc.
 
string Corename
 output filename without suffix, core name without subbasin ID
 
string Filename
 output filename without suffix, and contain subbasin ID as prefix for MPI version
 
string AggType
 Aggregation type string.
 

Member Function Documentation

◆ AggregateData()

void PrintInfoItem::AggregateData ( int  numrows,
FLTPT **  data,
AggregationType  type,
FLTPT  NoDataValue 
)

Aggregate the 2D data from the given data parameter using the given method type.

However this **data restrict to 3 layers, i.e., Row, Col, Value NO NEED TO USE?

Member Data Documentation

◆ SiteID

int PrintInfoItem::SiteID

used only by PET_TS??? The site id

The site index in output array1D variable

◆ PrintInfo

class PrintInfo

Outputs of one variable, which may contain one or more PrintInfoItem

See also
PrintInfoItem

Public Member Functions

 PrintInfo (int scenario_id=0, int calibration_id=-1)
 Constructor, initialize an empty instance.
 
 ~PrintInfo ()
 Destructor.
 
int ItemCount () const
 Get the number of output items.
 
void getSubbasinSelected (int *count, int **subbasins)
 Get all the subbasin IDs (in float array) selected for this outputID.
 
void setOutputID (string id)
 Set the OutputID for this object.
 
string getOutputID () const
 Get the OutputId for this object.
 
string getOutputTimeSeriesHeader ()
 Get Header string (all field names) for current OutputID. TODO, how to make it more flexible? By LJ.
 
void setInterval (int interval)
 Set the interval.
 
int getInterval ()
 Get the interval.
 
void setIntervalUnits (string &units)
 Set the interval units.
 
string getIntervalUnits () const
 Get the interval units.
 
void AddPrintItem (time_t start, time_t end, const string &file, const string &sufi)
 Add an output item with the given start time, end time and file name.
 
void AddPrintItem (string &type, time_t start, time_t end, const string &file, const string &sufi, int subbasinID=0)
 Add an output item with the given aggregate type, start time, end time, file name and subbasin ID.
 
void AddPrintItem (time_t start, time_t end, const string &file, string sitename, const string &sufi, bool isSubbasin)
 Add an output item with the given start time (string), end time (string) and file name, Overloaded method.
 
PrintInfoItemgetPrintInfoItem (int index)
 Get a reference to the output item located at the given index position.
 

Public Attributes

int m_scenarioID
 Scenario ID.
 
int m_calibrationID
 Calibration ID.
 
int m_Interval
 Time interval of output.
 
string m_IntervalUnits
 Unit of time interval, which can only be DAY, HR, SEC.
 
int m_moduleIndex
 Module index of the OutputID.
 
string m_OutputID
 Unique Output ID, which should be one of "VAR_" defined in text.h and Output of any modules.
 
ParamInfo< FLTPT > * m_param
 The calibration parameters corresponding to the output id, if stated.
 
vector< PrintInfoItem * > m_PrintItems
 For one OutputID, there may be several output items, e.g., different time period, different subbasin ID. etc.
 

◆ InputArgs

class InputArgs

Parse the input arguments of SEIMS.

Inheritance diagram for InputArgs:
ccgl::Interface

Public Member Functions

 InputArgs (const string &model_path, const string &model_cfgname, int thread_num, FlowDirMethod fdir_mtd, LayeringMethod lyr_mtd, const string &host, uint16_t port, int scenario_id, int calibration_id, int subbasin_id, GroupMethod grp_mtd, ScheduleMethod skd_mtd, int time_slices, const string &log_level, bool mpi_version=false)
 Constructor by detailed parameters. More...
 

Static Public Member Functions

static InputArgsInit (int argc, const char **argv, bool mpi_version=false)
 Initializer. More...
 

Public Attributes

string model_path
 full path of model folder which contains all inputs and outputs of all models
 
string model_cfgname
 config name of specific model, the default is "", it corresponds to a subfolder
 
string model_name
 model_name
 
string output_scene
 output identifier concatenated with scenario_id, calibration_id, lyr_mtd, fdir_mtd
 
string output_path
 full path of model outputs
 
int thread_num
 thread number for OpenMP
 
FlowDirMethod fdir_mtd
 Flow direction method for flow routing, default is 0 (D8)
 
LayeringMethod lyr_mtd
 Layering method for sequencing computing, default is 0.
 
string host
 Host IP address or name of MongoDB database.
 
uint16_t port
 port of MongoDB, 27017 is default
 
int scenario_id
 scenario ID defined in Database, -1 for no use.
 
int calibration_id
 calibration ID defined in Database (PARAMETERS), -1 for no use.
 
int subbasin_id
 Subbasin ID, which will be executed, 0 for whole basin, 9999 for field-version.
 
GroupMethod grp_mtd
 Group method for parallel task scheduling, default is 0.
 
ScheduleMethod skd_mtd
 Parallel task scheduling strategy at subbasin level by MPI.
 
int time_slices
 Time slices for Temporal-Spatial discretization method, Wang et al. (2013). Unfinished!
 
string log_level
 logging level, i.e., Trace, Debug, Info (default), Warning, Error, and Fatal
 
bool mpi_version
 is running the MPI version?
 

Constructor & Destructor Documentation

◆ InputArgs()

InputArgs::InputArgs ( const string &  model_path,
const string &  model_cfgname,
int  thread_num,
FlowDirMethod  fdir_mtd,
LayeringMethod  lyr_mtd,
const string &  host,
uint16_t  port,
int  scenario_id,
int  calibration_id,
int  subbasin_id,
GroupMethod  grp_mtd,
ScheduleMethod  skd_mtd,
int  time_slices,
const string &  log_level,
bool  mpi_version = false 
)

Constructor by detailed parameters.

Parameters
[in]model_pathpath of the configuration of the Model
[in]model_cfgnameconfig name of specific model, the default is "", it corresponds to a subfolder
[in]thread_numthread or processor number, which must be greater or equal than 1 (default)
[in]fdir_mtdcan be 0, 1, and 2, which means D8 (default), Dinf, and MFDmd, respectively
[in]lyr_mtdcan be 0 and 1, which means UP_DOWN (default) and DOWN_UP, respectively
[in]hostthe address of MongoDB database, by default, MongoDB IP is 127.0.0.1 (i.e., localhost)
[in]portport number, default is 27017
[in]scenario_idthe ID of BMPs Scenario which has been defined in BMPs database
[in]calibration_idthe ID of Calibration which has been defined in PARAMETERS table
[in]subbasin_idthe subbasin that will be executed, default is 0 which means the whole watershed
[in]grp_mtdcan be 0 and 1, which means KMETIS (default) and PMETIS, respectively
[in]skd_mtd(TESTED) can be 0 and 1, which means SPATIAL (default) and TEMPOROSPATIAL, respectively
[in]time_slices(TESTED) should be greater than 1, required when <skd_mtd> is 1
[in]log_levellogging level, the default is Info
[in]mpi_versionOptional, is running the MPI version?

Member Function Documentation

◆ Init()

static InputArgs * InputArgs::Init ( int  argc,
const char **  argv,
bool  mpi_version = false 
)
static

Initializer.

Parameters
[in]argcNumber of arguments
[in]argvchar* Arguments
[in]mpi_versionOptional, is running the MPI version?

◆ ModelClass

struct ModelClass

Module basic description.

◆ Information

struct Information

Module development information class.

Public Attributes

string Id
 Module ID.
 
string Name
 Module Name.
 
string Description
 Module Description.
 
string Version
 Module Version.
 
string Author
 Author.
 
string EMail
 Email.
 
string Website
 Website.
 
string Helpfile
 Helpfile.
 

◆ baseParameter

struct baseParameter

Basic model parameter information.

Inheritance diagram for baseParameter:
OutputVariable Parameter InputVariable InOutputVariable

Public Attributes

string Name
 Name.
 
string Units
 Units.
 
string Description
 Description.
 
dimensionTypes Dimension
 Data dimension type.
 

◆ Parameter

struct Parameter

Model parameter information class.

Inheritance diagram for Parameter:
baseParameter InputVariable InOutputVariable

Public Attributes

string Source
 Source type.
 
- Public Attributes inherited from baseParameter
string Name
 Name.
 
string Units
 Units.
 
string Description
 Description.
 
dimensionTypes Dimension
 Data dimension type.
 

◆ InputVariable

struct InputVariable

Input variable information class.

Inheritance diagram for InputVariable:
Parameter baseParameter InOutputVariable

Additional Inherited Members

- Public Attributes inherited from Parameter
string Source
 Source type.
 
- Public Attributes inherited from baseParameter
string Name
 Name.
 
string Units
 Units.
 
string Description
 Description.
 
dimensionTypes Dimension
 Data dimension type.
 

◆ OutputVariable

struct OutputVariable

Output variable information class.

Inheritance diagram for OutputVariable:
baseParameter

Additional Inherited Members

- Public Attributes inherited from baseParameter
string Name
 Name.
 
string Units
 Units.
 
string Description
 Description.
 
dimensionTypes Dimension
 Data dimension type.
 

◆ InOutputVariable

struct InOutputVariable

Input and output variable information class.

Inheritance diagram for InOutputVariable:
InputVariable Parameter baseParameter

Additional Inherited Members

- Public Attributes inherited from Parameter
string Source
 Source type.
 
- Public Attributes inherited from baseParameter
string Name
 Name.
 
string Units
 Units.
 
string Description
 Description.
 
dimensionTypes Dimension
 Data dimension type.
 

◆ MetadataInfo

class MetadataInfo

Metadata information of module.

Inheritance diagram for MetadataInfo:
ccgl::Interface

◆ ModuleFactory

class ModuleFactory

Linking user-defined modules to create the modeling workflow.

Inheritance diagram for ModuleFactory:
ccgl::NotCopyable

Public Member Functions

 ModuleFactory (string model_name, vector< string > &moduleIDs, map< string, SEIMSModuleSetting * > &moduleSettings, vector< DLLINSTANCE > &dllHandles, map< string, InstanceFunction > &instanceFuncs, map< string, MetadataFunction > &metadataFuncs, map< string, vector< ParamInfo< FLTPT > * > > &moduleParams, map< string, vector< ParamInfo< int > * > > &moduleParamsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleInputs, map< string, vector< ParamInfo< int > * > > &moduleInputsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleOutputs, map< string, vector< ParamInfo< int > * > > &moduleOutputsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleInOutputs, map< string, vector< ParamInfo< int > * > > &moduleInOutputsInt, vector< ParamInfo< FLTPT > * > &tfValueInputs, vector< ParamInfo< int > * > &tfValueInputsInt, int mpi_rank=0, int mpi_size=-1)
 Constructor.
 
 ~ModuleFactory ()
 Destructor.
 
void CreateModuleList (vector< SimulationModule * > &modules, int nthread=1)
 Create a set of objects and set up the relationship among them. Return time-consuming.
 
void GetValueFromDependencyModule (int iModule, vector< SimulationModule * > &modules)
 Get value from dependency modules.
 
bool FindOutputParameter (string &outputID, int &iModule, ParamInfo< FLTPT > *&paraInfo)
 Find outputID parameter's module. Return Module index iModule and its ParamInfo<FLTPT>
 
string GetModuleID (int i) const
 Get Module ID by index.
 
vector< string > & GetModuleIDs ()
 Get unique module IDs.
 
map< string, SEIMSModuleSetting * > & GetModuleSettings ()
 Get map of module settings.
 
map< string, vector< ParamInfo< FLTPT > * > > & GetModuleParams ()
 Get Parameters of modules.
 
map< string, vector< ParamInfo< int > * > > & GetModuleParamsInt ()
 Get integer parameters of modules.
 
map< string, vector< ParamInfo< FLTPT > * > > & GetModuleInputs ()
 Get Input of modules, from other modules.
 
map< string, vector< ParamInfo< int > * > > & GetModuleInputsInt ()
 Get integer input of modules, from other modules.
 
map< string, vector< ParamInfo< FLTPT > * > > & GetModuleOutputs ()
 Get Output of modules, out from current module.
 
map< string, vector< ParamInfo< int > * > > & GetModuleOutputsInt ()
 Get integer Output of modules, out from current module.
 
map< string, vector< ParamInfo< FLTPT > * > > & GetModuleInOutputs ()
 Get InOutput of modules, in and out from current module.
 
map< string, vector< ParamInfo< int > * > > & GetModuleInOutputsInt ()
 Get integer InOutput of modules, in and out from current module.
 
vector< ParamInfo< FLTPT > * > & GetTransferredInputs ()
 Get transferred single value inputs across subbasins.
 
vector< ParamInfo< int > * > & GetTransferredInputsInt ()
 Get transferred single integer value inputs across subbasins.
 
int GetTransferredInputsCount ()
 Get the count of transferred single value inputs.
 
int GetTransferredInputsIntCount ()
 Get the count of transferred single integer value inputs.
 
SimulationModuleGetInstance (const string &moduleID)
 Get module instance by moduleID.
 

Static Public Member Functions

static ModuleFactoryInit (const string &module_path, InputArgs *input_args, int mpi_rank=0, int mpi_size=-1)
 Initialization for exception-safe constructor.
 
static bool LoadSettingsFromFile (const char *filename, vector< vector< string > > &settings)
 Load modules setting from file.
 
static bool ReadConfigFile (const char *configFileName, vector< string > &moduleIDs, map< string, SEIMSModuleSetting * > &moduleSettings)
 Read configuration file. More...
 
static bool LoadParseLibrary (const string &module_path, vector< string > &moduleIDs, map< string, SEIMSModuleSetting * > &moduleSettings, vector< DLLINSTANCE > &dllHandles, map< string, InstanceFunction > &instanceFuncs, map< string, MetadataFunction > &metadataFuncs, map< string, vector< ParamInfo< FLTPT > * > > &moduleParams, map< string, vector< ParamInfo< int > * > > &moduleParamsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleInputs, map< string, vector< ParamInfo< int > * > > &moduleInputsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleOutputs, map< string, vector< ParamInfo< int > * > > &moduleOutputsInt, map< string, vector< ParamInfo< FLTPT > * > > &moduleInOutputs, map< string, vector< ParamInfo< int > * > > &moduleInOutputsInt, vector< ParamInfo< FLTPT > * > &tfValueInputs, vector< ParamInfo< int > * > &tfValueInputsInt)
 Load and parse module libraries. More...
 
static void ReadDLL (const string &module_path, const string &id, const string &dllID, vector< DLLINSTANCE > &dllHandles, map< string, InstanceFunction > &instanceFuncs, map< string, MetadataFunction > &metadataFuncs)
 Load function pointers from .DLL or .so.
 
static dimensionTypes MatchType (const string &strType)
 Match data type, e.g., 1D array.
 
static transferTypes MatchTransferType (const string &tfType)
 Match data transfer type, e.g., TF_SingleValue.
 
static bool IsConstantInputFromName (const string &name)
 Is constant input?
 
static void ReadParameterSetting (string &moduleID, TiXmlDocument &doc, SEIMSModuleSetting *setting, map< string, vector< ParamInfo< FLTPT > * > > &moduleParams, map< string, vector< ParamInfo< int > * > > &moduleParamsInt)
 Read module's parameters setting from XML string.
 
static void ReadIOSetting (string &moduleID, TiXmlDocument &doc, SEIMSModuleSetting *setting, const string &header, const string &title, map< string, vector< ParamInfo< FLTPT > * > > &vars, map< string, vector< ParamInfo< int > * > > &varsInt)
 Read module's input, output, and in/output setting from XML string.
 
static string GetComparableName (string &paraName)
 Get comparable name after underscore if necessary, e.g., T_PET => use PET.
 
static ParamInfo< FLTPT > * FindDependentParam (ParamInfo< FLTPT > *paramInfo, vector< string > &moduleIDs, map< string, vector< ParamInfo< FLTPT > * > > &moduleOutputs)
 Find dependent parameters.
 
static ParamInfo< int > * FindDependentParam (ParamInfo< int > *paramInfo, vector< string > &moduleIDs, map< string, vector< ParamInfo< int > * > > &moduleOutputs)
 Find dependent parameters.
 

Public Attributes

int m_mpi_rank
 Rank ID for MPI, starts from 0 to mpi_size_ - 1.
 
int m_mpi_size
 Rank size for MPI.
 

Member Function Documentation

◆ LoadParseLibrary()

static bool ModuleFactory::LoadParseLibrary ( const string &  module_path,
vector< string > &  moduleIDs,
map< string, SEIMSModuleSetting * > &  moduleSettings,
vector< DLLINSTANCE > &  dllHandles,
map< string, InstanceFunction > &  instanceFuncs,
map< string, MetadataFunction > &  metadataFuncs,
map< string, vector< ParamInfo< FLTPT > * > > &  moduleParams,
map< string, vector< ParamInfo< int > * > > &  moduleParamsInt,
map< string, vector< ParamInfo< FLTPT > * > > &  moduleInputs,
map< string, vector< ParamInfo< int > * > > &  moduleInputsInt,
map< string, vector< ParamInfo< FLTPT > * > > &  moduleOutputs,
map< string, vector< ParamInfo< int > * > > &  moduleOutputsInt,
map< string, vector< ParamInfo< FLTPT > * > > &  moduleInOutputs,
map< string, vector< ParamInfo< int > * > > &  moduleInOutputsInt,
vector< ParamInfo< FLTPT > * > &  tfValueInputs,
vector< ParamInfo< int > * > &  tfValueInputsInt 
)
static

Load and parse module libraries.

Parameters
module_path
moduleIDs
moduleSettings
dllHandles
instanceFuncs
metadataFuncs
moduleParams
moduleParamsInt
moduleInputs
moduleInputsInt
moduleOutputs
moduleOutputsInt
moduleInOutputs
tfValueInputs
Returns
True if succeed, else throw exception and return false.

◆ ReadConfigFile()

static bool ModuleFactory::ReadConfigFile ( const char *  configFileName,
vector< string > &  moduleIDs,
map< string, SEIMSModuleSetting * > &  moduleSettings 
)
static

Read configuration file.

Parameters
[in]configFileNameConfiguration full file path
[out]moduleIDsUnique module IDs (name)
[out]moduleSettingsMap of SEIMSModuleSetting
Returns
True if succeed.

◆ SimulationModule

class SimulationModule

Base module for all simulation modules in SEIMS.

Inheritance diagram for SimulationModule:
ccgl::Interface AET_PT_H Biomass_EPIC DepressionFS DepressionFSDaily DiffusiveWave ExcessRunoff ExcessRunoff GWaterReservoir IKW_REACH IUH_IF IUH_OL IUH_SED_OL ImplicitKinematicWave_CH ImplicitKinematicWave_OL InterFlow_IKW Interpolate KinWavSed_CH KinWavSed_OL MGTOpt_SWAT MUSK_CH NPS_Management NutrCH_QUAL2E NutrientMovementViaWater NutrientTransportSediment Nutrient_Transformation NutrientinGroundwater PER_PI PER_STR PETHargreaves PETPenmanMonteith PETPriestleyTaylor Percolation_DARCY ReservoirMethod SEDR_SBAGNOLD SERO_MUSLE SET_LM SNO_DD SNO_SP SNO_WB SOL_WB SRD_MB SSM_PE SUR_CN SUR_GreenAmpt SUR_MR SoilTemperatureFINPL SplashEro_Park StormGreenAmpt clsPI_MCS clsPI_SVSC clsTSD_RD

Public Member Functions

 SimulationModule ()
 Constructor.
 
virtual int Execute ()
 Execute the simulation. Return 0 for success.
 
virtual void SetDate (time_t t, int year_idx)
 Set date time, as well as the sequence number of the entire simulation. Added by LJ for statistics convenient.
 
virtual void SetTheadNumber (const int thread_num)
 Set thread number for OpenMP.
 
virtual void SetClimateDataType (int data_type)
 Set climate data type, P, M, PET etc.
 
virtual void SetValue (const char *key, int value)
 Set data, DT_Single, integer.
 
virtual void SetValue (const char *key, FLTPT value)
 Set data, DT_Single, float point number (float or double)
 
virtual void SetValueByIndex (const char *key, int index, int value)
 Set single value to array1D by index, used in MPI version for passing values of subbasins, integer.
 
virtual void SetValueByIndex (const char *key, int index, FLTPT value)
 Set single value to array1D by index, used in MPI version for passing values of subbasins, float.
 
virtual void Set1DData (const char *key, int n, int *data)
 Set 1D data, by default, DT_Raster1D, integer.
 
virtual void Set1DData (const char *key, int n, FLTPT *data)
 Set 1D data, by default, DT_Raster1D, float.
 
virtual void Set2DData (const char *key, int nrows, int ncols, int **data)
 Set 2D data, by default, DT_Raster2D, integer.
 
virtual void Set2DData (const char *key, int nrows, int ncols, FLTPT **data)
 Set 2D data, by default, DT_Raster2D, float.
 
virtual void GetValue (const char *key, int *value)
 Get value, DT_Single, integer.
 
virtual void GetValue (const char *key, FLTPT *value)
 Get value, DT_Single, float.
 
virtual void Get1DData (const char *key, int *n, int **data)
 Get 1D data, by default, DT_Raster1D, integer.
 
virtual void Get1DData (const char *key, int *n, FLTPT **data)
 Get 1D data, by default, DT_Raster1D, float.
 
virtual void Get2DData (const char *key, int *nrows, int *ncols, int ***data)
 Get 2D data, by default, DT_Raster2D, integer.
 
virtual void Get2DData (const char *key, int *nrows, int *ncols, FLTPT ***data)
 Get 2D data, by default, DT_Raster2D, float.
 
virtual void SetScenario (Scenario *sce)
 Set pointer of Scenario class which contains all BMP information. Added by LJ, 2016-6-14.
 
virtual void SetReaches (clsReaches *rches)
 Set pointer of clsReaches class which contains all reaches information. Added by LJ, 2016-7-2.
 
virtual void SetSubbasins (clsSubbasins *subbsns)
 Set pointer of clsSubbasins class which contains all subbasins information. Added by LJ, 2016-7-28.
 
virtual bool CheckInputData ()
 Check the input data. More...
 
virtual bool CheckInputSize (const char *module_id, const char *key, int nrows, int &m_nrows)
 Check data length of the first dimension (i.e., nRows) of the input array-based data. More...
 
virtual bool CheckInputSize2D (const char *module_id, const char *key, int nrows, int ncols, int &m_nrows, int &m_ncols)
 Check data length of the two dimensions (i.e., nRows and nCols) of the input array-based data. More...
 
virtual void InitialOutputs ()
 Initialize output variables. More...
 
virtual void InitialIntermediates ()
 Initialize intermediate parameters for reducing computing amount. More...
 
virtual TimeStepType GetTimeStepType ()
 Get time step type, default is hillslope process. More...
 
virtual void ResetSubTimeStep ()
 Reset subtime step.
 
bool IsInputsSetDone ()
 Whether the inputs (i.e., inputs derived from other modules) have been set.
 
void SetInputsDone (const bool set_done)
 Change the status of setting inputs parameters.
 
void SetReCalIntermediates (const bool recal)
 set whether intermediate parameters need to recalculated
 

Protected Attributes

time_t m_date
 date time
 
int m_yearIdx
 index of current year of simulation, e.g., the simulation period from 2010 to 2015, m_yearIdx is 2 when simulate 2012.
 
int m_year
 year
 
int m_month
 month since January - [1,12]
 
int m_day
 day of the month - [1,31]
 
int m_dayOfYear
 day of year - [1, 366]
 
int m_tsCounter
 sub-timestep counter
 
bool m_inputsSetDone
 Whether the inputs parameters (i.e., parameters derived from other modules) have been set.
 
bool m_reCalIntermediates
 need to recalculate intermediate parameters?
 

Member Function Documentation

◆ CheckInputData()

◆ CheckInputSize()

virtual bool SimulationModule::CheckInputSize ( const char *  module_id,
const char *  key,
int  nrows,
int &  m_nrows 
)
virtual

Check data length of the first dimension (i.e., nRows) of the input array-based data.

Parameters
[in]module_idModule ID used to print exception message
[in]keythe key to identify the requested data
[in]nrowssize of the first dimension
[out]m_nrowsthe expected size, if m_nrows less or equal to 0, then m_nrows = mrows

◆ CheckInputSize2D()

virtual bool SimulationModule::CheckInputSize2D ( const char *  module_id,
const char *  key,
int  nrows,
int  ncols,
int &  m_nrows,
int &  m_ncols 
)
virtual

Check data length of the two dimensions (i.e., nRows and nCols) of the input array-based data.

Parameters
[in]module_idModule ID used to print exception message
[in]keythe key to identify the requested data
[in]nrowssize of the first dimension
[in]ncolssize of the second dimension
[out]m_nrowsthe expected rows size, if m_nrows less or equal to 0, then m_nrows = mrows
[out]m_ncolsthe expected cols size, if m_ncols less or equal to 0, then m_ncols = ncols

◆ GetTimeStepType()

virtual TimeStepType SimulationModule::GetTimeStepType ( )
virtual

Get time step type, default is hillslope process.

   Remember to OVERRIDE this function to return other time step type for
   routing modules and others if necessary.

Reimplemented in IKW_REACH, SEDR_SBAGNOLD, ImplicitKinematicWave_CH, ReservoirMethod, MUSK_CH, NutrCH_QUAL2E, and NutrientinGroundwater.

◆ InitialIntermediates()

virtual void SimulationModule::InitialIntermediates ( )
virtual

Initialize intermediate parameters for reducing computing amount.

   This function is optional to be overridden.
   Intermediate parameters only need to be calculated once
     and will not change during simulation.
   This function must be separated with InitialOutputs().

   For example, K*P*LS*11.8*exp(ROCK) in the equation of MUSLE can be
     considered as an intermediate parameter.

Reimplemented in SERO_MUSLE, and NutrientTransportSediment.

◆ InitialOutputs()

virtual void SimulationModule::InitialOutputs ( void  )
virtual

Enumeration Type Documentation

◆ AggregationType

Aggregation type for OUTPUT.

Enumerator
AT_Unknown 

unknown

AT_Sum 

sum

AT_Average 

average

AT_Minimum 

minimum

AT_Maximum 

maximum

AT_SpecificCells 

specific cells

◆ dimensionTypes

enum of dimension data types

Enumerator
DT_Unknown 

Unknown type.

DT_Single 

Single floating point number.

DT_SingleInt 

Single integer.

DT_Array1DDateValue 

1D date array

DT_Array1D 

1D floating point array, e.g., maximum temperature of sites

DT_Array1DInt 

1D integer array

DT_Array2D 

2D floating point array

DT_Array2DInt 

2D integer array

DT_Raster1D 

Raster data in floating point number, same as DT_Array1D.

DT_Raster1DInt 

Raster data in integer, same as DT_Array1DInt.

DT_Raster2D 

2D raster in floating point number, e.g., multi-layers of soil properties

DT_Raster2DInt 

2D raster in integer, e.g., multiple flow direction

DT_Scenario 

Scenario used by BMPs.

DT_Reach 

Reach parameters.

DT_Subbasin 

Subbasin instances.

◆ TimeStepType

Time step types.

Enumerator
TIMESTEP_HILLSLOPE 

Hillslope scale.

TIMESTEP_CHANNEL 

Channel scale.

TIMESTEP_SIMULATION 

Whole simulation scale.

◆ transferTypes

Float values be transferred across subbasins for MPI version.

Enumerator
TF_None 

Default, which means no need to be transferred.

TF_SingleValue 

A single value in the data (e.g., DT_Array1D)

TF_OneArray1D 

A piece of 1D array in the data (e.g., DT_Array2D)