/* *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* */ /* ** Copyright UCAR */ /* ** University Corporation for Atmospheric Research (UCAR) */ /* ** National Center for Atmospheric Research (NCAR) */ /* ** Boulder, Colorado, USA */ /* ** BSD licence applies - redistribution and use in source and binary */ /* ** forms, with or without modification, are permitted provided that */ /* ** the following conditions are met: */ /* ** 1) If the software is modified to produce derivative works, */ /* ** such modified software should be clearly marked, so as not */ /* ** to confuse it with the version available from UCAR. */ /* ** 2) Redistributions of source code must retain the above copyright */ /* ** notice, this list of conditions and the following disclaimer. */ /* ** 3) Redistributions in binary form must reproduce the above copyright */ /* ** notice, this list of conditions and the following disclaimer in the */ /* ** documentation and/or other materials provided with the distribution. */ /* ** 4) Neither the name of UCAR nor the names of its contributors, */ /* ** if any, may be used to endorse or promote products derived from */ /* ** this software without specific prior written permission. */ /* ** DISCLAIMER: THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESS */ /* ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ /* ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* */ //////////////////////////////////////////// // Params.cc // // TDRP C++ code file for class 'Params'. // // Code for program ThreshFromObarPbar // // This file has been automatically // generated by TDRP, do not modify. // ///////////////////////////////////////////// /** * * @file Params.cc * * @class Params * * This class is automatically generated by the Table * Driven Runtime Parameters (TDRP) system * * @note Source is automatically generated from * paramdef file at compile time, do not modify * since modifications will be overwritten. * * * @author Automatically generated * */ #include "Params.hh" #include //////////////////////////////////////////// // Default constructor // Params::Params() { // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "Params"; // initialize table _init(); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Copy constructor // Params::Params(const Params& source) { // sync the source object source.sync(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "Params"; // copy table tdrpCopyTable((TDRPtable *) source._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Destructor // Params::~Params() { // free up freeAll(); } //////////////////////////////////////////// // Assignment // void Params::operator=(const Params& other) { // sync the other object other.sync(); // free up any existing memory freeAll(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // copy table tdrpCopyTable((TDRPtable *) other._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = other._exitDeferred; } //////////////////////////////////////////// // loadFromArgs() // // Loads up TDRP using the command line args. // // Check usage() for command line actions associated with // this function. // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // char **params_path_p: // If this is non-NULL, it is set to point to the path // of the params file used. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int Params::loadFromArgs(int argc, char **argv, char **override_list, char **params_path_p, bool defer_exit) { int exit_deferred; if (_tdrpLoadFromArgs(argc, argv, _table, &_start_, override_list, params_path_p, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // loadApplyArgs() // // Loads up TDRP using the params path passed in, and applies // the command line args for printing and checking. // // Check usage() for command line actions associated with // this function. // // const char *param_file_path: the parameter file to be read in // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int Params::loadApplyArgs(const char *params_path, int argc, char **argv, char **override_list, bool defer_exit) { int exit_deferred; if (tdrpLoadApplyArgs(params_path, argc, argv, _table, &_start_, override_list, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // isArgValid() // // Check if a command line arg is a valid TDRP arg. // bool Params::isArgValid(const char *arg) { return (tdrpIsArgValid(arg)); } //////////////////////////////////////////// // isArgValid() // // Check if a command line arg is a valid TDRP arg. // return number of args consumed. // int Params::isArgValidN(const char *arg) { return (tdrpIsArgValidN(arg)); } //////////////////////////////////////////// // load() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to load // up more than one class for a single application. It is a // lower-level routine than loadFromArgs, and hence more // flexible, but the programmer must do more work. // // const char *param_file_path: the parameter file to be read in. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int Params::load(const char *param_file_path, char **override_list, int expand_env, int debug) { if (tdrpLoad(param_file_path, _table, &_start_, override_list, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadFromBuf() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to // load up more than one module for a single application, // using buffers which have been read from a specified source. // // const char *param_source_str: a string which describes the // source of the parameter information. It is used for // error reporting only. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // const char *inbuf: the input buffer // // int inlen: length of the input buffer // // int start_line_num: the line number in the source which // corresponds to the start of the buffer. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int Params::loadFromBuf(const char *param_source_str, char **override_list, const char *inbuf, int inlen, int start_line_num, int expand_env, int debug) { if (tdrpLoadFromBuf(param_source_str, _table, &_start_, override_list, inbuf, inlen, start_line_num, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadDefaults() // // Loads up default params for a given class. // // See load() for more detailed info. // // Returns 0 on success, -1 on failure. // int Params::loadDefaults(int expand_env) { if (tdrpLoad(NULL, _table, &_start_, NULL, expand_env, FALSE)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // sync() // // Syncs the user struct data back into the parameter table, // in preparation for printing. // // This function alters the table in a consistent manner. // Therefore it can be regarded as const. // void Params::sync(void) const { tdrpUser2Table(_table, (char *) &_start_); } //////////////////////////////////////////// // print() // // Print params file // // The modes supported are: // // PRINT_SHORT: main comments only, no help or descriptions // structs and arrays on a single line // PRINT_NORM: short + descriptions and help // PRINT_LONG: norm + arrays and structs expanded // PRINT_VERBOSE: long + private params included // void Params::print(FILE *out, tdrp_print_mode_t mode) { tdrpPrint(out, _table, _className, mode); } //////////////////////////////////////////// // checkAllSet() // // Return TRUE if all set, FALSE if not. // // If out is non-NULL, prints out warning messages for those // parameters which are not set. // int Params::checkAllSet(FILE *out) { return (tdrpCheckAllSet(out, _table, &_start_)); } ////////////////////////////////////////////////////////////// // checkIsSet() // // Return TRUE if parameter is set, FALSE if not. // // int Params::checkIsSet(const char *paramName) { return (tdrpCheckIsSet(paramName, _table, &_start_)); } //////////////////////////////////////////// // freeAll() // // Frees up all TDRP dynamic memory. // void Params::freeAll(void) { tdrpFreeAll(_table, &_start_); } bool Params::extractStringValue(const string &parmName, string &value) const { int n = sizeof(_table)/sizeof(_table[0]); for (int i=0; i &values) const { values.clear(); int n = sizeof(_table)/sizeof(_table[0]); for (int i=0; iptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 0"); tt->comment_hdr = tdrpStrDup("ThreshFromObarPbar"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'Comment 1' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 1"); tt->comment_hdr = tdrpStrDup("ThreshFromObarPbar"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'pbarSpdb' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("pbarSpdb"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("The triggering SPDB, which is the pbar data"); tt->val_offset = (char *) &pbarSpdb - &_start_; tt->single_val.s = tdrpStrDup("spdbp:://localhost::EpochOps/spdb/CMCE/thresh"); tt++; // Parameter 'obarSpdb1' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("obarSpdb1"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Spdb with obar data,, input to this app, for precip"); tt->val_offset = (char *) &obarSpdb1 - &_start_; tt->single_val.s = tdrpStrDup("spdbp:://localhost::EpochOps/CMCE/obar"); tt++; // Parameter 'thresholdsSpdb1' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("thresholdsSpdb1"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Spdb with thresholds for precip, output of this app"); tt->val_offset = (char *) &thresholdsSpdb1 - &_start_; tt->single_val.s = tdrpStrDup("spdbp:://localhost::EpochOps/CMCE/thresh"); tt++; // Parameter 'threshFieldColdstartThreshold1' // ctype is 'double' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = DOUBLE_TYPE; tt->param_name = tdrpStrDup("threshFieldColdstartThreshold1"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("precip coldstart threshold"); tt->val_offset = (char *) &threshFieldColdstartThreshold1 - &_start_; tt->single_val.d = 2; tt++; // Parameter 'obarThreshTargetBias1' // ctype is '_ThreshBias_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("obarThreshTargetBias1"); tt->descr = tdrpStrDup("Precip obar threshold and target bias values"); tt->help = tdrpStrDup("obarThresh = Expected Obar precip threshold, should match what is in the obar database\ntargetBias = value set so | bias - targetBias | is minimized"); tt->array_offset = (char *) &_obarThreshTargetBias1 - &_start_; tt->array_n_offset = (char *) &obarThreshTargetBias1_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(ThreshBias_t); tt->array_n = 1; tt->struct_def.name = tdrpStrDup("ThreshBias_t"); tt->struct_def.nfields = 2; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("double"); tt->struct_def.fields[0].fname = tdrpStrDup("obarThresh"); tt->struct_def.fields[0].ptype = DOUBLE_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_obarThreshTargetBias1->obarThresh - (char *) _obarThreshTargetBias1; tt->struct_def.fields[1].ftype = tdrpStrDup("double"); tt->struct_def.fields[1].fname = tdrpStrDup("targetBias"); tt->struct_def.fields[1].ptype = DOUBLE_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_obarThreshTargetBias1->targetBias - (char *) _obarThreshTargetBias1; tt->n_struct_vals = 2; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].d = 4; tt->struct_vals[1].d = 0; tt++; // Parameter 'obarSpdb2' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("obarSpdb2"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Spdb with obar data,, input to this app, for cloudtops"); tt->val_offset = (char *) &obarSpdb2 - &_start_; tt->single_val.s = tdrpStrDup("spdbp:://localhost::EpochOps/CMCE/obar"); tt++; // Parameter 'thresholdsSpdb2' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("thresholdsSpdb2"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Spdb with thresholds for cloudtops, output of this app"); tt->val_offset = (char *) &thresholdsSpdb2 - &_start_; tt->single_val.s = tdrpStrDup("spdbp:://localhost::EpochOps/CMCE/thresh"); tt++; // Parameter 'threshFieldColdstartThreshold2' // ctype is 'double' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = DOUBLE_TYPE; tt->param_name = tdrpStrDup("threshFieldColdstartThreshold2"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("cloudtop coldstart threshold"); tt->val_offset = (char *) &threshFieldColdstartThreshold2 - &_start_; tt->single_val.d = 2; tt++; // Parameter 'obarThreshTargetBias2' // ctype is '_ThreshBias_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("obarThreshTargetBias2"); tt->descr = tdrpStrDup("Cloudtop obar threshold and target bias values"); tt->help = tdrpStrDup("obarThresh = Expected Obar CTH threshold, should match what is in the obar database\ntargetBias = value set so | bias - targetBias | is minimized"); tt->array_offset = (char *) &_obarThreshTargetBias2 - &_start_; tt->array_n_offset = (char *) &obarThreshTargetBias2_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(ThreshBias_t); tt->array_n = 1; tt->struct_def.name = tdrpStrDup("ThreshBias_t"); tt->struct_def.nfields = 2; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("double"); tt->struct_def.fields[0].fname = tdrpStrDup("obarThresh"); tt->struct_def.fields[0].ptype = DOUBLE_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_obarThreshTargetBias2->obarThresh - (char *) _obarThreshTargetBias2; tt->struct_def.fields[1].ftype = tdrpStrDup("double"); tt->struct_def.fields[1].fname = tdrpStrDup("targetBias"); tt->struct_def.fields[1].ptype = DOUBLE_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_obarThreshTargetBias2->targetBias - (char *) _obarThreshTargetBias2; tt->n_struct_vals = 2; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].d = 4; tt->struct_vals[1].d = 0; tt++; // Parameter 'tilingParamFile' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("tilingParamFile"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Parameter file with tiling information"); tt->val_offset = (char *) &tilingParamFile - &_start_; tt->single_val.s = tdrpStrDup("Tiling_05deg_02overlap_0.5deg.params"); tt++; // Parameter 'backfillDaysBack' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("backfillDaysBack"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Days to backfill at startup. Look back this many days from now (realtime) or t0 (archive) for gen times that have ensemble model data but have not produced output, and process the ones that have all inputs. Should be set bigger for cloudtops versions that trigger off of data that lags a few more days behind real time"); tt->val_offset = (char *) &backfillDaysBack - &_start_; tt->single_val.i = 5; tt++; // Parameter 'num_threads' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("num_threads"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Number of threads on ensemble member, 0 or 1 for no threading"); tt->val_offset = (char *) &num_threads - &_start_; tt->single_val.i = 0; tt++; // Parameter 'debug_state' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("debug_state"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Set true to see more debugging of internal state"); tt->val_offset = (char *) &debug_state - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'maxIncompleteDays' // ctype is 'double' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = DOUBLE_TYPE; tt->param_name = tdrpStrDup("maxIncompleteDays"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Maximum days without completing a gen time before outputting what can be output for that gen time, used in realtime"); tt->val_offset = (char *) &maxIncompleteDays - &_start_; tt->single_val.d = 2.5; tt++; // Parameter 'thresholdsMaxDaysBack' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("thresholdsMaxDaysBack"); tt->descr = tdrpStrDup(""); tt->help = tdrpStrDup("Maximum days back to look for thresholds SPDB data, used to set initial best threshold value"); tt->val_offset = (char *) &thresholdsMaxDaysBack - &_start_; tt->single_val.i = 30; tt++; // trailing entry has param_name set to NULL tt->param_name = NULL; return; }