WSL/SLF GitLab Repository

Commit 7dfd30af authored by Mathias Bavay's avatar Mathias Bavay
Browse files

fixing warnings/errors found when compiling on Hera... (types mismatch)

parent 3451fd19
......@@ -527,7 +527,7 @@ void IOUtils::getTimeZoneParameters(const Config& cfg, double& tz_in, double& tz
cfg.getValue("TIME_ZONE", "Output", tz_out, Config::nothrow);
}
unsigned int IOUtils::seek(const Date& soughtdate, const std::vector<MeteoData>& vecM, const bool& exactmatch){
size_t IOUtils::seek(const Date& soughtdate, const std::vector<MeteoData>& vecM, const bool& exactmatch){
//returns index of element, if element does not exist it returns closest index after soughtdate
//the element needs to be an exact hit or embedded between two measurments
......
......@@ -24,8 +24,8 @@ namespace mio {
/************************************************************
* static section *
************************************************************/
const unsigned int MeteoData::nrOfParameters = MeteoData::lastparam - MeteoData::firstparam + 1;
map<unsigned int, string> MeteoData::static_meteoparamname;
const size_t MeteoData::nrOfParameters = MeteoData::lastparam - MeteoData::firstparam + 1;
map<size_t, string> MeteoData::static_meteoparamname;
const bool MeteoData::__init = MeteoData::initStaticData();
bool MeteoData::initStaticData()
......@@ -48,7 +48,7 @@ bool MeteoData::initStaticData()
return true;
}
const std::string& MeteoData::getParameterName(const unsigned int& parindex)
const std::string& MeteoData::getParameterName(const size_t& parindex)
{
if (parindex >= MeteoData::nrOfParameters)
throw IndexOutOfBoundsException("Trying to access meteo parameter that does not exist", AT);
......@@ -61,9 +61,9 @@ const std::string& MeteoData::getParameterName(const unsigned int& parindex)
* non-static section *
************************************************************/
const std::string& MeteoData::getNameForParameter(const unsigned int& parindex) const
const std::string& MeteoData::getNameForParameter(const size_t& parindex) const
{
std::map<unsigned int, std::string>::const_iterator it;
std::map<size_t, std::string>::const_iterator it;
it = meteoparamname.find(parindex);
#ifndef NOSAFECHECKS
......@@ -113,7 +113,7 @@ void MeteoData::initParameterMap()
nrOfAllParameters = meteoparam.size();
//Go through all parameters in <int,string> map and store them into <string,double*> map
map<unsigned int, string>::const_iterator tmpit;
map<size_t, string>::const_iterator tmpit;
for (tmpit = meteoparamname.begin(); tmpit != meteoparamname.end(); tmpit++)
mapParameterByName[tmpit->second] = meteoparam[tmpit->first];
......@@ -180,8 +180,8 @@ MeteoData& MeteoData::operator=(const MeteoData& rhs)
associateMemberVariables(); //sets the pointers for the standard parameters in the meteoparam map
std::map<unsigned int, double*>::const_iterator tmpit;
for (unsigned int ii=0; ii<=MeteoData::lastparam; ii++) {
std::map<size_t, double*>::const_iterator tmpit;
for (size_t ii=0; ii<=MeteoData::lastparam; ii++) {
//go through meteoparameters and copy them by value
double* val = meteoparam[ii];
tmpit = rhs.meteoparam.find(ii);
......@@ -189,7 +189,7 @@ MeteoData& MeteoData::operator=(const MeteoData& rhs)
mapParameterByName[meteoparamname[ii]] = val; //copy pointer into mapParameterByName
}
for (unsigned int ii=MeteoData::lastparam+1; ii<rhs.getNrOfParameters(); ii++) {
for (size_t ii=MeteoData::lastparam+1; ii<rhs.getNrOfParameters(); ii++) {
//for the extraparameters other measures are necessary
const string& name = meteoparamname[ii]; //get the name of that extra parameter
double* val = &extraparameters[name]; //copy the pointer
......@@ -213,7 +213,7 @@ void MeteoData::setDate(const Date& in_date)
void MeteoData::reset()
{
std::map<unsigned int, double*>::iterator it;
std::map<size_t, double*>::iterator it;
for (it=meteoparam.begin(); it!=meteoparam.end(); it++){
*it->second = IOUtils::nodata;
}
......@@ -229,7 +229,7 @@ void MeteoData::setData(const MeteoData::Parameters& param, const double& value)
* The plugin-specific nodata values are replaced by MeteoIO's internal nodata value
*/
void MeteoData::standardizeNodata(const double& plugin_nodata) {
for(unsigned int ii=0; ii<nrOfParameters; ii++){
for(size_t ii=0; ii<nrOfParameters; ii++){
//loop through all meteo params and check whether they're nodata values
if (param(ii)<=plugin_nodata)
param(ii) = IOUtils::nodata;
......@@ -251,7 +251,7 @@ bool MeteoData::operator==(const MeteoData& in) const
//An object is equal if the date is equal and all meteo parameters are equal
bool eval = (date==in.date);
for (unsigned int ii=0; ii<in.getNrOfParameters(); ii++){
for (size_t ii=0; ii<in.getNrOfParameters(); ii++){
eval &= (param(ii) == in.param(ii));
}
......@@ -263,7 +263,7 @@ bool MeteoData::operator!=(const MeteoData& in) const
return !(*this==in);
}
double& MeteoData::param(const unsigned int& parindex)
double& MeteoData::param(const size_t& parindex)
{
#ifndef NOSAFECHECKS
if (parindex >= getNrOfParameters())
......@@ -272,9 +272,9 @@ double& MeteoData::param(const unsigned int& parindex)
return *(meteoparam[parindex]);
}
const double& MeteoData::param(const unsigned int& parindex) const
const double& MeteoData::param(const size_t& parindex) const
{
std::map<unsigned int, double*>::const_iterator it;
std::map<size_t, double*>::const_iterator it;
it = meteoparam.find(parindex);
#ifndef NOSAFECHECKS
......@@ -308,9 +308,9 @@ const double& MeteoData::param(const std::string& parname) const
return *(it->second);
}
unsigned int MeteoData::getParameterIndex(const std::string& parname) const
size_t MeteoData::getParameterIndex(const std::string& parname) const
{
for (map<unsigned int, string>::const_iterator it=meteoparamname.begin(); it!=meteoparamname.end(); it++){
for (map<size_t, string>::const_iterator it=meteoparamname.begin(); it!=meteoparamname.end(); it++){
if (it->second == parname)
return it->first;
}
......@@ -335,7 +335,7 @@ std::ostream& operator<<(std::ostream& os, const MeteoData& data) {
os << data.meta;
os << data.date.toString(Date::FULL) << "\n";
std::map<unsigned int, double*>::const_iterator it1;
std::map<size_t, double*>::const_iterator it1;
for (it1=data.meteoparam.begin(); it1 != data.meteoparam.end(); it1++){
if( (*it1->second) != IOUtils::nodata ) {
os << setw(8) << data.getNameForParameter(it1->first) << ":" << setw(15) << *it1->second << "\n";
......@@ -348,7 +348,7 @@ std::ostream& operator<<(std::ostream& os, const MeteoData& data) {
void MeteoData::initAllParameters()
{
std::map<unsigned int, double*>::iterator it;
std::map<size_t, double*>::iterator it;
for (it=meteoparam.begin(); it!=meteoparam.end(); it++){
*meteoparam[it->first] = IOUtils::nodata;
}
......
......@@ -64,8 +64,8 @@ class MeteoData {
P, ///< Air pressure
lastparam=P};
static const unsigned int nrOfParameters; ///<holds the number of meteo parameters stored in MeteoData
static const std::string& getParameterName(const unsigned int& parindex);
static const size_t nrOfParameters; ///<holds the number of meteo parameters stored in MeteoData
static const std::string& getParameterName(const size_t& parindex);
/**
* @brief The default constructor initializing every double attribute to nodata and the Date to julian==0.0
......@@ -123,12 +123,12 @@ class MeteoData {
void standardizeNodata(const double& plugin_nodata);
double& param(const unsigned int& parindex);
const double& param(const unsigned int& parindex) const;
double& param(const size_t& parindex);
const double& param(const size_t& parindex) const;
double& param(const std::string& parname);
const double& param(const std::string& parname) const;
const std::string& getNameForParameter(const unsigned int& parindex) const;
unsigned int getParameterIndex(const std::string& parname) const;
const std::string& getNameForParameter(const size_t& parindex) const;
size_t getParameterIndex(const std::string& parname) const;
friend std::ostream& operator<<(std::ostream& os, const MeteoData& data);
......@@ -156,7 +156,7 @@ class MeteoData {
size_t getNrOfParameters() const;
private:
//static methods
static std::map<unsigned int, std::string> static_meteoparamname; ///<Associate a name with meteo parameters in Parameters
static std::map<size_t, std::string> static_meteoparamname; ///<Associate a name with meteo parameters in Parameters
static const bool __init; ///<helper variable to enable the init of static collection data
static bool initStaticData();///<initialize the static map meteoparamname
......
......@@ -23,7 +23,7 @@ using namespace std;
namespace mio {
/**
* @page resampling Resampling overview
* The resampling infrastructure is described in ResamplingAlgorithms (for its API).
* The resampling infrastructure is described in ResamplingAlgorithms (for its API).
* The goal of this page is to give an overview of the available resampling algorithms and their usage.
*
* @section resampling_section Resampling section
......@@ -34,12 +34,12 @@ namespace mio {
* @code
* [Interpolations1D]
* TA::resample = linear
*
*
* RH::resample = linear
*
*
* VW::resample = nearest_neighbour
* VW::args = extrapolate
*
*
* HNW::resample = linear
* @endcode
*
......@@ -95,7 +95,7 @@ void ResamplingAlgorithms::NoResampling(const unsigned int& /*pos*/, const unsig
/**
* @brief Nearest Neighbour data resampling: Find the nearest neighbour of a desired data point
* @brief Nearest Neighbour data resampling: Find the nearest neighbour of a desired data point
* that is not IOUtils::nodata and copy that value into the desired data point
* - If the data point itself is not IOUtils::nodata, nothing needs to be done
* - If two points have the same distance from the data point to be resampled, calculate mean and return it
......@@ -155,10 +155,10 @@ void ResamplingAlgorithms::NearestNeighbour(const unsigned int& pos, const unsig
}
/**
* @brief Linear data resampling: If a point is requested that is in between two input data points,
* the requested value is automatically calculated using a linear interpolation. Furthermore
* @brief Linear data resampling: If a point is requested that is in between two input data points,
* the requested value is automatically calculated using a linear interpolation. Furthermore
* if the argument extrapolate is provided there will be an attempt made to extrapolate the
* point if the interpolation fails, by solving the line equation y = kx + d
* point if the interpolation fails, by solving the line equation y = kx + d
* @code
* [Interpolations1D]
* TA::resample = linear
......@@ -181,27 +181,27 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
//Now find two points within the vecM (before and aft, that are not IOUtils::nodata)
//If that condition cannot be met, simply add nodata for the resampled value (exception: extrapolate)
unsigned int indexP1=IOUtils::npos, indexP2=IOUtils::npos;
size_t indexP1=IOUtils::npos, indexP2=IOUtils::npos;
bool foundP1=false, foundP2=false;
for (unsigned int ii=pos; (ii--) > 0; ){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP1=ii;
indexP1 = (size_t)ii;
foundP1 = true;
break;
}
}
}
for (unsigned int ii=pos+1; ii<vecM.size(); ii++){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP2 = ii;
indexP2 = (size_t)ii;
foundP2 = true;
break;
}
}
//do nothing if we can't interpolate, and extrapolation is not explicitly activated
if ((!extrapolate) && ((!foundP1) || (!foundP2)))
if ((!extrapolate) && ((!foundP1) || (!foundP2)))
return;
//do nothing if not at least one value different from IOUtils::nodata has been found
......@@ -216,7 +216,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
foundP1 = true;
break;
}
}
}
} else if (foundP1 && !foundP2){ //only nodata found after pos, try looking before indexP1
for (unsigned int ii=indexP1; (ii--) > 0; ){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
......@@ -224,7 +224,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
foundP2 = true;
break;
}
}
}
}
if (!foundP1 || !foundP2) //now at least two points need to be present
......@@ -274,7 +274,7 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
tmp << "Please provide accumulation period (in seconds) for param" << vecM.at(0).getNameForParameter(paramindex);
throw InvalidArgumentException(tmp.str(), AT);
}
//find start of accumulation period
bool found_start=false;
unsigned int start_idx = pos+1;
......@@ -294,17 +294,17 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
vecM[pos].param(paramindex) = IOUtils::nodata;
return;
}
//resample the starting point
//HACK: we consider nodata to be 0. In fact, we should try to interpolate from valid points
//if they are not too far away
unsigned int interval_end = start_idx + 1;
double valstart = funcval(vecM, start_idx, dateStart, paramindex);
double valend = funcval(vecM, interval_end, vecM[interval_end].date, paramindex);
double sum = IOUtils::nodata;
if ((valend == IOUtils::nodata) || (valstart == IOUtils::nodata)){
sum = 0.0; //HACK maybe it should be set it to IOUtils::nodata
} else {
......@@ -335,7 +335,7 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
}
valend = funcval(vecM, pos, vecM[pos].date, paramindex);
if (valend != IOUtils::nodata)
sum += valend;
......
......@@ -21,8 +21,8 @@ using namespace std;
namespace mio {
WindowedFilter::WindowedFilter(const std::string& name)
: FilterBlock(name), is_soft(false), min_data_points(1), min_time_span(0.0, 0.),
WindowedFilter::WindowedFilter(const std::string& name)
: FilterBlock(name), is_soft(false), min_data_points(1), min_time_span(0.0, 0.),
centering(WindowedFilter::center), elements_left(0), elements_right(0), last_index(IOUtils::npos)
{}
......@@ -39,7 +39,7 @@ unsigned int WindowedFilter::get_centering(std::vector<std::string>& vec_args) {
return WindowedFilter::center;
}
}
return WindowedFilter::center; //the default
}
......@@ -51,7 +51,7 @@ unsigned int WindowedFilter::get_centering(std::vector<std::string>& vec_args) {
* @param index The index of the element in ivec that requires a window
* @param ivec The original sequence of data points
*/
const std::vector<const MeteoData*>& WindowedFilter::get_window(const unsigned int& index,
const std::vector<const MeteoData*>& WindowedFilter::get_window(const size_t& index,
const std::vector<MeteoData>& ivec)
{
//cout << "Requesting index " << index << endl;
......@@ -60,8 +60,8 @@ const std::vector<const MeteoData*>& WindowedFilter::get_window(const unsigned i
vec_window.clear();
elements_left = elements_right = 0;
if ((centering == WindowedFilter::right) || (is_soft)){
for (unsigned int kk=0; kk<min_data_points; kk++){
if ((centering == WindowedFilter::right) || (is_soft)){
for (size_t kk=0; kk<min_data_points; kk++){
if (ivec.size() > kk) {
elements_right++;
vec_window.push_back(&ivec[kk]);
......@@ -77,7 +77,7 @@ const std::vector<const MeteoData*>& WindowedFilter::get_window(const unsigned i
}
//cout << "Init: " << elements_left << "/" << elements_right << endl;
last_index = 0;
return vec_window;
......@@ -100,7 +100,7 @@ const std::vector<const MeteoData*>& WindowedFilter::get_window(const unsigned i
} else if (centering == WindowedFilter::left){
if (index >= (vec_window.size())){
if (ivec.size() > index){ //otherwise don't touch the whole thing
vec_window.erase(vec_window.begin());
vec_window.erase(vec_window.begin());
vec_window.push_back(&ivec[index]);
}
} else {
......@@ -145,24 +145,24 @@ const std::vector<const MeteoData*>& WindowedFilter::get_window(const unsigned i
} else {
if (ivec.size() > index) { //broaden window
vec_window.push_back(&ivec[index]);
elements_left++;
elements_left++;
}
}
} else if (centering == WindowedFilter::center){
if ((elements_left + elements_right - 1) >= min_data_points){
vec_window.erase(vec_window.begin());
if (elements_right > 0) elements_right--;
if (ivec.size() > (index+elements_left-1)) { //shift window one point to the right
vec_window.push_back(&ivec[index+elements_left-1]);
elements_right++; //elements_left will stay at a constant
elements_right++; //elements_left will stay at a constant
}
} else {
if (ivec.size() > (index+elements_left-1)) { //shift window one point to the right
vec_window.push_back(&ivec[index+elements_left-1]);
elements_left++;
}
if ((elements_left + elements_right - 1) < min_data_points){
if (ivec.size() > (index+elements_left-1)){ //shift window one point to the right
vec_window.push_back(&ivec[index+elements_left-1]);
......
......@@ -26,7 +26,7 @@ namespace mio {
/**
* @class WindowedFilter
* @brief
* @brief
* @author Thomas Egger
* @date 2011-01-22
*/
......@@ -42,20 +42,20 @@ class WindowedFilter : public FilterBlock {
WindowedFilter(const std::string& name);
virtual void process(const unsigned int& index, const std::vector<MeteoData>& ivec,
std::vector<MeteoData>& ovec) = 0;
std::vector<MeteoData>& ovec) = 0; //HACK: index should be size_t
static unsigned int get_centering(std::vector<std::string>& vec_args);
protected:
const std::vector<const MeteoData*>& get_window(const unsigned int& index,
const std::vector<const MeteoData*>& get_window(const size_t& index,
const std::vector<MeteoData>& ivec);
bool is_soft;
unsigned int min_data_points;
size_t min_data_points;
Duration min_time_span;
Centering centering;
unsigned int elements_left, elements_right, last_index;
size_t elements_left, elements_right, last_index;
private:
std::vector<const MeteoData*> vec_window;
......
......@@ -57,7 +57,7 @@ const bool SMETIO::__init = SMETIO::initStaticData();
bool SMETIO::initStaticData()
{
for (unsigned int ii=0; ii<MeteoData::nrOfParameters; ii++){
for (size_t ii=0; ii<MeteoData::nrOfParameters; ii++){
mapParameterByName[MeteoData::getParameterName(ii)] = MeteoData::Parameters(ii);
}
......@@ -85,9 +85,9 @@ void SMETIO::checkColumnNames(const std::vector<std::string>& vecColumns, const
* This function checks whether the sequence of keywords specified in the
* [HEADER] section (key 'fields') is valid
*/
vector<unsigned int> paramcounter = vector<unsigned int>(MeteoData::nrOfParameters, 0);
vector<size_t> paramcounter = vector<size_t>(MeteoData::nrOfParameters, 0);
for (unsigned int ii=0; ii<vecColumns.size(); ii++){
for (size_t ii=0; ii<vecColumns.size(); ii++){
std::string column = vecColumns[ii];
//column names mapping
......@@ -107,7 +107,7 @@ void SMETIO::checkColumnNames(const std::vector<std::string>& vecColumns, const
}
//Check for multiple usages of parameters
for (unsigned int ii=0; ii<paramcounter.size(); ii++){
for (size_t ii=0; ii<paramcounter.size(); ii++){
if (paramcounter[ii] > 1)
throw InvalidFormatException("In 'fields': Multiple use of " + MeteoData::getParameterName(ii), AT);
}
......@@ -115,8 +115,8 @@ void SMETIO::checkColumnNames(const std::vector<std::string>& vecColumns, const
//If there is no location information in the [HEADER] section, then
//location information must be part of fields
if (!locationInHeader){
unsigned int latcounter = 0, loncounter=0, altcounter=0;
for (unsigned int ii=0; ii<vecColumns.size(); ii++){
size_t latcounter = 0, loncounter=0, altcounter=0;
for (size_t ii=0; ii<vecColumns.size(); ii++){
if (vecColumns[ii] == "longitude")
loncounter++;
else if (vecColumns[ii] == "latitude")
......@@ -200,7 +200,7 @@ void SMETIO::readStationData(const Date&, std::vector<StationData>& vecStation)
vecStation.reserve(nr_stations);
//Now loop through all requested stations, open the respective files and parse them
for (unsigned int ii=0; ii<nr_stations; ii++){
for (size_t ii=0; ii<nr_stations; ii++){
bool isAscii = true;
string filename = vecFiles.at(ii); //filename of current station
......@@ -255,7 +255,7 @@ void SMETIO::parseInputOutputSection()
cfg.getValue("METEO", "Input", in_meteo, Config::nothrow);
if (in_meteo == "SMET") { //keep it synchronized with IOHandler.cc for plugin mapping!!
cfg.getValue("METEOPATH", "Input", inpath);
unsigned int counter = 1;
size_t counter = 1;
string filename = "";
do {
......@@ -322,7 +322,7 @@ void SMETIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
{
//Make sure that vecMeteo have the correct dimension and stationindex is valid
size_t startindex=0, endindex=vecFiles.size();
if (stationindex != IOUtils::npos){
if (stationindex != (unsigned int)IOUtils::npos){ //HACK do we really still need stationindex??
if ((stationindex < vecFiles.size()) || (stationindex < vecMeteo.size())){
startindex = stationindex;
endindex = stationindex+1;
......
......@@ -85,7 +85,7 @@ class SNIO : public IOInterface {
std::ofstream fout;//Output file streams
static const int sn_julian_offset;
static const double plugin_nodata; //plugin specific nodata value, e.g. -999
static const unsigned int min_nr_meteoData; // minimal number of parameters on data input lines
static const size_t min_nr_meteoData; // minimal number of parameters on data input lines
unsigned int nr_meteoData; // number of parameters on data input lines, excluding optional ones
std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
std::vector<StationData> vecAllStations;
......
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