Skip to content

Commit fd91c78

Browse files
James CraigJames Craig
authored andcommitted
v499 - added warnings for specified parameters not used in model configuration
1 parent 4169f4a commit fd91c78

File tree

5 files changed

+80
-6
lines changed

5 files changed

+80
-6
lines changed

src/ParseFEWSRunInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
292292
string att_name_s=to_string(att_name);
293293

294294
// NamedConstant(s) ----------------------------------------------------
295-
296295
if (att_name_s.substr(0, 14) == "NamedConstant_")
297296
{
298297
string name=att_name_s.substr(14,att_name_s.length());
@@ -302,7 +301,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
302301
retval = nc_get_att_text(ncid,varid_props,att_name,my_value); HandleNetCDFErrors(retval);// read attribute text
303302
my_value[att_len] = '\0';// add string determining character
304303
att_value=s_to_d(my_value);
305-
delete my_value;
304+
delete [] my_value;
306305

307306
//cout<<"RUN INFO NAMED CONSTANT = "<<name<<" value = "<<att_value <<endl;
308307
if (Options.management_optimization){

src/ParseInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ bool ParseMainInputFile (CModel *&pModel,
22172217
else if (!strcmp(s[1],"INF_PRMS" )){itype=INF_PRMS; }
22182218
else if (!strcmp(s[1],"INF_HBV" )){itype=INF_HBV; }
22192219
else if (!strcmp(s[1],"INF_UBC" )){itype=INF_UBC; }
2220-
else if (!strcmp(s[1],"INF_PARTITION" )){itype=INF_RATIONAL; }
2220+
else if (!strcmp(s[1],"INF_PARTITION" )){itype=INF_RATIONAL; } //backward compatible
22212221
else if (!strcmp(s[1],"INF_GR4J" )){itype=INF_GR4J; }
22222222
else if (!strcmp(s[1],"INF_SCS" )){itype=INF_SCS; }
22232223
else if (!strcmp(s[1],"INF_SCS_NOABSTRACTION")){itype=INF_SCS_NOABSTRACTION; }

src/ParsePropertyFile.cpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,17 @@ bool ParseClassPropertiesFile(CModel *&pModel,
531531
CSoilClass::SetSoilProperty(*parsed_soils[indices[i]],aParamStrings[j+1],properties[i][j]);
532532
}
533533
}
534+
bool found_in_master;
535+
for (int j=0;j<nParamStrings-1;j++){
536+
found_in_master=false;
537+
for (int k = 0; k < nPmaster; k++) {
538+
if ((aPCmaster[k] == CLASS_SOIL) && (aPmaster[k]==aParamStrings[j+1])){found_in_master=true; break;}
539+
}
540+
if (!found_in_master) {
541+
string warn="ParseClassPropertiesFile: Soil parameter "+aParamStrings[j+1]+" specified in .rvp file, but is not used within this model formulation.";
542+
WriteAdvisory(warn.c_str(), Options.noisy);
543+
}
544+
}
534545
break;
535546
}
536547
//===========================================================================================
@@ -617,6 +628,17 @@ bool ParseClassPropertiesFile(CModel *&pModel,
617628
properties[i][j]);
618629
}
619630
}
631+
bool found_in_master;
632+
for (int j=0;j<nParamStrings-1;j++){
633+
found_in_master=false;
634+
for (int k = 0; k < nPmaster; k++) {
635+
if ((aPCmaster[k] == CLASS_LANDUSE) && (aPmaster[k]==aParamStrings[j+1])){found_in_master=true; break;}
636+
}
637+
if (!found_in_master) {
638+
string warn="ParseClassPropertiesFile: Land Use parameter "+aParamStrings[j+1]+" specified in .rvp file, but is not used within this model formulation.";
639+
WriteAdvisory(warn.c_str(), Options.noisy);
640+
}
641+
}
620642
break;
621643
}
622644
case(102): //----------------------------------------------
@@ -752,6 +774,17 @@ bool ParseClassPropertiesFile(CModel *&pModel,
752774
properties [i][j]);
753775
}
754776
}
777+
bool found_in_master;
778+
for (int j=0;j<nParamStrings-1;j++){
779+
found_in_master=false;
780+
for (int k = 0; k < nPmaster; k++) {
781+
if ((aPCmaster[k] == CLASS_VEGETATION) && (aPmaster[k]==aParamStrings[j+1])){found_in_master=true; break;}
782+
}
783+
if (!found_in_master) {
784+
string warn="ParseClassPropertiesFile: Vegetation parameter "+aParamStrings[j+1]+" specified in .rvp file, but is not used within this model formulation.";
785+
WriteAdvisory(warn.c_str(), Options.noisy);
786+
}
787+
}
755788
break;
756789
}
757790
case(207): //----------------------------------------------
@@ -1476,13 +1509,13 @@ bool ParseClassPropertiesFile(CModel *&pModel,
14761509

14771510
if (!Options.silent){cout<<"Autocalculating Model Parameters..."<<endl;}
14781511

1479-
pModel->GetGlobalParams()->AutoCalculateGlobalParams (parsed_globals,global_template);
1512+
pModel->GetGlobalParams()->AutoCalculateGlobalParams(parsed_globals,global_template);
14801513

14811514
for (int c=1;c<num_parsed_veg;c++){
1482-
pVegClasses [c-1]->AutoCalculateVegetationProps (parsed_veg[c],parsed_veg[0]);
1515+
pVegClasses [c-1]->AutoCalculateVegetationProps (parsed_veg[c],parsed_veg[0]);
14831516
}
14841517
for (int c=1;c<num_parsed_soils;c++){
1485-
pSoilClasses[c]->AutoCalculateSoilProps (*parsed_soils[c],*parsed_soils[0],pModel->GetTransportModel()->GetNumConstituents());
1518+
pSoilClasses[c]->AutoCalculateSoilProps (*parsed_soils[c],*parsed_soils[0],pModel->GetTransportModel()->GetNumConstituents());
14861519
}
14871520
for (int c=1;c<num_parsed_lult;c++) {
14881521
pModel->GetLanduseClass(c-1)->AutoCalculateLandUseProps(parsed_surf[c], parsed_surf[0]);

src/SubBasin.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,47 @@ double CSubBasin::ScaleAllFlows(const double &scale, const bool overriding, cons
14171417
_rivulet_storage*=scale; va+=_rivulet_storage*sf;
14181418
return va;
14191419
}
1420+
//////////////////////////////////////////////////////////////////
1421+
/// \brief adjust all internal flows by adjustment factor (for assimilation/nudging)
1422+
/// \remark Messes with mass balance something fierce!
1423+
/// \param &scale [in] Flow adjustment, m3/s
1424+
/// \param &scale_last [in] True if Qlast should be scaled (overriding); false for no-data scaling
1425+
/// \param &tstep [in] time step [d]
1426+
/// \return volume added to system [m3]
1427+
//
1428+
double CSubBasin::AdjustAllFlows(const double &adjust, const bool overriding, const double &tstep, const double &t)
1429+
{
1430+
double va=0.0; //volume added [m3]
1431+
1432+
if(!overriding)
1433+
{
1434+
for(int n=0;n<_nQinHist; n++) {
1435+
_aQinHist[n]+=adjust; upperswap(_aQinHist[n],0.0);
1436+
va+=adjust*tstep*SEC_PER_DAY;
1437+
}
1438+
for(int i=0;i<_nSegments;i++) {
1439+
_aQout[i]+=adjust; upperswap(_aQout[i],0.0);
1440+
va+=adjust*tstep*SEC_PER_DAY;
1441+
}
1442+
}
1443+
1444+
if((overriding) && (_pReservoir==NULL)) {
1445+
for (int i=0;i<_nSegments;i++)
1446+
{
1447+
_aQout[i]+=adjust; upperswap(_aQout[i],0.0);
1448+
va+=adjust*tstep*SEC_PER_DAY;
1449+
}
1450+
}
1451+
1452+
if(_pReservoir!=NULL) {
1453+
//va+=_pReservoir->ScaleFlow(scale,overriding,tstep,t);
1454+
}
1455+
1456+
//Estivate volume added through scaling
1457+
//_channel_storage+=adjust*tstep*SEC_PER_DAY; //va+=_channel_storage*sf;
1458+
//_rivulet_storage+=adjust*tstep*SEC_PER_DAY; //va+=_rivulet_storage*sf;
1459+
return va;
1460+
}
14201461
/////////////////////////////////////////////////////////////////
14211462
/// \brief Sets (i.e., overrides initial) Downstream ID (use sparingly!)
14221463
/// \param down_SBID [in] ID of downstream subbasin

src/SubBasin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class CSubBasin
301301
void Disable ();
302302
void Enable ();
303303
double ScaleAllFlows (const double &scale_factor, const bool scale_last, const double &tstep, const double &t);
304+
double AdjustAllFlows (const double &adjustment, const bool scale_last, const double &tstep, const double &t);
304305
void SetUnusableFlowPercentage(const double &val);
305306
void IncludeInAssimilation ();
306307

0 commit comments

Comments
 (0)