WSL/SLF GitLab Repository

Commit 2e1a1e2a authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixing some unsigned int / size_t conversion issues by using more widely...

Fixing some unsigned int / size_t conversion issues by using more widely size_t (as it seems to be recommended and done in the STL)
parent 7d127d2b
......@@ -22,10 +22,10 @@ using namespace std;
namespace mio {
#ifdef _POPC_
BufferedIOHandler::BufferedIOHandler(IOHandler& in_iohandler, const Config& in_cfg)
BufferedIOHandler::BufferedIOHandler(IOHandler& in_iohandler, const Config& in_cfg)
: iohandler(in_iohandler), cfg(in_cfg), mapBufferedGrids()
#else
BufferedIOHandler::BufferedIOHandler(IOHandler& in_iohandler, const Config& in_cfg)
BufferedIOHandler::BufferedIOHandler(IOHandler& in_iohandler, const Config& in_cfg)
: IOInterface(NULL), iohandler(in_iohandler), cfg(in_cfg), mapBufferedGrids()
#endif
{
......@@ -43,10 +43,10 @@ void BufferedIOHandler::read2DGrid(Grid2DObject& in_grid2Dobj, const std::string
{
std::map<std::string, Grid2DObject>::iterator it = mapBufferedGrids.find(in_filename);
if (it != mapBufferedGrids.end()) { //already in map
in_grid2Dobj = (*it).second;
in_grid2Dobj = (*it).second;
return;
}
Grid2DObject tmpgrid2D;
iohandler.read2DGrid(tmpgrid2D, in_filename);
mapBufferedGrids[in_filename] = tmpgrid2D;
......@@ -68,7 +68,7 @@ void BufferedIOHandler::readDEM(DEMObject& in_grid2Dobj)
}
return;
}
DEMObject tmpgrid2D;
//copy the updating policy of the destination
tmpgrid2D.setUpdatePpt((DEMObject::update_type)in_grid2Dobj.getUpdatePpt());
......@@ -81,10 +81,10 @@ void BufferedIOHandler::readLanduse(Grid2DObject& in_grid2Dobj)
{
std::map<std::string, Grid2DObject>::iterator it = mapBufferedGrids.find("/:LANDUSE");
if (it != mapBufferedGrids.end()) { //already in map
in_grid2Dobj = (*it).second;
in_grid2Dobj = (*it).second;
return;
}
Grid2DObject tmpgrid2D;
iohandler.readLanduse(tmpgrid2D);
mapBufferedGrids["/:LANDUSE"] = tmpgrid2D;
......@@ -95,10 +95,10 @@ void BufferedIOHandler::readAssimilationData(const Date& in_date, Grid2DObject&
{
std::map<std::string, Grid2DObject>::iterator it = mapBufferedGrids.find("/:ASSIMILATIONDATA" + in_date.toString(Date::FULL));
if (it != mapBufferedGrids.end()) { //already in map
in_grid2Dobj = (*it).second;
in_grid2Dobj = (*it).second;
return;
}
Grid2DObject tmpgrid2D;
iohandler.readAssimilationData(in_date, tmpgrid2D);
mapBufferedGrids["/:ASSIMILATIONDATA" + in_date.toString(Date::FULL)] = tmpgrid2D;
......@@ -113,7 +113,7 @@ void BufferedIOHandler::readStationData(const Date& date, STATION_TIMESERIE& vec
#ifdef _POPC_
void BufferedIOHandler::writeMeteoData(std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name)
#else
#else
void BufferedIOHandler::writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name)
#endif
......@@ -154,10 +154,10 @@ void BufferedIOHandler::setDfltBufferProperties()
double BufferedIOHandler::getAvgSamplingRate()
{
if (vec_buffer_meteo.size() > 0){
unsigned int sum = 0;
for (unsigned int ii=0; ii<vec_buffer_meteo.size(); ii++){
unsigned long sum = 0;
for (size_t ii=0; ii<vec_buffer_meteo.size(); ii++){
//count all data
sum += vec_buffer_meteo[ii].size();
sum += (unsigned long)vec_buffer_meteo[ii].size();
}
if (sum > 0){
double days = buffer_end.getJulianDate() - buffer_start.getJulianDate();
......@@ -176,7 +176,7 @@ const std::vector< METEO_TIMESERIE >& BufferedIOHandler::get_complete_buffer(Dat
return vec_buffer_meteo; //return reference
}
void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_end,
void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_end,
std::vector< METEO_TIMESERIE >& vecMeteo,
const unsigned int& /*stationindex*/)
{
......@@ -192,7 +192,7 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
if (vec_buffer_meteo.size() == 0) //init
bufferData(new_buffer_start, new_buffer_end, vec_buffer_meteo);
unsigned int buffer_size = vec_buffer_meteo.size();
size_t buffer_size = vec_buffer_meteo.size();
//1. Check whether data is in buffer already, and buffer it if not
if ((date_start < buffer_start) || (date_end > buffer_end)){
......@@ -209,10 +209,10 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
if (tmp_meteo_buffer.size() != buffer_size)
throw IOException("The number of stations changed over time, this is not handled yet!", AT);
//Loop through stations and append data
for (unsigned int ii=0; ii<buffer_size; ii++){
unsigned int station_size = vec_buffer_meteo[ii].size();
for (size_t ii=0; ii<buffer_size; ii++){
size_t station_size = vec_buffer_meteo[ii].size();
if ((station_size > 0) && (tmp_meteo_buffer[ii].size() > 0)){
//check if the last element equals the first one
......@@ -228,23 +228,23 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
}
//2. Copy appropriate data into vecMeteo
for (unsigned int ii=0; ii<buffer_size; ii++){
for (size_t ii=0; ii<buffer_size; ii++){
vecMeteo.push_back(vector<MeteoData>()); //insert one empty vector of MeteoData
if (vec_buffer_meteo[ii].size() == 0) continue; //no data in buffer for this station
unsigned int pos_start = IOUtils::seek(date_start, vec_buffer_meteo[ii], false);
size_t pos_start = IOUtils::seek(date_start, vec_buffer_meteo[ii], false);
if (pos_start == IOUtils::npos) pos_start = 0;
unsigned int pos_end = IOUtils::seek(date_end, vec_buffer_meteo[ii], false);//HACK:: edit IOUtils::seek to accept an offset
size_t pos_end = IOUtils::seek(date_end, vec_buffer_meteo[ii], false);//HACK:: edit IOUtils::seek to accept an offset
if (pos_end == IOUtils::npos) pos_end = vec_buffer_meteo[ii].size() - 1; //just copy until the end of the buffer
//cout << "Station " << ii << ": pos_start=" << pos_start << " pos_end=" << pos_end << endl;
//cout << "Station " << ii << ": pos_start=" << pos_start << " pos_end=" << pos_end << endl;
if (vec_buffer_meteo[ii][pos_end].date > date_end){
if (pos_end > pos_start) pos_end--;
} else {
pos_end++;
}
//cout << "Station " << ii << ": pos_start=" << pos_start << " pos_end=" << pos_end << endl;
//cout << "Station " << ii << ": pos_start=" << pos_start << " pos_end=" << pos_end << endl;
vecMeteo[ii].insert(vecMeteo[ii].begin(), vec_buffer_meteo[ii].begin()+pos_start, vec_buffer_meteo[ii].begin()+pos_end);
}
}
......@@ -258,7 +258,7 @@ void BufferedIOHandler::bufferData(const Date& date_start, const Date& date_end,
}
/**
* @brief Push a vector of time series of MeteoData objects into the local buffer.
* @brief Push a vector of time series of MeteoData objects into the local buffer.
* This overwrites the local buffer. This method is a way to bypass the internal reading
* of MeteoData from a certain source.
* @param date_start Representing the beginning of the data
......@@ -298,11 +298,11 @@ std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data)
os << "IOHandler &iohandler = " << hex << &data.iohandler << dec << "\n";
os << "Buffering " << data.chunks << " chunk(s) of " <<data.chunk_size.getJulianDate() << " days\n";
os << "Current buffer content (" << data.vec_buffer_meteo.size() << " stations, "
os << "Current buffer content (" << data.vec_buffer_meteo.size() << " stations, "
<< data.mapBufferedGrids.size() << " grids):\n";
for(unsigned int ii=0; ii<data.vec_buffer_meteo.size(); ii++) {
for(size_t ii=0; ii<data.vec_buffer_meteo.size(); ii++) {
if (data.vec_buffer_meteo[ii].size() > 0){
os << std::setw(10) << data.vec_buffer_meteo[ii][0].meta.stationID << " = "
<< data.vec_buffer_meteo[ii][0].date.toString(Date::ISO) << " - "
......
......@@ -167,8 +167,8 @@ std::string Config::getSourceName()
return sourcename;
}
unsigned int Config::findKeys(std::vector<std::string>& vecResult, std::string keystart,
std::string section) const
size_t Config::findKeys(std::vector<std::string>& vecResult, std::string keystart,
std::string section) const
{
vecResult.clear();
......
......@@ -259,8 +259,8 @@ class Config {
* unsigned int nrOfMatches = getKeys(myVec, "TA::", "Filters");
* @endcode
*/
unsigned int findKeys(std::vector<std::string>& vecResult,
std::string keystart, std::string section="GENERAL") const;
size_t findKeys(std::vector<std::string>& vecResult,
std::string keystart, std::string section="GENERAL") const;
static const std::string defaultSection;
......@@ -279,7 +279,7 @@ class ConfigProxy {
const Config& proxycfg;
const std::string& key;
const std::string& section;
const Config::Options& opt;
const Config::Options& opt;
ConfigProxy(const Config& i_cfg, const std::string& i_key,
const std::string& i_section, const Config::Options& i_opt)
......
......@@ -252,11 +252,11 @@ bool Grid2DObject::clusterization(const std::vector<double>& thresholds, const s
throw IOException("Can't start clusterization, cluster definition list doesnt fit id definition list", AT);
}
const unsigned int count = ncols*nrows;
const unsigned int nscl = thresholds.size();
const size_t nscl = thresholds.size();
for (unsigned int jj = 0; jj< count; jj++){
const double& val = grid2D(jj);
if (val!=IOUtils::nodata){
unsigned int i = 0;
size_t i = 0;
for ( ;i<nscl; i++)
if(thresholds[i] >= val)
break;
......
......@@ -172,8 +172,10 @@ void IOHandler::loadPlugin(const std::string& libname, const std::string& classn
}
}
} catch (std::exception& e) {
#ifndef _POPC_ //HACK: this line causes a segfault in the parallel version for unknown reasons, lwk
if (dynLibrary != NULL)
delete dynLibrary;
#endif
std::cerr << "\t" << e.what() << std::endl;
}
}
......
......@@ -36,7 +36,7 @@ void IOManager::setProcessingLevel(const unsigned int& i_level)
if (i_level >= IOManager::num_of_levels)
throw InvalidArgumentException("The processing level is invalid", AT);
if (((i_level & IOManager::raw) == IOManager::raw)
if (((i_level & IOManager::raw) == IOManager::raw)
&& ((i_level & IOManager::filtered) == IOManager::filtered))
throw InvalidArgumentException("The processing level is invalid (raw and filtered at the same time)", AT);
......@@ -52,7 +52,7 @@ double IOManager::getAvgSamplingRate()
}
}
void IOManager::push_meteo_data(const ProcessingLevel& level, const Date& date_start, const Date& date_end,
void IOManager::push_meteo_data(const ProcessingLevel& level, const Date& date_start, const Date& date_end,
const std::vector< METEO_TIMESERIE >& vecMeteo)
{
//perform check on date_start and date_end
......@@ -158,7 +158,7 @@ bool IOManager::read_filtered_cache(const Date& start_date, const Date& end_date
if (startpos != IOUtils::npos){
vec_meteo.push_back(vector<MeteoData>());
unsigned int index = vec_meteo.size()-1;
size_t index = vec_meteo.size()-1;
for (unsigned int jj=startpos; jj<filtered_cache[ii].size(); jj++){
const MeteoData& md = filtered_cache[ii][jj];
if (md.date <= end_date){
......@@ -172,7 +172,7 @@ bool IOManager::read_filtered_cache(const Date& start_date, const Date& end_date
return true;
}
return false;
}
......@@ -202,7 +202,7 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
if (index != IOUtils::npos)
vecMeteo.push_back(vec_cache[ii][index]); //Insert station into vecMeteo
}
return vecMeteo.size();
}
......@@ -254,7 +254,7 @@ void IOManager::writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo, c
void IOManager::interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters meteoparam,
Grid2DObject& result)
#else
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result)
#endif
{
......@@ -341,12 +341,12 @@ std::string IOManager::toString() const {
os << "Processing level = " << processing_level << "\n";
//display meteocache
unsigned int count=0;
unsigned int min_stations=std::numeric_limits<unsigned int>::max();
unsigned int max_stations=0;
size_t count=0;
size_t min_stations=std::numeric_limits<size_t>::max();
size_t max_stations=0;
std::map<Date, std::vector<MeteoData> >::const_iterator iter = resampled_cache.begin();
for (; iter != resampled_cache.end(); iter++) {
const unsigned int nb_stations = iter->second.size();
const size_t nb_stations = iter->second.size();
if(nb_stations>max_stations) max_stations=nb_stations;
if(nb_stations<min_stations) min_stations=nb_stations;
count++;
......@@ -380,7 +380,7 @@ std::string IOManager::toString() const {
//display filtered_cache
os << "Filteredcache content (" << filtered_cache.size() << " stations)\n";
for(unsigned int ii=0; ii<filtered_cache.size(); ii++) {
for(size_t ii=0; ii<filtered_cache.size(); ii++) {
if (filtered_cache[ii].size() > 0){
os << std::setw(10) << filtered_cache[ii][0].meta.stationID << " = "
<< filtered_cache[ii][0].date.toString(Date::ISO) << " - "
......
......@@ -121,7 +121,7 @@ void IOUtils::trim(std::string& str)
}
void IOUtils::toUpper(std::string& str){
for(unsigned int t=0; t<str.length(); t++) {
for(size_t t=0; t<str.length(); t++) {
str[t] = (char)toupper(str[t]);
}
}
......@@ -254,16 +254,16 @@ void IOUtils::readDirectory(const std::string& path, std::list<std::string>& dir
void IOUtils::readKeyValueHeader(std::map<std::string,std::string>& headermap,
std::istream& fin,
const unsigned int& linecount,
const size_t& linecount,
const std::string& delimiter)
{
int linenr = 0;
size_t linenr = 0;
std::string line="";
//make a test for end of line encoding:
char eol = IOUtils::getEoln(fin);
for (unsigned int ii=0; ii< linecount; ii++){
for (size_t ii=0; ii< linecount; ii++){
if (std::getline(fin, line, eol)) {
//cout << line <<endl;
linenr++;
......@@ -315,10 +315,10 @@ char IOUtils::getEoln(std::istream& fin)
return '\n';
}
void IOUtils::skipLines(std::istream& fin, const unsigned int& nbLines, const char& eoln)
void IOUtils::skipLines(std::istream& fin, const size_t& nbLines, const char& eoln)
{
std::string dummy;
for (unsigned int ii=0; ii<nbLines; ii++) {
for (size_t ii=0; ii<nbLines; ii++) {
if(!getline(fin, dummy, eoln)) {
throw InvalidFormatException("Premature EOF while skipping lines", AT);
}
......@@ -454,14 +454,14 @@ bool IOUtils::convertString(Date& t, const std::string& str, const double& time_
t.setDate( ((double)hour)/24. + ((double)minute)/24./60. , time_zone);
} else {
//try to read purely numerical date, potentially surrounded by other chars
const unsigned int in_len = str.length();
const size_t in_len = str.length();
const size_t beg = str.find_first_of(NUM);
if(beg==npos || beg==in_len) return false;
size_t end = str.find_first_not_of(NUM, beg+1);
if(end==npos) end = in_len;
const std::string datum = str.substr(beg, end-beg);
const unsigned int d_len = datum.length();
const size_t d_len = datum.length();
if(d_len<8 || d_len>14) return false;
if( convertString(year,datum.substr(0,4))==false ) return false;
if( convertString(month,datum.substr(4,2))==false ) return false;
......@@ -551,11 +551,11 @@ unsigned int IOUtils::seek(const Date& soughtdate, const std::vector<MeteoData>&
//if we reach this point: the date is spanned by the buffer and there are at least two elements
//HACK: would it be better to create a timeseries object and call vector's binary search on it?
if (exactmatch){
unsigned int first = 1, last = vecM.size()-1;
size_t first = 1, last = vecM.size()-1;
//perform binary search
while (first <= last) {
unsigned int mid = (first + last) / 2; // compute mid point
size_t mid = (first + last) / 2; // compute mid point
if (soughtdate > vecM[mid].date)
first = mid + 1; // repeat search in top half
else if (soughtdate < vecM[mid].date)
......@@ -564,11 +564,11 @@ unsigned int IOUtils::seek(const Date& soughtdate, const std::vector<MeteoData>&
return mid; // found it. return position
}
} else {
unsigned int first = 0, last = vecM.size()-1;
size_t first = 0, last = vecM.size()-1;
//perform binary search
while (first <= last) {
unsigned int mid = (first + last) / 2; // compute mid point
size_t mid = (first + last) / 2; // compute mid point
if (mid < (vecM.size()-1))
if ((soughtdate > vecM[mid].date) && (soughtdate < vecM[mid+1].date))
......
......@@ -63,7 +63,7 @@ namespace IOUtils {
const unsigned int unodata = (unsigned int)-1;
const int inodata = -999;
const short int snodata = -999;
const unsigned int npos = (unsigned int)-1; ///<npos is the out-of-range value
const size_t npos = (size_t)-1; ///<npos is the out-of-range value
const double grid_epsilon = 5.; ///<What is an acceptable small distance on a grid, in meters
const double lon_epsilon = grid_epsilon / Cst::earth_R0; ///<in degrees. Small angle for longitudes, so sin(x)=x
......@@ -87,7 +87,7 @@ namespace IOUtils {
double pow3(const double& val);
double pow4(const double& val);
unsigned int seek(const Date& soughtdate, const std::vector<MeteoData>& vecM, const bool& exactmatch=true);
size_t seek(const Date& soughtdate, const std::vector<MeteoData>& vecM, const bool& exactmatch=true);
/**
* @brief Copies a files from one location to another
......@@ -132,7 +132,7 @@ namespace IOUtils {
char getEoln(std::istream& fin);
void skipLines(std::istream& fin, const unsigned int& nbLines, const char& eoln='\n');
void skipLines(std::istream& fin, const size_t& nbLines, const char& eoln='\n');
/**
* @brief read a string line, parse it and save it into a map object, that is passed by reference
......@@ -153,7 +153,7 @@ namespace IOUtils {
size_t readLineToVec(const std::string& line_in, std::vector<std::string>& vecString, const char& delim);
void readKeyValueHeader(std::map<std::string, std::string>& headermap,
std::istream& bs,
const unsigned int& linecount=1,
const size_t& linecount=1,
const std::string& delimiter="=");
......@@ -258,8 +258,8 @@ namespace IOUtils {
//split value string
std::vector<std::string> vecUnconvertedValues;
unsigned int counter = readLineToVec(value, vecUnconvertedValues);
for (unsigned int ii=0; ii<counter; ii++){
size_t counter = readLineToVec(value, vecUnconvertedValues);
for (size_t ii=0; ii<counter; ii++){
T myvar;
if(!convertString<T>(myvar, vecUnconvertedValues.at(ii), std::dec)){
std::cerr << "[E] When reading \"" << key << "\" = \"" << myvar << "\"\n";
......@@ -291,7 +291,7 @@ namespace IOUtils {
* @param[out] coordoutparam The coordinate system parameters to be used for output data
*/
void getProjectionParameters(const Config& cfg, std::string& coordin, std::string& coordinparam,
std::string& coordout, std::string& coordoutparam);
std::string& coordout, std::string& coordoutparam);
/**
* @brief A function that parses a Config object for the time_zone keyword and returns the timezone
......
......@@ -27,10 +27,10 @@ const bool AlgorithmFactory::flag_init = AlgorithmFactory::initStaticData();
bool AlgorithmFactory::initStaticData()
{
/*
* Keywords for selecting the spatial interpolation algorithm among the
* available methods for single source and multiple sources interpolations.
* More details about some of these algorithms can be found in "A Meteorological
/*
* Keywords for selecting the spatial interpolation algorithm among the
* available methods for single source and multiple sources interpolations.
* More details about some of these algorithms can be found in "A Meteorological
* Distribution System for High-Resolution Terrestrial Modeling (MicroMet)", Liston and Elder, 2006.
* Please don't forget to document InterpolationAlgorithms.h for the available algorithms!
*/
......@@ -93,27 +93,27 @@ InterpolationAlgorithm* AlgorithmFactory::getAlgorithm(const std::string& i_algo
}
}
InterpolationAlgorithm::InterpolationAlgorithm(Meteo2DInterpolator& i_mi,
InterpolationAlgorithm::InterpolationAlgorithm(Meteo2DInterpolator& i_mi,
const Date& i_date,
const DEMObject& i_dem,
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: mi(i_mi), date(i_date), dem(i_dem), vecArgs(i_vecArgs), algo(i_algo), iomanager(iom)
: mi(i_mi), date(i_date), dem(i_dem), vecArgs(i_vecArgs), algo(i_algo), iomanager(iom)
{
nrOfMeasurments = 0;
param = MeteoData::firstparam; //this is a stupid default value, but since we never check it...
iomanager.getMeteoData(date, vecMeteo);
}
unsigned int InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
size_t InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
std::vector<double>& vecData) const
{
vector<StationData> vecMeta;
return getData(param, vecData, vecMeta);
}
unsigned int InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
size_t InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
std::vector<double>& vecData, std::vector<StationData>& vecMeta) const
{
if (vecData.size() > 0)
......@@ -122,7 +122,7 @@ unsigned int InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
if (vecMeta.size() > 0)
vecMeta.clear();
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
const double& val = vecMeteo[ii].param(param);
if (val != IOUtils::nodata){
vecData.push_back(val);
......@@ -133,10 +133,10 @@ unsigned int InterpolationAlgorithm::getData(const MeteoData::Parameters& param,
return vecData.size();
}
unsigned int InterpolationAlgorithm::getStationAltitudes(const std::vector<StationData>& vecMeta,
size_t InterpolationAlgorithm::getStationAltitudes(const std::vector<StationData>& vecMeta,
std::vector<double>& vecData) const
{
for (unsigned int ii=0; ii<vecMeta.size(); ii++){
for (size_t ii=0; ii<vecMeta.size(); ii++){
const double& val = vecMeta[ii].position.getAltitude();
if (val != IOUtils::nodata)
vecData.push_back(val);
......@@ -418,7 +418,7 @@ void RHAlgorithm::initialize(const MeteoData::Parameters& in_param) {
param = in_param;
nrOfMeasurments = 0;
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
if ((vecMeteo[ii].rh != IOUtils::nodata) && (vecMeteo[ii].ta != IOUtils::nodata)){
vecDataTA.push_back(vecMeteo[ii].ta);
vecDataRH.push_back(vecMeteo[ii].rh);
......@@ -436,14 +436,14 @@ double RHAlgorithm::getQualityRating()
if (vecDataTA.size() == 0)
return 0.0;
if( ( nrOfMeasurments<(unsigned int)(0.5*vecDataRH.size()) ) || ( nrOfMeasurments<2 ) )
if( ( nrOfMeasurments<(size_t)(0.5*vecDataRH.size()) ) || ( nrOfMeasurments<2 ) )
return 0.6;
return 0.9;
}
void RHAlgorithm::calculate(Grid2DObject& grid)
{
{
//This algorithm is only valid for RH
if (param != MeteoData::RH)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
......@@ -461,10 +461,10 @@ void RHAlgorithm::calculate(Grid2DObject& grid)
std::vector<double> vecTd(vecDataRH.size(), 0.0); // init to 0.0
//Compute dew point temperatures at stations
for (unsigned int ii=0; ii<vecDataRH.size(); ii++){
for (size_t ii=0; ii<vecDataRH.size(); ii++){
vecTd[ii] = Atmosphere::RhtoDewPoint(vecDataRH[ii], vecDataTA[ii], 1);
}
//Krieging on Td
std::vector<double> vecCoefficients;
vecCoefficients.resize(4, 0.0);
......@@ -485,7 +485,7 @@ void ILWRAlgorithm::initialize(const MeteoData::Parameters& in_param) {
param = in_param;
nrOfMeasurments = 0;
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
if ((vecMeteo[ii].ilwr != IOUtils::nodata) && (vecMeteo[ii].ta != IOUtils::nodata)){
vecDataEA.push_back( Atmosphere::blkBody_Emissivity( vecMeteo[ii].ilwr, vecMeteo[ii].ta) );
vecMeta.push_back(vecMeteo[ii].meta);
......@@ -507,7 +507,7 @@ double ILWRAlgorithm::getQualityRating()
}
void ILWRAlgorithm::calculate(Grid2DObject& grid)
{
{
//This algorithm is only valid for RH
if (param != MeteoData::ILWR)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
......@@ -570,7 +570,7 @@ void SimpleWindInterpolationAlgorithm::initialize(const MeteoData::Parameters& i
param = in_param;
nrOfMeasurments = 0;
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
if ((vecMeteo[ii].vw != IOUtils::nodata) && (vecMeteo[ii].dw != IOUtils::nodata)){
vecDataVW.push_back(vecMeteo[ii].vw);
vecDataDW.push_back(vecMeteo[ii].dw);
......@@ -596,14 +596,14 @@ double SimpleWindInterpolationAlgorithm::getQualityRating()
if (vecDataVW.size() == 0)
return 0.0;
if( ( nrOfMeasurments<(unsigned int)(0.5*vecDataVW.size()) ) || ( nrOfMeasurments<2 ) )
if( ( nrOfMeasurments<(size_t)(0.5*vecDataVW.size()) ) || ( nrOfMeasurments<2 ) )
return 0.6;
return 0.9;
}
void SimpleWindInterpolationAlgorithm::calculate(Grid2DObject& grid)
{
{
//This algorithm is only valid for VW
if (param != MeteoData::VW)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
......@@ -612,16 +612,16 @@ void SimpleWindInterpolationAlgorithm::calculate(Grid2DObject& grid)
getStationAltitudes(vecMeta, vecAltitudes);
if( vecDataDW.size() == 0)
if( vecDataDW.size() == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);