WSL/SLF GitLab Repository

Commit bec56f5b authored by Mathias Bavay's avatar Mathias Bavay
Browse files

SNIO throws an exception if the user specified a METAFILE that does not...

SNIO throws an exception if the user specified a METAFILE that does not exists/is not valid. ARPSIO was wrongly reading grids (wrong layer for DEM and swapping x and y)
parent 7c5227cc
......@@ -132,9 +132,9 @@ void ARPSIO::readDEM(DEMObject& dem_out)
cfg.getValue("DEMFILE", "Input", _filename);
openGridFile(_filename);
if(is_true_arps) {
readGridLayer(std::string("zp coordinat"), 1 ,dem_out);
readGridLayer(std::string("zp coordinat"), 2 ,dem_out);
} else {
readGridLayer(std::string("zp_coordinat"), 1 ,dem_out);
readGridLayer(std::string("zp_coordinat"), 2 ,dem_out);
}
}
......@@ -347,8 +347,8 @@ void ARPSIO::readGridLayer(const std::string& parameter, const unsigned int& lay
}
//read the data we are interested in
for (unsigned int ix = 0; ix < dimx; ix++) {
for (unsigned int iy = 0; iy < dimy; iy++) {
for (unsigned int iy = 0; iy < dimy; iy++) {
for (unsigned int ix = 0; ix < dimx; ix++) {
double tmp;
if(fscanf(fin," %16lf%*[\n]",&tmp)==1) {
grid.grid2D(ix,iy) = tmp;
......
......@@ -170,14 +170,19 @@ void SNIO::readStationData(const Date&, std::vector<StationData>& vecStation)
bool SNIO::readStationMetaData(const std::string& metafile, const std::string& stationID, StationData& sd)
{
if (!IOUtils::validFileName(metafile))
if (!IOUtils::validFileName(metafile)) {
std::stringstream ss;
ss << "\"" << metafile << "\" is not a valid file name. Please check your METAFILE key!";
throw InvalidFileNameException(metafile, AT);
}
if (!IOUtils::fileExists(metafile)) {
cout << "[i] " << metafile << " not found! Read metadata from *.sno[old]" << endl;
return true;
std::stringstream ss;
ss << "File \"" << metafile << "\" does not exist. Please check your METAFILE key!";
throw FileNotFoundException(ss.str(), AT);
}
fin.clear();
fin.open (metafile.c_str(), std::ifstream::in);
if (fin.fail())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment