Skip to content

Commit 347c819

Browse files
James CraigJames Craig
authored andcommitted
v498 - removed need for FEWS managment info file
1 parent 12b5e4b commit 347c819

File tree

3 files changed

+1
-136
lines changed

3 files changed

+1
-136
lines changed

src/ParseFEWSRunInfo.cpp

Lines changed: 1 addition & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -304,31 +304,11 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
304304
att_value=s_to_d(my_value);
305305
delete my_value;
306306

307-
cout<<"RUN INFO NAMED CONSTANT = "<<name<<" value = "<<att_value <<endl;
307+
//cout<<"RUN INFO NAMED CONSTANT = "<<name<<" value = "<<att_value <<endl;
308308
if (Options.management_optimization){
309309
pModel->GetManagementOptimizer()->AddUserConstant(name,att_value);
310310
}
311311
}
312-
313-
// TargetStageSet_ ----------------------------------------------------
314-
315-
if (att_name_s.substr(0, 15) == "TargetStageSet_") {
316-
string SBID_s=att_name_s.substr(15,att_name_s.length());
317-
long long SBID=s_to_ll(SBID_s.c_str());
318-
319-
retval = nc_inq_attlen(ncid, varid_props, att_name, &att_len);
320-
char* boolean = new char[att_len + 1];
321-
retval = nc_get_att_text(ncid,varid_props,att_name,boolean); HandleNetCDFErrors(retval);// read attribute text
322-
boolean[att_len] = '\0';// add string determining character
323-
324-
if (!strcmp(boolean,"true")) {
325-
326-
// LOOK for User Time Series
327-
//pModel->GetManagementOptimizer()->LookForTargetStageInUserTS(SBID);
328-
// creates !hSBID = @ts("TargetStage_SBID",0) management goal , ensures units correction applied
329-
ExitGracefully("RUN INFO FILE - TARGET STAGE SET ",STUB);
330-
}
331-
}
332312
}
333313
}
334314
}
@@ -716,112 +696,6 @@ bool ParseNetCDFFlowStateFile(CModel*& pModel,const optStruct& Options)
716696
#endif
717697
}
718698

719-
//////////////////////////////////////////////////////////////////
720-
/// \brief Parses Deltares FEWS Management Time series file
721-
///
722-
/// \param *&pModel [out] Reference to model object
723-
/// \param &Options [out] Global model options information
724-
/// \return True if operation is successful
725-
//
726-
// The management update file includes:
727-
// 1) 'time' dimensions
728-
// 2) One or more vectors of size[1:time]
729-
730-
// .The state variable corresponding to the model start time will be used for initialization of flow/stage; all other values in the time vector are ignored
731-
// The naming convention of each vector is : {UserTimeSeries_NAME}
732-
//
733-
bool ParseNetCDFManagementFile(CModel*& pModel,const optStruct& Options)
734-
{
735-
if(Options.maninfo_filename=="") { return true; }
736-
if (!Options.management_optimization)
737-
{
738-
WriteWarning(":FEWSManagmentInfoFile command will be ignored; Management optimization is not enabled.",Options.noisy);
739-
return true;
740-
}
741-
742-
#ifdef _RVNETCDF_
743-
int ncid; // NetCDF file id
744-
int retval; // return value of NetCDF routines
745-
int ntime = 0; // size of time vector
746-
int time_dimid; // dimension id of time variable
747-
int start_time_index=0; // index of NetCDF time array which corresponds to Raven start time
748-
749-
// Open file
750-
//====================================================================
751-
string manfile=Options.maninfo_filename;
752-
753-
if(Options.noisy) { cout<<"Opening management info file "<<manfile<<endl; }
754-
retval = nc_open(manfile.c_str(),NC_NOWRITE,&ncid);
755-
if(retval != 0) {
756-
string warn = "ParseNetCDFManagementFile: :ParseNetCDFManagementFile command: Cannot find file "+ manfile;
757-
ExitGracefully(warn.c_str(),BAD_DATA_WARN);
758-
return false;
759-
}
760-
HandleNetCDFErrors(retval);
761-
762-
// Get information from time vector
763-
//====================================================================
764-
GetNetCDFTimeInfo(ncid,time_dimid,ntime,start_time_index,Options);
765-
766-
if ((start_time_index < 0) || (start_time_index >= ntime))
767-
{
768-
time_struct tt;
769-
JulianConvert(0, Options.julian_start_day, Options.julian_start_year, Options.calendar, tt);
770-
string warn = "ParseNetCDFFlowStateFile: Model start time ("+tt.date_string+" "+ DecDaysToHours(Options.julian_start_day)+") does not occur during time window provided in NetCDF state update file";
771-
ExitGracefully(warn.c_str(), BAD_DATA);
772-
return false;
773-
}
774-
775-
// Get Names of all UserTimeSeries_ vectors in model
776-
//====================================================================
777-
int N=0;
778-
string *userTSnames;
779-
int nvars;
780-
char varname[NC_MAX_NAME];
781-
retval=nc_inq_nvars(ncid,&nvars);
782-
783-
userTSnames=new string [nvars];
784-
785-
for (int i = 0; i < nvars; i++) {
786-
retval=nc_inq_varname(ncid,i,varname);
787-
788-
userTSnames[N]=varname;
789-
790-
if (userTSnames[N].substr(0,15)=="UserTimeSeries_")
791-
{
792-
userTSnames[N]=userTSnames[N].substr(15,userTSnames[N].length());
793-
N++;
794-
}
795-
}
796-
797-
//close file
798-
//====================================================================
799-
retval = nc_close(ncid); HandleNetCDFErrors(retval);
800-
801-
//Read data and store as time series
802-
//====================================================================
803-
804-
CTimeSeries *pTS;
805-
for (int i=0;i<N;i++)
806-
{
807-
pTS=CTimeSeries::ReadTimeSeriesFromNetCDF(Options, userTSnames[i],
808-
DOESNT_EXIST, "none",false, true, //assumes period ending format
809-
manfile, "UserTimeSeries_"+userTSnames[i],
810-
"None", "time", //this assumes "time" is FEWS standard for time dimension
811-
0, 0.0, 1.0, 0.0);
812-
if (Options.management_optimization){
813-
cout<<"ADDING USER TIME SERIES "<<endl;
814-
pModel->GetManagementOptimizer()->AddUserTimeSeries(pTS);
815-
}
816-
}
817-
delete [] userTSnames;
818-
819-
return true;
820-
#else
821-
ExitGracefully("ParseNetCDFFlowStateFile: Deltares FEWS State Update file can only be read using NetCDF version of Raven",BAD_DATA_WARN);
822-
return false;
823-
#endif
824-
}
825699

