void GenericSolver::solve( data_input * target) { std::cout<<printParams() << std::endl; std::ofstream fout("submission.csv"); fout << "UserId:ItemId,Prediction"<< std::endl; beforePredict(); vector<data_node> sortedNodes; for (int i = 0; i < target->length; i++) { sortedNodes.push_back(target->data[i]); } std::sort(sortedNodes.begin(), sortedNodes.end(), std::bind(&GenericSolver::sortBeforeSolveFunc, this, std::placeholders::_1, std::placeholders::_2)); for (unsigned int i = 0; i < sortedNodes.size(); i++) { data_node node = sortedNodes[i]; node.value = predict(node.userId, node.itemId); //std::cout << ++predicted << " User: "******", Item: " << node.itemId << ", prediction: " << node.value << std::endl; if(++predicted % 1000 == 0) std::cout << predicted << " predictions done" << std::endl; fout << node.userId <<":"<< node.itemId<< ","<< node.value << std::endl; } std::cout << predicted << " predictions done" << std::endl; fout.close(); afterPredict(); }
Param_t * stringbreaker(char*str, Param_t *param) { char *t; //create new temporary character array char *stringcount[MAXARGS]; //create array of character pointers int i=0; t=strtok(str," \n\t"); //tokenize first argument based on where " ", "\t", and "\n" are located printf("Temp String: %s\n",t); //print the temporary string //tokenize the rest of the string while(t != NULL) { printf("\nThe token is: %s", t); stringcount[i] = t; //add temp char to string array param->argumentCount++; //increment argc t = strtok(NULL," \n\t"); //tokenize i++; } parseParams(stringcount,param); // printParams(param); //print params, returns nothing //theshell(param) //fork to new process id, show child process and wait param = clearParam(param); return param; }
void DataFlow::print(ostream& out) { for (set<string>::const_iterator libIt=m_libs.begin();libIt!=m_libs.end();libIt++) out << "useComponentLibrary " << *libIt << endl; map<Node*,std::string> mapping; for (NameMapCIt it=m_names.begin();it!=m_names.end();it++) { mapping[it->second] = it->first; } for (size_t i=0;i<m_nodes.size(); i++) { Node* node=m_nodes[i]; map<Node*,std::string>::iterator nameIt = mapping.find(node); if (nameIt==mapping.end()) { ostringstream oss; oss << "n" << i; mapping[node] = oss.str(); } out << mapping[node] << " := " << node->v.componentId; printParams(out,node->v.params); out << endl; } for (size_t i=0;i<m_links.size();i++) { Link* l=m_links[i]; out << mapping[l->source]; if (l->sourceOutputPort.size()>0) out << ":" << l->sourceOutputPort; out << " > " << mapping[l->target]; if (l->targetInputPort.size()>0) out << ":" << l->targetInputPort; out << endl; } }
void HTNMethod::SHOPPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) { s << "( :METHOD (" << name << " "; //params TokenStruct< std::string > astruct; std::stringstream ss; printParams( 0, s, astruct, d ); s<<")\n"; //preconds if ( pre ) pre->PDDLPrint( s, 1, astruct, d ); else s << "\t()"; s << "\n"; //tasks if ( tasks.size() > 0 ){ s << "\t( "; for(unsigned i=0;i<tasks.size();++i) tasks[i]->SHOPPrint( s, 1, astruct, d ); s << " )"; } else s << "\t()"; s << "\n"; s << ")\n"; }
void SaveableFlannBasedMatcher::readIndex(const char* name) { indexParams->setAlgorithm(cvflann::FLANN_INDEX_SAVED); indexParams->setString("filename", name); // construct flannIndex now, so printParams works train(); printParams(); }
void Application::__run_session(FCGX_Request *request, Router *router, bool debug) { Request req(request); Response res(request->out, router); if (debug) printParams(request->envp); router->dispatch(req, res); }
void Action::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) { s << "( :ACTION " << name << "\n"; s << " :PARAMETERS "; TokenStruct< std::string > astruct; printParams( 0, s, astruct, d ); s << " :PRECONDITION\n"; if ( pre ) pre->PDDLPrint( s, 1, astruct, d ); else s << "\t()"; s << "\n"; s << " :EFFECT\n"; if ( eff ) eff->PDDLPrint( s, 1, astruct, d ); else s << "\t()"; s << "\n"; s << ")\n"; }
void Forall::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) { tabindent( s, indent ); s << "( FORALL\n"; TokenStruct< std::string > fstruct( ts ); tabindent( s, indent + 1 ); printParams( 0, s, fstruct, d ); if ( cond ) cond->PDDLPrint( s, indent + 1, fstruct, d ); else { tabindent( s, indent + 1 ); s << "()"; } if( cond1 ) { s << "\n"; cond1->PDDLPrint( s, indent + 1, fstruct, d ); } s << "\n"; tabindent( s, indent ); s << ")"; }
bool AlchemyCreateProfile::processApplication() { // process parameters passed in by user if (!loadParams()) { getContext() << Context::PRIORITY_error << "Application failed while loading parameters" << Context::endl; return false; } printParams(); if (!readData(m_trainFile, m_trainData, "training data")) { getContext() << Context::PRIORITY_error << "Application failed while reading training data" << Context::endl; return false; } else if (!m_trainData.size()) { getContext() << Context::PRIORITY_error << "No training data was read; aborting execution" << Context::endl; return false; } if (!createProfile()) { getContext() << Context::PRIORITY_error << "Application failed while creating prediction profile" << Context::endl; return false; } return true; }
void SaveableFlannBasedMatcher::writeIndex(const char* name) { printParams(); flannIndex->save(name); }
struct landuse_default *construct_landuse_defaults( int num_default_files, char **default_files, struct command_line_object *command_line) { /*--------------------------------------------------------------*/ /* Local function definition. */ /*--------------------------------------------------------------*/ void *alloc( size_t, char *, char *); /*--------------------------------------------------------------*/ /* Local variable definition. */ /*--------------------------------------------------------------*/ int i; int strbufLen = 256; int filenameLen = 1024; double landuse, ftmp; FILE *default_file; char strbuf[strbufLen]; char outFilename[filenameLen]; char record[MAXSTR]; char *newrecord; struct landuse_default *default_object_list; param *paramPtr = NULL; int paramCnt = 0; /*--------------------------------------------------------------*/ /* Allocate an array of default objects. */ /*--------------------------------------------------------------*/ default_object_list = (struct landuse_default *) alloc(num_default_files * sizeof(struct landuse_default),"default_object_list", "construct_landuse_defaults"); /*--------------------------------------------------------------*/ /* Loop through the default files list. */ /*--------------------------------------------------------------*/ for (i=0 ; i<num_default_files; i++){ /*--------------------------------------------------------------*/ /* Try to open the ith default file. */ /*--------------------------------------------------------------*/ printf("Reading %s\n", default_files[i]); paramCnt = 0; if (paramPtr != NULL) free(paramPtr); paramPtr = readParamFile(¶mCnt, default_files[i]); /*--------------------------------------------------------------*/ /* read the ith default file into the ith object. */ /*--------------------------------------------------------------*/ default_object_list[i].ID = getIntParam(¶mCnt, ¶mPtr, "landuse_default_ID", "%d", 1, 0); default_object_list[i].irrigation = getDoubleParam(¶mCnt, ¶mPtr, "irrigation", "%lf", 0.0, 1) / 365; default_object_list[i].fertilizer_NO3 = getDoubleParam(¶mCnt, ¶mPtr, "fertilizer_NO3", "%lf", 0.0, 1) / 365; default_object_list[i].fertilizer_NH4 = getDoubleParam(¶mCnt, ¶mPtr, "fertilizer_NH4", "%lf", 0.0, 1) / 365; default_object_list[i].septic_NO3_load = getDoubleParam(¶mCnt, ¶mPtr, "septic_NO3_load", "%lf", 0.0, 1) / 365; default_object_list[i].septic_water_load = getDoubleParam(¶mCnt, ¶mPtr, "septic_water_load", "%lf", 0.0, 1) / 365; default_object_list[i].detention_store_size = getDoubleParam(¶mCnt, ¶mPtr, "detention_store_size", "%lf", 0.0, 1) / 365; default_object_list[i].PH = getDoubleParam(¶mCnt, ¶mPtr, "PH", "%lf", 7.0, 1); default_object_list[i].percent_impervious = getDoubleParam(¶mCnt, ¶mPtr, "landuse.percent_impervious", "%lf", 0.0, 1); default_object_list[i].grazing_Closs = getDoubleParam(¶mCnt, ¶mPtr, "grazing_Closs", "%lf", 0.0, 1) / 365; /*--------------------------------------------------------------*/ /* Close the ith default file. */ /*--------------------------------------------------------------*/ memset(strbuf, '\0', strbufLen); strcpy(strbuf, default_files[i]); char *s = strbuf; char *y = NULL; char *token = NULL; char filename[256]; // Store filename portion of path in 't' while ((token = strtok(s, "/")) != NULL) { // Save the latest component of the filename strcpy(filename, token); s = NULL; } // Remove the file extension, if one exists memset(strbuf, '\0', strbufLen); strcpy(strbuf, filename); free(s); s = strbuf; token = strtok(s, "."); if (token != NULL) { strcpy(filename, token); } memset(outFilename, '\0', filenameLen); // Concatenate the output prefix with the filename of the input .def file // and "_landuse.params" if (command_line[0].output_prefix != NULL) { strcat(outFilename, command_line[0].output_prefix); if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "_landuse.params"); } else { if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "landuse.params"); } printParams(paramCnt, paramPtr, outFilename); } /*end for*/ return(default_object_list); } /*end construct_landuse_defaults*/
struct stratum_default *construct_stratum_defaults( int num_default_files, char **default_files, struct command_line_object *command_line) { /*--------------------------------------------------------------*/ /* Local function definition. */ /*--------------------------------------------------------------*/ void *alloc( size_t, char *, char *); int parse_veg_type( char *); int parse_phenology_type( char *); int parse_dyn_flag( char *); int parse_alloc_flag( char *); /*--------------------------------------------------------------*/ /* Local variable definition. */ /*--------------------------------------------------------------*/ int i, itmp; int strbufLen = 256; int filenameLen = 1024; int paramCnt = 0; char record[MAXSTR]; char *newrecord; char stmp[MAXSTR]; char strbuf[strbufLen]; char outFilename[filenameLen]; double fcel, ftmp, lig_cel_ratio; //FILE *default_file; param *paramPtr = NULL; struct stratum_default *default_object_list; struct epconst_struct *epc; /*--------------------------------------------------------------*/ /* Allocate an array of default objects. */ /*--------------------------------------------------------------*/ default_object_list = (struct stratum_default *) alloc(num_default_files * sizeof(struct stratum_default),"default_object_list", "construct_stratum_defaults" ); /*--------------------------------------------------------------*/ /* Loop through the default files list. */ /*--------------------------------------------------------------*/ for (i=0 ; i<num_default_files; i++) { epc = &(default_object_list[i].epc); /*--------------------------------------------------------------*/ /* Try to open the ith default file. */ /*--------------------------------------------------------------*/ printf("Reading %s\n", default_files[i]); paramCnt = 0; if (paramPtr != NULL) free(paramPtr); paramPtr = readParamFile(¶mCnt, default_files[i]); /*--------------------------------------------------------------*/ /* read the ith default file into the ith object. */ /*--------------------------------------------------------------*/ default_object_list[i].ID = getIntParam(¶mCnt, ¶mPtr, "stratum_default_ID", "%d", 7, 1); // new param name default_object_list[i].epc.veg_type = parse_veg_type(getStrParam(¶mCnt, ¶mPtr, "epc.veg.type", "%s", "TREE", 1)); // param name is "epc.veg.type" in param file default_object_list[i].K_absorptance = getDoubleParam(¶mCnt, ¶mPtr, "K_absorptance", "%lf", 0.8, 1); // parameter misspelled in file as "K_apsorbtance" default_object_list[i].K_reflectance = getDoubleParam(¶mCnt, ¶mPtr, "K_reflectance", "%lf", 0.1, 1); default_object_list[i].K_transmittance = getDoubleParam(¶mCnt, ¶mPtr, "K_transmittance", "%lf", 0.1, 1); default_object_list[i].PAR_absorptance = getDoubleParam(¶mCnt, ¶mPtr, "PAR_absorptance", "%lf", 1.0, 1); // param misspelled in file "PAR_absrptance" default_object_list[i].PAR_reflectance = getDoubleParam(¶mCnt, ¶mPtr, "PAR_reflectance", "%lf", 0.0, 1); default_object_list[i].PAR_transmittance = getDoubleParam(¶mCnt, ¶mPtr, "PAR_transmittance", "%lf", 0.0, 1); default_object_list[i].epc.ext_coef = getDoubleParam(¶mCnt, ¶mPtr, "epc.ext_coef", "%lf", 0.5, 1); default_object_list[i].specific_rain_capacity = getDoubleParam(¶mCnt, ¶mPtr, "specific_rain_capacity", "%lf", 0.00024, 1); default_object_list[i].specific_snow_capacity = getDoubleParam(¶mCnt, ¶mPtr, "specific_snow_capacity", "%lf", 0.00024, 1); default_object_list[i].wind_attenuation_coeff = getDoubleParam(¶mCnt, ¶mPtr, "wind_attenuation_coef", "%lf", 0.4, 1); // param name is "wind_attenuation_coef" in param file default_object_list[i].ustar_overu = getDoubleParam(¶mCnt, ¶mPtr, "ustar_overu", "%lf", -999.9, 1); default_object_list[i].mrc.q10 = getDoubleParam(¶mCnt, ¶mPtr, "mrc.q10", "%lf", 1.5, 1); default_object_list[i].mrc.per_N = getDoubleParam(¶mCnt, ¶mPtr, "mrc.per_N", "%lf", 0.21, 1); default_object_list[i].epc.gr_perc = getDoubleParam(¶mCnt, ¶mPtr, "epc.gr_perc", "%lf", 0.2, 1); default_object_list[i].lai_stomatal_fraction = getDoubleParam(¶mCnt, ¶mPtr, "lai_stomatal_fraction", "%lf", 1.0, 1); default_object_list[i].epc.flnr = getDoubleParam(¶mCnt, ¶mPtr, "epc.flnr", "%lf", 0.1, 1); default_object_list[i].epc.ppfd_coef = getDoubleParam(¶mCnt, ¶mPtr, "epc.ppfd_coef", "%lf", 0.03, 1); default_object_list[i].epc.topt = getDoubleParam(¶mCnt, ¶mPtr, "epc.topt", "%lf", 15.0, 1); default_object_list[i].epc.tmax = getDoubleParam(¶mCnt, ¶mPtr, "epc.tmax", "%lf", 40.0, 1); default_object_list[i].epc.tcoef = getDoubleParam(¶mCnt, ¶mPtr, "epc.tcoef", "%lf", 0.2, 1); default_object_list[i].epc.psi_open = getDoubleParam(¶mCnt, ¶mPtr, "epc.psi_open", "%lf", -0.65, 1); default_object_list[i].epc.psi_close = getDoubleParam(¶mCnt, ¶mPtr, "epc.psi_close", "%lf", -2.5, 1); default_object_list[i].epc.vpd_open = getDoubleParam(¶mCnt, ¶mPtr, "epc.vpd_open", "%lf", 0.0, 1); default_object_list[i].epc.vpd_close = getDoubleParam(¶mCnt, ¶mPtr, "epc.vpd_close", "%lf", 3500.0, 1); default_object_list[i].epc.gl_smax = getDoubleParam(¶mCnt, ¶mPtr, "epc.gl_smax", "%lf", 0.006, 1); default_object_list[i].epc.gl_c = getDoubleParam(¶mCnt, ¶mPtr, "epc.gl_c", "%lf", 0.00006, 1); default_object_list[i].gsurf_slope = getDoubleParam(¶mCnt, ¶mPtr, "gsurf_slope", "%lf", 0.0, 1); default_object_list[i].gsurf_intercept = getDoubleParam(¶mCnt, ¶mPtr, "gsurf_intercept", "%lf", 1000000.0, 1); default_object_list[i].epc.phenology_flag = parse_dyn_flag(getStrParam(¶mCnt, ¶mPtr, "epc.phenology_flag", "%s", "static", 1)); default_object_list[i].epc.phenology_type = parse_phenology_type(getStrParam(¶mCnt, ¶mPtr, "epc.phenology.type", "%s", "EVERGREEN", 1)); default_object_list[i].epc.max_lai = getDoubleParam(¶mCnt, ¶mPtr, "epc.max_lai", "%lf", 12.0, 1); default_object_list[i].epc.proj_sla = getDoubleParam(¶mCnt, ¶mPtr, "epc.proj_sla", "%lf", 9.0, 1); default_object_list[i].epc.lai_ratio = getDoubleParam(¶mCnt, ¶mPtr, "epc.lai_ratio", "%lf", 2.6, 1); default_object_list[i].epc.proj_swa = getDoubleParam(¶mCnt, ¶mPtr, "epc.proj_swa", "%lf", 1.4, 1); default_object_list[i].epc.leaf_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaf_turnover", "%lf", 0.27, 1); default_object_list[i].epc.day_leafon = getIntParam(¶mCnt, ¶mPtr, "epc.day_leafon", "%d", 91, 1); default_object_list[i].epc.day_leafoff = getIntParam(¶mCnt, ¶mPtr, "epc.day_leafoff", "%d", 260, 1); default_object_list[i].epc.ndays_expand = getIntParam(¶mCnt, ¶mPtr, "epc.ndays_expand", "%d", 30, 1); default_object_list[i].epc.ndays_litfall = getIntParam(¶mCnt, ¶mPtr, "epc.ndays_litfall", "%d", 30, 1); default_object_list[i].epc.leaf_cn = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaf_cn", "%lf", 45.0, 1); default_object_list[i].epc.leaflitr_cn = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaflitr_cn", "%lf", 70.0, 1); default_object_list[i].min_heat_capacity = getDoubleParam(¶mCnt, ¶mPtr, "min_heat_capacity", "%lf", 0.0, 1); default_object_list[i].max_heat_capacity = getDoubleParam(¶mCnt, ¶mPtr, "max_heat_capacity", "%lf", 0.0, 1); default_object_list[i].epc.allocation_flag = parse_alloc_flag(getStrParam(¶mCnt, ¶mPtr, "epc.allocation_flag", "%s", "waring", 1)); /*--------------------------------------------------------------*/ /* NOTE: PLACE ANY GROW READING HERE. */ /*--------------------------------------------------------------*/ if ( (default_object_list[i].epc.leaflitr_cn < default_object_list[i].epc.leaf_cn) && (command_line[0].grow_flag > 0) ){ fprintf(stderr, "WARNING construct_stratum_defaults \n"); fprintf(stderr, " leaf litter C:N < leaf C:N \n"); } default_object_list[i].epc.storage_transfer_prop = getDoubleParam(¶mCnt, ¶mPtr, "epc.storage_transfer_prop", "%lf", 1.0, 1); default_object_list[i].epc.froot_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.froot_turnover", "%lf", 0.27, 1); if ((default_object_list[i].epc.veg_type == GRASS) || (default_object_list[i].epc.veg_type == C4GRASS)) { default_object_list[i].epc.deadleaf_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.deadleaf_turnover", "%lf", 1.0, 1); } else { default_object_list[i].epc.livewood_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.livewood_turnover", "%lf", 0.7, 1); } default_object_list[i].epc.kfrag_base = getDoubleParam(¶mCnt, ¶mPtr, "epc.kfrag_base", "%lf", 0.01, 1); default_object_list[i].epc.daily_mortality_turnover = getFloatParam(¶mCnt, ¶mPtr, "epc.daily_mortality_turnover", "%f", 0.005, 1) / 365; default_object_list[i].epc.froot_cn = getDoubleParam(¶mCnt, ¶mPtr, "epc.froot_cn", "%lf", 139.7, 1); default_object_list[i].epc.livewood_cn = getDoubleParam(¶mCnt, ¶mPtr, "epc.livewood_cn", "%lf", 200.0, 1); default_object_list[i].epc.leaflitr_flab = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaflitr_flab", "%lf", 0.31, 1); // Skipping epc.leaflitr_fcel (pcs 20130117 : comment or var name wrong in orig code: defs/veg_westhemlock.def has 'leaflitr_fcel') fcel = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaflitr_fcel", "%lf", 0.45, 1); // param name in file is "leaflitr_fcel" default_object_list[i].epc.leaflitr_flig = getDoubleParam(¶mCnt, ¶mPtr, "epc.leaflitr_flig", "%lf", 0.24, 1); if ( (float)(epc->leaflitr_flig + epc->leaflitr_flab + fcel) != 1.0 ) { fprintf(stderr,"FATAL ERROR construct_stratum_defaults \n"); fprintf(stderr," litter proportions of labile, cell. and lignin must sum to 1.0 \n"); fprintf(stderr," for default ID %d \n", default_object_list[i].ID); exit(EXIT_FAILURE); } lig_cel_ratio = epc->leaflitr_flig/fcel; /* calculate shielded and unshielded cellulose fraction */ if (lig_cel_ratio < 0.45){ epc->leaflitr_fscel = 0.0; epc->leaflitr_fucel = fcel; } else{ if ((lig_cel_ratio > 0.45) && (lig_cel_ratio < 0.7)){ epc->leaflitr_fscel= (lig_cel_ratio - 0.45)*3.2*fcel; epc->leaflitr_fucel = (1.0 - 3.2*(lig_cel_ratio - 0.45))*fcel; } else { epc->leaflitr_fscel = 0.8*fcel; epc->leaflitr_fucel = 0.2*fcel; } } default_object_list[i].epc.frootlitr_flab = getDoubleParam(¶mCnt, ¶mPtr, "epc.frootlitr_flab", "%lf", 0.23, 1); // Skipping the mortality parameter fcel = getDoubleParam(¶mCnt, ¶mPtr, "epc.frootlitr_fcel", "%lf", 0.41, 1); default_object_list[i].epc.frootlitr_flig = getDoubleParam(¶mCnt, ¶mPtr, "epc.frootlitr_flig", "%lf", 0.36, 1); if ( (float)(epc->frootlitr_flab + epc->frootlitr_flig + fcel) != 1.0 ){ fprintf(stderr,"\nFATAL ERROR construct_stratum_defaults"); fprintf(stderr,"\n froot litter proportions of labile, cell. and lignin must sum to 1.0\n"); exit(EXIT_FAILURE); } lig_cel_ratio = epc->frootlitr_flig/fcel; /* calculate shielded and unshielded cellulose fraction */ if (lig_cel_ratio < 0.45) { epc->frootlitr_fscel = 0.0; epc->frootlitr_fucel = fcel; } else{ if ((lig_cel_ratio > 0.45) && (lig_cel_ratio < 0.7)){ epc->frootlitr_fscel= (lig_cel_ratio - 0.45)*3.2*fcel; epc->frootlitr_fucel = (1.0 - 3.2*(lig_cel_ratio - 0.45))*fcel; } else{ epc->frootlitr_fscel = 0.8*fcel; epc->frootlitr_fucel = 0.2*fcel; } } fcel = getDoubleParam(¶mCnt, ¶mPtr, "epc.deadwood_fcel", "%lf", 0.52, 1); default_object_list[i].epc.deadwood_flig = getDoubleParam(¶mCnt, ¶mPtr, "epc.deadwood_flig", "%lf", 0.48, 1); if (epc->veg_type == TREE) { if ( (float)(epc->deadwood_flig + fcel) != 1.0 ){ fprintf(stderr,"FATAL ERROR construct_stratum_defaults \n"); fprintf(stderr," dead wood proportions of labile, cell. and lignin must sum to 1.0 \n"); exit(EXIT_FAILURE); } lig_cel_ratio = epc->deadwood_flig/fcel; /* calculate shielded and unshielded cellulose fraction */ if (lig_cel_ratio < 0.45) { epc->deadwood_fscel = 0.0; epc->deadwood_fucel = fcel; } else{ if ((lig_cel_ratio > 0.45) && (lig_cel_ratio < 0.7)){ epc->deadwood_fscel= (lig_cel_ratio - 0.45)*3.2*fcel; epc->deadwood_fucel = (1.0 - 3.2*(lig_cel_ratio - 0.45))*fcel; } else{ epc->deadwood_fscel = 0.8*fcel; epc->deadwood_fucel = 0.2*fcel; } } /* epc->deadwood_cn = ((epc->deadwood_fucel + epc->deadwood_fscel + epc->deadwood_flig) * CEL_CN * LIG_CN ) / (LIG_CN * (epc->deadwood_fucel + epc->deadwood_fscel) + CEL_CN * epc->deadwood_flig); if (epc->deadwood_cn < epc->livewood_cn){ fprintf(stderr,"\nFATAL ERROR: construct_canopy_stratum"); fprintf(stderr,"\ndeadwood C:N must be > livewood C:N"); exit(EXIT_FAILURE); } */ epc->deadwood_cn = (epc->deadwood_fucel + epc->deadwood_fscel) * CEL_CN + (epc->deadwood_flig) * LIG_CN; } /* end if tree */ else { epc->deadwood_flig = 0.0; epc->deadwood_fucel = 0.0; epc->deadwood_fscel = 0.0; epc->deadwood_cn = 0.0; } default_object_list[i].epc.alloc_frootc_leafc = getDoubleParam(¶mCnt, ¶mPtr, "epc.alloc_frootc_leafc", "%lf", 1.325, 1); default_object_list[i].epc.alloc_crootc_stemc = getDoubleParam(¶mCnt, ¶mPtr, "epc.alloc_crootc_stemc", "%lf", 0.3, 1); default_object_list[i].epc.alloc_stemc_leafc = getDoubleParam(¶mCnt, ¶mPtr, "epc.alloc_stemc_leafc", "%lf", 1.62, 1); default_object_list[i].epc.alloc_livewoodc_woodc = getDoubleParam(¶mCnt, ¶mPtr, "epc.alloc_livewoodc_woodc", "%lf", 0.073, 1); if (epc->veg_type != TREE){ epc->alloc_crootc_stemc = 0.0; epc->phloemcsa_per_alllai = 0.0; } default_object_list[i].epc.alloc_maxlgf = getDoubleParam(¶mCnt, ¶mPtr, "epc.maxlgf", "%lf", 0.05, 1); // param named 'epc.maxlgf' in parameter file default_object_list[i].epc.alloc_prop_day_growth = getDoubleParam(¶mCnt, ¶mPtr, "epc.alloc_prop_day_growth", "%lf", 0.5, 1); default_object_list[i].epc.dynamic_alloc_prop_day_growth = getIntParam(¶mCnt, ¶mPtr, "epc.dyn_alloc_prop_day_growth", "%d", 0, 1); default_object_list[i].epc.daily_fire_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.daily_fire_turnover", "%lf", 0.0, 1); default_object_list[i].epc.height_to_stem_exp = getDoubleParam(¶mCnt, ¶mPtr, "epc.height_to_stem_exp", "%lf", 0.57, 1); default_object_list[i].epc.height_to_stem_coef = getDoubleParam(¶mCnt, ¶mPtr, "epc.height_to_stem_coef", "%lf", 11.39, 1); /*--------------------------------------------------------------*/ /* optionally read in parameters on re-sprouting */ /* and other newly implemented vegetation routines */ /*--------------------------------------------------------------*/ default_object_list[i].epc.min_leaf_carbon = getDoubleParam(¶mCnt, ¶mPtr, "epc.min_leaf_carbon", "%lf", 0.0005, 1); default_object_list[i].epc.max_years_resprout = getIntParam(¶mCnt, ¶mPtr, "epc.max_years_resprout", "%d", 100, 1); default_object_list[i].epc.resprout_leaf_carbon = getDoubleParam(¶mCnt, ¶mPtr, "epc.resprout_leaf_carbon", "%lf", 0.001, 1); default_object_list[i].epc.litter_gsurf_slope = getDoubleParam(¶mCnt, ¶mPtr, "epc.litter_gsurf_slope", "%lf", 0.0, 1); default_object_list[i].epc.litter_gsurf_intercept = getDoubleParam(¶mCnt, ¶mPtr, "epc.litter_gsurf_intercept", "%lf", 100000000, 1); default_object_list[i].epc.coef_CO2 = getDoubleParam(¶mCnt, ¶mPtr, "epc.coef_CO2", "%lf", 1.0, 1); default_object_list[i].epc.root_growth_direction = getDoubleParam(¶mCnt, ¶mPtr, "epc.root_growth_direction", "%lf", 0.8, 1); default_object_list[i].epc.root_distrib_parm = getDoubleParam(¶mCnt, ¶mPtr, "epc.root_distrib_parm", "%lf", 8.0, 1); default_object_list[i].epc.crown_ratio = getDoubleParam(¶mCnt, ¶mPtr, "epc.crown_ratio", "%lf", 0.6, 1); if (epc->veg_type != TREE) default_object_list[i].epc.crown_ratio = 1.0; /*--------------------------------------------------------------*/ /* default values for phenology (leaf onset/offset) model parameters */ /* are set based on Jolly et al., 2005, Global Change Biology */ /* who defined a globally uniform parameter set */ /*--------------------------------------------------------------*/ default_object_list[i].epc.gs_tmin = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_tmin", "%lf", -2.0, 1); default_object_list[i].epc.gs_tmax = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_tmax", "%lf", 5.0, 1); default_object_list[i].epc.gs_vpd_min = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_vpd_min", "%lf", 900, 1); default_object_list[i].epc.gs_vpd_max = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_vpd_max", "%lf", 4100, 1); default_object_list[i].epc.gs_dayl_min = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_dayl_min", "%lf", 36000, 1); default_object_list[i].epc.gs_dayl_max = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_dayl_max", "%lf", 39600, 1); default_object_list[i].epc.gs_psi_min = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_psi_min", "%lf", -15.0, 1); default_object_list[i].epc.gs_psi_max = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_psi_max", "%lf", -14.0, 1); default_object_list[i].epc.gs_ravg_days = getDoubleParam(¶mCnt, ¶mPtr, "epc.gs_ravg_days", "%lf", 6, 1); default_object_list[i].epc.max_storage_percent = getDoubleParam(¶mCnt, ¶mPtr, "epc.max_storage_percent", "%lf", 0.2, 1); default_object_list[i].epc.min_percent_leafg = getDoubleParam(¶mCnt, ¶mPtr, "epc.min_percent_leafg", "%lf", default_object_list[i].epc.leaf_turnover, 1); default_object_list[i].epc.dickenson_pa = getDoubleParam(¶mCnt, ¶mPtr, "epc.dickenson_pa", "%lf", 0.25, 1); default_object_list[i].epc.waring_pa = getDoubleParam(¶mCnt, ¶mPtr, "epc.waring_pa", "%lf", 0.8, 1); default_object_list[i].epc.waring_pb = getDoubleParam(¶mCnt, ¶mPtr, "epc.waring_pb", "%lf", 2.5, 1); default_object_list[i].epc.branch_turnover = getDoubleParam(¶mCnt, ¶mPtr, "epc.branch_turnover", "%lf", 0.0, 1) / 365.0; default_object_list[i].epc.Tacclim = getIntParam(¶mCnt, ¶mPtr, "epc.Tacclim", "%d", 0, 1); default_object_list[i].epc.Tacclim_intercpt = getDoubleParam(¶mCnt, ¶mPtr, "epc.Tacclim_intercpt", "%lf",3.22, 1); default_object_list[i].epc.Tacclim_slp = getDoubleParam(¶mCnt, ¶mPtr, "epc.Tacclim_slp", "%lf",0.046, 1); default_object_list[i].epc.Tacclim_days = getIntParam(¶mCnt, ¶mPtr, "epc.Tacclim_days", "%d", 30, 1); /*--------------------------------------------------------------*/ /* litter is assumed to have a mositure capacity of */ /* given by litter_moist_coef default assumes */ /* 200% moisture content by weight following */ /* Helvey, 1964 (deciduous forest in Coweeta) and */ /* Ogee and Brunet (2002) J of Hydrology, for a pine */ /* forest - */ /* so capacity in m is 2*litter carbon * 2(carbon to biomass */ /* / density of water */ /* similarly for litter depth but we assume an organic */ /* matter density */ /*--------------------------------------------------------------*/ default_object_list[i].epc.litter_moist_coef = getDoubleParam(¶mCnt, ¶mPtr, "epc.litter_moist_coef", "%lf", 2.0/1000.0, 1); default_object_list[i].epc.litter_density = getDoubleParam(¶mCnt, ¶mPtr, "epc.litter_density", "%lf", 100.0/2.0, 1); default_object_list[i].epc.gs_psi_range = default_object_list[i].epc.gs_psi_max-default_object_list[i].epc.gs_psi_min; default_object_list[i].epc.gs_dayl_range = default_object_list[i].epc.gs_dayl_max-default_object_list[i].epc.gs_dayl_min; default_object_list[i].epc.gs_vpd_range = default_object_list[i].epc.gs_vpd_max-default_object_list[i].epc.gs_vpd_min; default_object_list[i].epc.gs_trange = default_object_list[i].epc.gs_tmax-default_object_list[i].epc.gs_tmin; /*--------------------------------------------------------------*/ /* plant type defaults - are you an nfixer - are you edible */ /*--------------------------------------------------------------*/ default_object_list[i].epc.nfix = getIntParam(¶mCnt, ¶mPtr, "epc.nfix", "%d", 0, 1); default_object_list[i].epc.edible = getIntParam(¶mCnt, ¶mPtr, "epc.edible", "%d", 1, 1); default_object_list[i].epc.psi_curve = getIntParam(¶mCnt, ¶mPtr, "epc.psi_curve", "%d", 0, 1); default_object_list[i].epc.psi_threshold = getDoubleParam(¶mCnt, ¶mPtr, "epc.psi_threshold", "%lf", -1, 1); default_object_list[i].epc.psi_slp = getDoubleParam(¶mCnt, ¶mPtr, "epc.psi_slp", "%lf", 0.2, 1); default_object_list[i].epc.psi_intercpt = getDoubleParam(¶mCnt, ¶mPtr, "epc.psi_intercpt", "%lf", 1.0, 1); /*--------------------------------------------------------------*/ /* set sunlit sla multiplier this should be an input */ /*--------------------------------------------------------------*/ default_object_list[i].epc.shade_sla_mult = 1.0; /*--------------------------------------------------------------*/ /* Apply sensitivity analysis if appropriate */ /*--------------------------------------------------------------*/ if (command_line[0].vgsen_flag == 1) { default_object_list[i].epc.proj_sla *= command_line[0].veg_sen1; default_object_list[i].epc.shade_sla_mult *= command_line[0].veg_sen2; } /*--------------------------------------------------------------*/ /* Close the ith default file. */ /*--------------------------------------------------------------*/ memset(strbuf, '\0', strbufLen); strcpy(strbuf, default_files[i]); char *s = strbuf; char *y = NULL; char *token = NULL; char filename[256]; // Store filename portion of path in 't' while ((token = strtok(s, "/")) != NULL) { // Save the latest component of the filename strcpy(filename, token); s = NULL; } // Remove the file extension, if one exists memset(strbuf, '\0', strbufLen); strcpy(strbuf, filename); free(s); s = strbuf; token = strtok(s, "."); if (token != NULL) { strcpy(filename, token); } memset(outFilename, '\0', filenameLen); // Concatenate the output prefix with the filename of the input .def file // and "_stratum.params" if (command_line[0].output_prefix != NULL) { strcat(outFilename, command_line[0].output_prefix); if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "_stratum.params"); } else { if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "stratum.params"); } printParams(paramCnt, paramPtr, outFilename); } /*end for*/ if (paramPtr != NULL) free(paramPtr); return(default_object_list); } /*end construct_stratum_defaults*/
// update fi params with data from fi.input file void updateFIParams(){ #ifdef MPI_ENABLED MPI_Comm_rank(MPI_COMM_WORLD, ¤tRank); #endif char * line = NULL; char *name,*value; size_t len = 0; ssize_t read; FILE* fp; // initialize rand seed once srand(time(NULL)); // init execution key //execKey = time(NULL); updateTimeStamp(); fp = fopen(fiParams,"r"); if (fp == NULL){ printf("\nError:Coudn't find fi param file \"fi.in\"\n"); exit(-1); } // read fault injection params while ((read = getline(&line, &len, fp)) != -1) { name = getStrFieldByIndex(line,":\n",0); value = getStrFieldByIndex(line,":\n",1); processParams(name,value); } // select dyn instr only in fi mode if(pfs==0){ // update interval size if(tf>0){ intvsz = tf; } // update interval count if(dynFSCount>0 && intvsz>0){ if(dynFSCount%intvsz==0){ intvCount = dynFSCount/intvsz; } else { intvCount = floor(dynFSCount/intvsz)+1; } } // update target dynamic FS indices only once at runtime if(!fidatardflag){ updateFSIdx(); } if(dynFSIdx==NULL){ printf("\nError:memory allocation failed for dynFSIdx!!\n"); exit(-1); } } // write FI headers const char* instrfield = "Instr_Name"; const char* originalVal = "Original_Value"; const char* corruptedVal = "Corrupted_Value"; const char* bitPosVal = "Bit_Position"; if(!file_exists(fiStat) && pfs==0){ writeFIData(instrfield,(void*)originalVal,(void*)corruptedVal,(void*)bitPosVal,StringTy,"w"); } #ifndef MPI_ENABLED printParams(); #endif checkParams(); fidatardflag=1; fclose(fp); return; }
struct fire_default *construct_fire_defaults( int num_default_files, char **default_files, struct command_line_object *command_line) { /*--------------------------------------------------------------*/ /* Local function definition. */ /*--------------------------------------------------------------*/ void *alloc( size_t, char *, char *); /*--------------------------------------------------------------*/ /* Local variable definition. */ /*--------------------------------------------------------------*/ int i; int strbufLen = 256; int filenameLen = 1024; int paramCnt = 0; char strbuf[strbufLen]; char outFilename[filenameLen]; double ftmp, soil; FILE *default_file; char *newrecord; char record[MAXSTR]; struct fire_default *default_object_list; param *paramPtr = NULL; /*--------------------------------------------------------------*/ /* Allocate an array of default objects. */ /*-------------------------------------------------------------*/ default_object_list = (struct fire_default *) alloc(num_default_files * sizeof(struct fire_default),"default_object_list", "construct_fire_defaults"); /*--------------------------------------------------------------*/ /* Loop through the default files list. */ /*--------------------------------------------------------------*/ for (i=0 ; i<num_default_files; i++){ /*--------------------------------------------------------------*/ /* Try to open the ith default file. */ /*--------------------------------------------------------------*/ printf("\n Reading %s\n", default_files[i]); paramCnt = 0; if (paramPtr != NULL) free(paramPtr); paramPtr = readParamFile(¶mCnt, default_files[i]); /*--------------------------------------------------------------*/ /* read the ith default file into the ith object. */ /*--------------------------------------------------------------*/ default_object_list[i].ID = getIntParam(¶mCnt, ¶mPtr, "fire_default_ID", "%d", 0, 0); // new param name /*--------------------------------------------------------------*/ /* assign parameters in default and read the */ /* optional parameter specification */ /*--------------------------------------------------------------*/ default_object_list[i].veg_fuel_weighting = getDoubleParam(¶mCnt, ¶mPtr, "veg_fuel_weighting", "%lf", 0.2, 1); /*--------------------------------------------------------------*/ /* Close the ith default file. */ /*--------------------------------------------------------------*/ memset(strbuf, '\0', strbufLen); strcpy(strbuf, default_files[i]); char *s = strbuf; char *y = NULL; char *token = NULL; char filename[256]; // Store filename portion of path in 't' while ((token = strtok(s, "/")) != NULL) { // Save the latest component of the filename strcpy(filename, token); s = NULL; } // Remove the file extension, if one exists memset(strbuf, '\0', strbufLen); strcpy(strbuf, filename); free(s); s = strbuf; token = strtok(s, "."); if (token != NULL) { strcpy(filename, token); } memset(outFilename, '\0', filenameLen); // Concatenate the output prefix with the filename of the input .def file // and "_stratum.params" if (command_line[0].output_prefix != NULL) { strcat(outFilename, command_line[0].output_prefix); if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "_fire.params"); } else { if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "fire.params"); } printParams(paramCnt, paramPtr, outFilename); } /*end for*/ return(default_object_list); } /*end construct_fire_defaults*/
struct soil_default *construct_soil_defaults( int num_default_files, char **default_files, struct command_line_object *command_line) { /*--------------------------------------------------------------*/ /* Local function definition. */ /*--------------------------------------------------------------*/ void *alloc( size_t, char *, char *); double compute_delta_water(int, double, double, double, double, double); /*--------------------------------------------------------------*/ /* Local variable definition. */ /*--------------------------------------------------------------*/ int strbufLen = 256; int filenameLen = 1024; int i; double ftmp,soil; FILE *default_file; char strbuf[strbufLen]; char outFilename[filenameLen]; char *newrecord; char record[MAXSTR]; struct soil_default *default_object_list; void *alloc( size_t, char *, char *); param *paramPtr = NULL; int paramCnt = 0; /*--------------------------------------------------------------*/ /* Allocate an array of default objects. */ /*--------------------------------------------------------------*/ default_object_list = (struct soil_default *) alloc(num_default_files * sizeof(struct soil_default),"default_object_list", "construct_soil_defaults"); /*--------------------------------------------------------------*/ /* Loop through the default files list. */ /*--------------------------------------------------------------*/ for (i=0 ; i<num_default_files; i++){ /*--------------------------------------------------------------*/ /* Try to open the ith default file. */ /*--------------------------------------------------------------*/ //if ( (default_file = fopen( default_files[i], "r")) == NULL ){ // fprintf(stderr,"FATAL ERROR:in construct_soil_defaults", // "unable to open defaults file %d.\n",i); // exit(EXIT_FAILURE); //} /*end if*/ printf("Reading %s\n", default_files[i]); paramCnt = 0; if (paramPtr != NULL) free(paramPtr); paramPtr = readParamFile(¶mCnt, default_files[i]); /*--------------------------------------------------------------*/ /* read the ith default file into the ith object. */ /*--------------------------------------------------------------*/ default_object_list[i].ID = getIntParam(¶mCnt, ¶mPtr, "patch_default_ID", "%d", 3, 1); default_object_list[i].theta_psi_curve = getIntParam(¶mCnt, ¶mPtr, "theta_psi_curve", "%d", 1.0, 1); default_object_list[i].Ksat_0 = getDoubleParam(¶mCnt, ¶mPtr, "Ksat_0", "%lf", 3.0, 1); default_object_list[i].m = getDoubleParam(¶mCnt, ¶mPtr, "m", "%lf", 0.12, 1); default_object_list[i].porosity_0 = getDoubleParam(¶mCnt, ¶mPtr, "porosity_0", "%lf", 0.435, 1); default_object_list[i].porosity_decay = getDoubleParam(¶mCnt, ¶mPtr, "porosity_decay", "%lf", 4000.0, 1); default_object_list[i].p3 = getDoubleParam(¶mCnt, ¶mPtr, "P3", "%lf", 0.0, 1); // param name upper case in param file default_object_list[i].pore_size_index = getDoubleParam(¶mCnt, ¶mPtr, "pore_size_index", "%lf", 0.204, 1); default_object_list[i].psi_air_entry = getDoubleParam(¶mCnt, ¶mPtr, "psi_air_entry", "%lf", 0.218, 1); default_object_list[i].psi_max = getDoubleParam(¶mCnt, ¶mPtr, "psi_max", "%lf", 0.01, 1); default_object_list[i].soil_depth = getDoubleParam(¶mCnt, ¶mPtr, "soil_depth", "%lf", 200.0, 1); default_object_list[i].m_z = getDoubleParam(¶mCnt, ¶mPtr, "m_z", "%lf", 0.4, 1); default_object_list[i].detention_store_size = getDoubleParam(¶mCnt, ¶mPtr, "detention_store_size", "%lf", 0.0, 1); default_object_list[i].deltaz = getDoubleParam(¶mCnt, ¶mPtr, "deltaZ", "%lf", 1.0, 1); // param name contains uppercase "Z" in param file default_object_list[i].active_zone_z = getDoubleParam(¶mCnt, ¶mPtr, "active_zone_z", "%lf", 10.0, 1); if (abs(default_object_list[i].active_zone_z - default_object_list[i].soil_depth) > 0.5) { printf("\nNote that soil depth used for biogeochem cycling (active zone z)"); printf("\nis more than 0.5 meter different from hydrologic soil depth"); printf("\nfor soil default file: %s\n", default_files[i] ); } default_object_list[i].maximum_snow_energy_deficit = getDoubleParam(¶mCnt, ¶mPtr, "maximum_snow_energy_deficit", "%lf", -10.0, 1); default_object_list[i].snow_water_capacity = getDoubleParam(¶mCnt, ¶mPtr, "snow_water_capacity", "%lf", 0.0, 1); default_object_list[i].snow_light_ext_coef = getDoubleParam(¶mCnt, ¶mPtr, "snow_light_ext_coef", "%lf", 10000.0, 1); default_object_list[i].snow_melt_Tcoef = getDoubleParam(¶mCnt, ¶mPtr, "snow_melt_Tcoef", "%lf", 0.05, 1); /* default_object_list[i].snow_melt_Tcoef *= command_line[0].tmp_value; */ default_object_list[i].max_heat_capacity = getDoubleParam(¶mCnt, ¶mPtr, "max_heat_capacity", "%lf", 0.0, 1); default_object_list[i].min_heat_capacity = getDoubleParam(¶mCnt, ¶mPtr, "min_heat_capacity", "%lf", 0.0, 1); default_object_list[i].albedo = getDoubleParam(¶mCnt, ¶mPtr, "albedo", "%lf", 0.28, 1); default_object_list[i].NO3_adsorption_rate = getDoubleParam(¶mCnt, ¶mPtr, "NO3_adsorption_rate", "%lf", 0.0, 1); default_object_list[i].N_decay_rate = getDoubleParam(¶mCnt, ¶mPtr, "N_decay", "%lf", 0.12, 1); /* if (command_line[0].tmp_value > ZERO) default_object_list[i].N_decay_rate *= command_line[0].tmp_value; */ default_object_list[i].soil_type.sand = getDoubleParam(¶mCnt, ¶mPtr, "sand", "%lf", 0.7, 1); default_object_list[i].soil_type.silt = getDoubleParam(¶mCnt, ¶mPtr, "silt", "%lf", 0.2, 1); default_object_list[i].soil_type.clay = getDoubleParam(¶mCnt, ¶mPtr, "clay", "%lf", 0.1, 1); soil = default_object_list[i].soil_type.sand + default_object_list[i].soil_type.silt + default_object_list[i].soil_type.clay; if (abs(soil - 1.0) > ZERO) { fprintf(stderr, "FATAL ERROR:in construct_soil_defaults\n proportion sand, silt, clay = %f\n\n", soil); printf("\n %d - %f %f %f %f \n", default_object_list[i].ID, default_object_list[i].N_decay_rate, default_object_list[i].soil_type.sand, default_object_list[i].soil_type.silt, default_object_list[i].soil_type.clay); } /*end if*/ if (command_line[0].gw_flag > 0) { default_object_list[i].sat_to_gw_coeff = getDoubleParam(¶mCnt, ¶mPtr, "sat_to_gw_coeff", "%lf", 1.0, 1); default_object_list[i].sat_to_gw_coeff *= command_line[0].sat_to_gw_coeff_mult; } /*--------------------------------------------------------------*/ /* vertical soil m and K are initized using soil default */ /* but sensitivity analysis -s is not applied to them */ /* use -sv to change these parameters */ /*--------------------------------------------------------------*/ default_object_list[i].m_v = default_object_list[i].m; default_object_list[i].mz_v = default_object_list[i].m_z; default_object_list[i].Ksat_0_v = default_object_list[i].Ksat_0; /*--------------------------------------------------------------*/ /* sensitivity adjustment of vertical drainage soil paramters */ /*--------------------------------------------------------------*/ if (command_line[0].vsen_flag > 0) { default_object_list[i].m_v *= command_line[0].vsen[M]; default_object_list[i].mz_v *= command_line[0].vsen[M]; default_object_list[i].Ksat_0_v *= command_line[0].vsen[K]; } /*--------------------------------------------------------------*/ /* sensitivity adjustment of soil drainage paramters */ /*--------------------------------------------------------------*/ if (command_line[0].sen_flag > 0) { default_object_list[i].m *= command_line[0].sen[M]; default_object_list[i].m_z *= command_line[0].sen[M]; default_object_list[i].Ksat_0 *= command_line[0].sen[K]; default_object_list[i].soil_depth *= command_line[0].sen[SOIL_DEPTH]; } /*--------------------------------------------------------------*/ /* calculate water_equivalent depth of soil */ /*--------------------------------------------------------------*/ default_object_list[i].soil_water_cap = compute_delta_water( 0, default_object_list[i].porosity_0, default_object_list[i].porosity_decay, default_object_list[i].soil_depth, default_object_list[i].soil_depth, 0.0); /*--------------------------------------------------------------*/ /* initialization of optional default file parms */ /*--------------------------------------------------------------*/ default_object_list[i].theta_mean_std_p1 = getDoubleParam(¶mCnt, ¶mPtr, "theta_mean_std_p1", "%lf", 0.0, 1); default_object_list[i].theta_mean_std_p2 = getDoubleParam(¶mCnt, ¶mPtr, "theta_mean_std_p2", "%lf", 0.0, 1); default_object_list[i].gl_c = getDoubleParam(¶mCnt, ¶mPtr, "gl_c", "%lf", 0.0062, 1); default_object_list[i].gsurf_slope = getDoubleParam(¶mCnt, ¶mPtr, "gsurf_slope ", "%lf", 0.01, 1); default_object_list[i].gsurf_intercept = getDoubleParam(¶mCnt, ¶mPtr, "gsurf_intercept", "%lf", 0.001, 1); default_object_list[i].p4 = getDoubleParam(¶mCnt, ¶mPtr, "p4", "%lf", -1.5, 1); default_object_list[i].DOM_decay_rate = getDoubleParam(¶mCnt, ¶mPtr, "DOM_decay_rate", "%lf", 0.05, 1); default_object_list[i].NH4_adsorption_rate = getDoubleParam(¶mCnt, ¶mPtr, "NH4_adsorption_rate", "%lf", 0.000005, 1); default_object_list[i].DON_production_rate = getDoubleParam(¶mCnt, ¶mPtr, "DON_production_rate", "%lf", 0.03, 1); default_object_list[i].DOC_adsorption_rate = getDoubleParam(¶mCnt, ¶mPtr, "DOC_adsorption_rate", "%lf", 0.000023, 1); default_object_list[i].DON_adsorption_rate = getDoubleParam(¶mCnt, ¶mPtr, "DON_adsorption_rate", "%lf", 0.000001, 1); default_object_list[i].interval_size = getDoubleParam(¶mCnt, ¶mPtr, "interval_size", "%lf", INTERVAL_SIZE, 1); /*--------------------------------------------------------------*/ /* sensitivity adjustment of vertical drainage soil paramters */ /* an scale Pore size index and psi air entry or other parameters */ /* that control moisture retention (if curve 3 is used) */ /*--------------------------------------------------------------*/ if (command_line[0].vsen_alt_flag > 0) { if (default_object_list[i].theta_psi_curve != 3) { default_object_list[i].psi_air_entry *= command_line[0].vsen_alt[PA]; default_object_list[i].pore_size_index *= command_line[0].vsen_alt[PO]; if (default_object_list[0].pore_size_index >= 1.0) { printf("\n Sensitivity analysis giving Pore Size Index > 1.0, not allowed, setting to 1.0\n"); default_object_list[i].pore_size_index = 0.999; } } else { default_object_list[i].p3 *= command_line[0].vsen_alt[PA]; default_object_list[i].p4 *= command_line[0].vsen_alt[PO]; } } /*--------------------------------------------------------------*/ /* Close the ith default file. */ /*--------------------------------------------------------------*/ memset(strbuf, '\0', strbufLen); strcpy(strbuf, default_files[i]); char *s = strbuf; char *y = NULL; char *token = NULL; char filename[256]; // Store filename portion of path in 't' while ((token = strtok(s, "/")) != NULL) { // Save the latest component of the filename strcpy(filename, token); s = NULL; } // Remove the file extension, if one exists memset(strbuf, '\0', strbufLen); strcpy(strbuf, filename); free(s); s = strbuf; token = strtok(s, "."); if (token != NULL) { strcpy(filename, token); } memset(outFilename, '\0', filenameLen); // Concatenate the output prefix with the filename of the input .def file // and "_soil.params" if (command_line[0].output_prefix != NULL) { strcat(outFilename, command_line[0].output_prefix); if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "_soil.params"); } else { if (filename != NULL) { strcat(outFilename, "_"); strcat(outFilename, filename); } strcat(outFilename, "soil.params"); } printParams(paramCnt, paramPtr, outFilename); } /*end for*/ return(default_object_list); } /*end construct_soil_defaults*/