826700
//////////////////////////////////////////////////////////////////
827701
/// \brief Parses Deltares FEWS Parameter update file

src/ParseInput.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ bool ParseMainInputFile (CModel *&pModel,
335335
Options.stateinfo_filename ="";
336336
Options.paraminfo_filename ="";
337337
Options.flowinfo_filename ="";
338-
Options.maninfo_filename ="";
339338

340339
Options.NetCDF_chunk_mem =10; //MB
341340

@@ -484,7 +483,6 @@ bool ParseMainInputFile (CModel *&pModel,
484483
else if (!strcmp(s[0],":FEWSStateInfoFile" )){code=110;}
485484
else if (!strcmp(s[0],":FEWSParamInfoFile" )){code=111;}
486485
else if (!strcmp(s[0],":FEWSBasinStateInfoFile" )){code=112;}
487-
else if (!strcmp(s[0],":FEWSManagmentInfoFile" )){code=113;}
488486

489487
else if (!strcmp(s[0],":WriteGroundwaterHeads" )){code=510;}//GWMIGRATE -TO REMOVE
490488
else if (!strcmp(s[0],":WriteGroundwaterFlows" )){code=511;}//GWMIGRATE -TO REMOVE
@@ -1934,12 +1932,6 @@ bool ParseMainInputFile (CModel *&pModel,
19341932
Options.flowinfo_filename = CorrectForRelativePath(s[1], Options.rvi_filename);//with .nc extension!
19351933
break;
19361934
}
1937-
case(113): //
1938-
{/*:FEWSManagmentInfoFile [filename.nc]*/
1939-
if (Options.noisy) { cout << "FEWS management info file" << endl; }
1940-
Options.maninfo_filename = CorrectForRelativePath(s[1], Options.rvi_filename);//with .nc extension!
1941-
break;
1942-
}
19431935
case(160): //--------------------------------------------
19441936
{/*:rvh_Filename [filename.rvh]*/
19451937
if(Options.noisy) { cout <<"rvh filename: "<<s[1]<<endl; }

src/RavenInclude.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,6 @@ struct optStruct
10701070
string stateinfo_filename; ///< fully qualified filename of state_mods.nc file from FEWS
10711071
string flowinfo_filename; ///< fully qualified filename of flowstate_mods.nc file from FEWS
10721072
string paraminfo_filename; ///< fully qualified filename of param_mods.nc file from FEWS
1073-
string maninfo_filename; ///< fully qualified filename of managment.nc file from FEWS
10741073
string warm_ensemble_run; ///< run name prefix in warm ensemble solution files
10751074

10761075
string main_output_dir; ///< primary output directory (RavenErrors.txt, =output_dir for non-ensemble)

0 commit comments

Comments
 (0)