WSL/SLF GitLab Repository

Commit 4b59fe4a authored by Mathias Bavay's avatar Mathias Bavay
Browse files

fixing some of the warnings found on Hera (sorry for not noticing before). All...

fixing some of the warnings found on Hera (sorry for not noticing before). All the size_t / unsigned int stuff will have to be addressed later
parent bef3f2d3
......@@ -23,7 +23,7 @@ namespace mio {
BufferedIOHandler::BufferedIOHandler(IOHandler& in_iohandler, const Config& in_cfg)
: iohandler(in_iohandler), cfg(in_cfg), vec_buffer_meteo(), mapBufferedGrids(), IndexBufferedGrids(),
buffer_start(), buffer_end(), chunk_size(), buff_before(), chunks(1), max_grids(10)
buffer_start(), buffer_end(), chunk_size(), buff_before(), max_grids(10)
{
setDfltBufferProperties();
......@@ -46,7 +46,6 @@ BufferedIOHandler& BufferedIOHandler::operator=(const BufferedIOHandler& source)
buffer_end = source.buffer_end;
chunk_size = source.chunk_size;
buff_before = source.buff_before;
chunks = source.chunks;
max_grids = source.max_grids;
}
return *this;
......@@ -183,9 +182,7 @@ void BufferedIOHandler::writeMeteoData(const std::vector< METEO_TIMESERIE >& vec
void BufferedIOHandler::setDfltBufferProperties()
{
double chunk_size_days = 15.; //default chunk size value
chunks = 1;
cfg.getValue("BUFF_CHUNK_SIZE", "General", chunk_size_days, IOUtils::nothrow); //in days
cfg.getValue("BUFF_CHUNKS", "General", chunks, IOUtils::nothrow);
chunk_size = Duration(chunk_size_days, 0);
//get buffer centering options
......@@ -270,7 +267,7 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
{
vecMeteo.clear();
const Date new_buffer_start(date_start-buff_before); //taking centering into account
Date new_buffer_end(new_buffer_start + chunk_size*chunks);
Date new_buffer_end(new_buffer_start + chunk_size);
vector< vector<MeteoData> > tmp_meteo_buffer; //it must be here -> adresses copied in 2. are still valid
//Read MeteoData for requested interval in chunks, furthermore buffer it
......@@ -294,7 +291,7 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
while (date_end > new_buffer_end){
//if the requested interval is bigger than a normal buffer, we have to increase the buffer anyway...
tmp_meteo_buffer.reserve(buffer_size);
iohandler.readMeteoData(new_buffer_end, new_buffer_end+chunk_size*chunks, tmp_meteo_buffer);
iohandler.readMeteoData(new_buffer_end, new_buffer_end+chunk_size, tmp_meteo_buffer);
if (tmp_meteo_buffer.size() != buffer_size) {
stringstream ss;
......@@ -314,7 +311,7 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
vec_buffer_meteo[ii].reserve(vec_buffer_meteo[ii].size()+tmp_meteo_buffer[ii].size());
vec_buffer_meteo[ii].insert(vec_buffer_meteo[ii].end(), tmp_meteo_buffer[ii].begin(), tmp_meteo_buffer[ii].end());
}
new_buffer_end += chunk_size*chunks;
new_buffer_end += chunk_size;
buffer_end = new_buffer_end;
}
}
......@@ -343,7 +340,6 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
}
void BufferedIOHandler::bufferData(const Date& date_start, const Date& date_end, std::vector< METEO_TIMESERIE >& vecvecMeteo){
//TODO: implement reading data by chunks. It has to be done the same way as rebuffering
vecvecMeteo.clear(); //the plugins do it internally anyway, but this is cheap and safe...
iohandler.readMeteoData(date_start, date_end, vecvecMeteo);
buffer_start = date_start;
......@@ -395,7 +391,7 @@ std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data)
os << "Config& cfg = " << hex << &data.cfg << dec << "\n";
os << "IOHandler &iohandler = " << hex << &data.iohandler << dec << "\n";
os << "Buffering " << data.chunks << " chunk(s) of " <<data.chunk_size.getJulian() << " day(s) with "
os << "Buffering " <<data.chunk_size.getJulian() << " day(s) with "
<< data.buff_before.getJulian() << " day(s) pre-buffering\n";
os << "Current buffer content (" << data.vec_buffer_meteo.size() << " stations, "
......
......@@ -162,7 +162,6 @@ class BufferedIOHandler : public IOInterface {
Date buffer_start, buffer_end;
Duration chunk_size; ///< How much data to read at once
Duration buff_before; ///< How much data to read before the requested date in buffer
size_t chunks; ///< How many chuncks to buffer
size_t max_grids; ///< How many grids to buffer (grids, dems, landuse and assimilation grids together)
};
......
......@@ -230,7 +230,8 @@ std::ostream& operator<<(std::ostream &os, const Coords& coord)
os << "Lat/Long\t" << "(" << coord.getLat() << " , " << coord.getLon() << ")" << "\n";
std::streamsize p = os.precision();
os << "X/Y_coords\t" << std::fixed << std::setprecision(0) << "(" << coord.getEasting() << " , " << coord.getNorthing() << ")" << "\n";
os << std::resetiosflags(std::ios_base::fixed|std::ios_base::floatfield) << std::setprecision(p);
os << std::resetiosflags(std::ios_base::fixed|std::ios_base::floatfield);
os.precision(p);
os << "I/J_indices\t" << "(" << coord.getGridI() << " , " << coord.getGridJ() << ")" << "\n";
os << "Projection\t" << coord.coordsystem << " " << coord.coordparam << "\n";
os << "EPSG\t\t" << coord.getEPSG() << "\n";
......
......@@ -79,10 +79,10 @@ IOException::IOException(const std::string& message, const std::string& position
#if defined(LINUX) && !defined(ANDROID) && !defined(CYGWIN)
void* tracearray[25]; //maximal size for backtrace: 25 pointers
size_t tracesize = backtrace(tracearray, 25); //obtains backtrace for current thread
const int tracesize = backtrace(tracearray, 25); //obtains backtrace for current thread
char** symbols = backtrace_symbols(tracearray, tracesize); //translate pointers to strings
std::string backtrace_info = "\n\033[01;30m**** backtrace ****\n"; //we use ASCII color codes to make the backtrace less visible/aggressive
for (unsigned int ii=1; ii<tracesize; ii++) {
for (unsigned int ii=1; ii<(unsigned)tracesize; ii++) {
#ifdef __GNUC__
std::stringstream ss;
char *mangled_name = 0, *offset_begin = 0, *offset_end = 0;
......@@ -128,8 +128,7 @@ IOException::IOException(const std::string& message, const std::string& position
#endif
}
IOException::~IOException() throw(){
}
IOException::~IOException() throw() {}
const char* IOException::what() const throw()
{
......
......@@ -709,8 +709,8 @@ size_t seek(const Date& soughtdate, const std::vector<MeteoData>& vecM, const bo
size_t first = 0, last = vecM.size()-1;
const double raw_pos = (curr_val-start_val) / (end_val-start_val);
const size_t start = MAX( (size_t)(floor(raw_pos*last*.8)), first);
const size_t end = MIN( (size_t)ceil(raw_pos*last*1.2), last);
const size_t start = MAX( (size_t)(floor(raw_pos*static_cast<double>(last)*.8)), first);
const size_t end = MIN( (size_t)ceil(raw_pos*static_cast<double>(last)*1.2), last);
if(vecM[start].date.getJulian(true)<curr_val) first=start;
if(vecM[end].date.getJulian(true)>=curr_val) last=end;
......
......@@ -446,7 +446,7 @@ double RHAlgorithm::getQualityRating()
if (vecDataTA.empty())
return 0.0;
if( ( nrOfMeasurments<(size_t)(0.5*vecDataRH.size()) ) || ( nrOfMeasurments<2 ) )
if( (nrOfMeasurments<vecDataRH.size()/2) || ( nrOfMeasurments<2 ) )
return 0.6;
return 0.9;
......@@ -603,7 +603,7 @@ double SimpleWindInterpolationAlgorithm::getQualityRating()
if (vecDataVW.empty())
return 0.0;
if( ( nrOfMeasurments<(size_t)(0.5*vecDataVW.size()) ) || ( nrOfMeasurments<2 ) )
if( (nrOfMeasurments<vecDataVW.size()/2) || ( nrOfMeasurments<2 ) )
return 0.6;
return 0.9;
......
......@@ -45,8 +45,8 @@ Timer::Timer() : start_point(0.), elapsed(0.), isRunning(false)
*/
void Timer::start() {
if (!isRunning) {
isRunning=true;
start_point=getCurrentTime();
isRunning = true;
start_point = getCurrentTime();
}
}
......@@ -55,7 +55,7 @@ void Timer::start() {
*/
void Timer::restart() {
reset();
isRunning=true;
isRunning = true;
}
/**
......@@ -64,8 +64,8 @@ void Timer::restart() {
*/
void Timer::stop() {
if (isRunning) {
elapsed+=getCurrentTime()-start_point;
isRunning=false;
elapsed += static_cast<double>(getCurrentTime()-start_point);
isRunning = false;
}
}
......@@ -73,8 +73,8 @@ void Timer::stop() {
* @brief Reset the timer to zero.
*/
void Timer::reset() {
start_point=getCurrentTime();
elapsed=0;
start_point = getCurrentTime();
elapsed = 0.;
}
/**
......@@ -84,13 +84,13 @@ void Timer::reset() {
*/
double Timer::getElapsed() const {
if (isRunning) {
return elapsed+getCurrentTime()-start_point;
return elapsed + static_cast<double>(getCurrentTime()-start_point);
}
return elapsed;
}
#ifdef WIN32
double Timer::getCurrentTime() const {
long double Timer::getCurrentTime() const {
SYSTEMTIME systemTime;
GetSystemTime( &systemTime );
......@@ -101,15 +101,15 @@ double Timer::getCurrentTime() const {
uli.LowPart = fileTime.dwLowDateTime;
uli.HighPart = fileTime.dwHighDateTime;
const ULONGLONG units_convert = 10000*1000; //it gives the time since 1 January 1601 (UTC) in units of 100ns
const ULONGLONG units_convert = 10000*1000ULL; //it gives the time since 1 January 1601 (UTC) in units of 100ns
const ULONGLONG offset_to_epoch = 11644473600ULL; //offset in seconds to Unix epoch, 134774 days * 24*3600
return static_cast<double>(uli.QuadPart - offset_to_epoch*units_convert) / units_convert;
return static_cast<long double>(uli.QuadPart - offset_to_epoch*units_convert) / units_convert;
}
#else
double Timer::getCurrentTime() const {
long double Timer::getCurrentTime() const {
timeval tp;
gettimeofday(&tp,NULL);
const double t=tp.tv_sec+double(tp.tv_usec)*1.0e-6;
const long double t = tp.tv_sec+tp.tv_usec*1.0e-6;
return t;
}
#endif
......
......@@ -49,9 +49,9 @@ public:
void reset();
double getElapsed() const;
protected:
double getCurrentTime() const;
long double getCurrentTime() const;
double start_point;
long double start_point;
double elapsed;
bool isRunning;
};
......
......@@ -98,7 +98,7 @@ void FilterStdDev::getStat(const std::vector<MeteoData>& ivec, const unsigned in
sum3 = sum3 + (value - mean);
}
}
const double variance = (sum2 - sum3*sum3/count) / (count - 1);
const double variance = (sum2 - sum3*sum3/static_cast<double>(count)) / static_cast<double>(count - 1);
stddev = sqrt(variance);
}
}
......
......@@ -89,7 +89,7 @@ double FilterTukey::getStdDev(const std::vector<MeteoData>& ivec, const unsigned
sum3 = sum3 + (value - mean);
}
}
const double variance = (sum2 - sum3*sum3/count) / (count - 1);
const double variance = (sum2 - sum3*sum3/static_cast<double>(count)) / static_cast<double>(count - 1);
return sqrt(variance);
}
......
......@@ -74,8 +74,8 @@ double FilterWindAvg::calc_avg(const std::vector<MeteoData>& ivec, const unsigne
if(count==0) return IOUtils::nodata;
ve /= count;
vn /= count;
ve /= static_cast<double>(count);
vn /= static_cast<double>(count);
if(param==MeteoData::VW) {
const double meanspeed = sqrt(ve*ve + vn*vn);
......
......@@ -81,7 +81,7 @@ double ProcWMASmoothing::calcWMASmoothing(const std::vector<MeteoData>& ivec, co
}
if (norm > 0)
return wma/norm;
return wma / static_cast<double>(norm);
else
return IOUtils::nodata;
}
......
......@@ -128,7 +128,7 @@ void SunObject::getBeamPotential(const double& sun_elevation, const double& Ecce
R_toa = 0.;
R_direct = 0.;
R_diffuse = 0.;
} else {
} else {
const double olt = 0.32; // ozone layer thickness (cm) U.S.standard = 0.34 cm
const double w0 = 0.9; // fraction of energy scattered to total attenuation by aerosols (Bird and Hulstrom(1981))
const double fc = 0.84; // fraction of forward scattering to total scattering (Bird and Hulstrom(1981))
......@@ -342,7 +342,8 @@ std::ostream& operator<<(std::ostream &os, const SunObject& data)
os << std::fixed << std::setw(colw) << std::setprecision(1) << R_diffuse;
os << std::fixed << std::setw(colw) << std::setprecision(1) << R_direct+R_diffuse << "\n";
os << "</SunObject>\n" << std::setprecision(old_prec);
os << "</SunObject>\n";
os.precision(old_prec);
return os;
}
......
......@@ -125,7 +125,7 @@ bool FitLeastSquare::computeFit() {
initDLambda(dLambda);
Matrix A((unsigned int)nPts, (unsigned int)nParam);
Matrix dBeta(nPts,(unsigned)1);
Matrix dBeta(nPts,(unsigned int)1);
unsigned int iter = 0;
do {
......
......@@ -310,7 +310,7 @@ double Interpol1D::variance(const std::vector<double>& X)
sum3 = sum3 + (value - mean);
}
}
const double variance = (sum2 - sum3*sum3/count) / (count - 1);
const double variance = (sum2 - sum3*sum3/static_cast<double>(count)) / static_cast<double>(count - 1);
return variance;
}
......
......@@ -718,8 +718,8 @@ void Interpol2D::ODKriging(const std::vector<double>& vecData, const std::vector
//now, calculate each point
for(size_t j=0; j<grid.nrows; j++) {
for(size_t i=0; i<grid.ncols; i++) {
const double x = llcorner_x+i*cellsize;
const double y = llcorner_y+j*cellsize;
const double x = llcorner_x+static_cast<double>(i)*cellsize;
const double y = llcorner_y+static_cast<double>(j)*cellsize;
//fill gamma
for(size_t st=0; st<nrOfMeasurments; st++) {
......
......@@ -376,7 +376,7 @@ void PNGIO::setFile(const std::string& filename, png_structp& png_ptr, png_infop
unsigned int PNGIO::setLegend(const unsigned int &ncols, const unsigned int &nrows, const double &min, const double &max, Array2D<double> &legend_array)
{
if(has_legend) {
legend leg(nrows, min, max);
const legend leg(nrows, min, max);
legend_array = leg.getLegend();
unsigned int nx, ny;
legend_array.size(nx,ny);
......@@ -469,7 +469,7 @@ void PNGIO::setPalette(const Gradient &gradient, png_structp& png_ptr, png_infop
palette[ii].green = static_cast<png_byte>(pal[interlace+1]);
palette[ii].blue = static_cast<png_byte>(pal[interlace+2]);
}
png_set_PLTE(png_ptr, info_ptr, palette, nr_colors);
png_set_PLTE(png_ptr, info_ptr, palette, static_cast<int>(nr_colors));
}
void PNGIO::closePNG(png_structp& png_ptr, png_infop& info_ptr, png_color *palette)
......@@ -484,7 +484,7 @@ void PNGIO::closePNG(png_structp& png_ptr, png_infop& info_ptr, png_color *palet
void PNGIO::write2DGrid(const Grid2DObject& grid_in, const std::string& filename)
{
string full_name = grid2dpath+"/"+filename;
const string full_name = grid2dpath+"/"+filename;
fp=NULL;
png_color *palette=NULL;
png_structp png_ptr=NULL;
......@@ -655,7 +655,7 @@ void PNGIO::writeWorldFile(const Grid2DObject& grid_in, const std::string& filen
{
const string world_file = IOUtils::removeExtension(filename)+".pnw";
const double cellsize = grid_in.cellsize;
Coords world_ref=grid_in.llcorner;
Coords world_ref = grid_in.llcorner;
world_ref.setProj(coordout, coordoutparam);
world_ref.moveByXY(.5*cellsize, (grid_in.nrows+.5)*cellsize); //moving to center of upper left cell
......@@ -737,11 +737,9 @@ void PNGIO::writeMetadata(png_structp &png_ptr, png_infop &info_ptr)
{
const size_t max_len = 79; //according to the official specs' recommendation
const size_t nr = metadata_key.size();
png_text *info_text;
info_text = (png_text *)calloc(sizeof(png_text), nr);
char **key, **text;
key = (char**)calloc(sizeof(char)*max_len, nr);
text = (char**)calloc(sizeof(char)*max_len, nr);
png_text *info_text = (png_text *)calloc(sizeof(png_text), nr);
char **key = (char**)calloc(sizeof(char)*max_len, nr);
char **text = (char**)calloc(sizeof(char)*max_len, nr);
for(size_t ii=0; ii<nr; ii++) {
key[ii] = (char *)calloc(sizeof(char), max_len);
......@@ -753,7 +751,7 @@ void PNGIO::writeMetadata(png_structp &png_ptr, png_infop &info_ptr)
info_text[ii].compression = PNG_TEXT_COMPRESSION_NONE;
}
png_set_text(png_ptr, info_ptr, info_text, nr);
png_set_text(png_ptr, info_ptr, info_text, static_cast<int>(nr));
png_write_info(png_ptr, info_ptr);
free(info_text);
......@@ -766,11 +764,11 @@ void PNGIO::writeMetadata(png_structp &png_ptr, png_infop &info_ptr)
}
std::string PNGIO::decimal_to_dms(const double& decimal) {
std::stringstream dms;
const int d = static_cast<int>( floor(decimal) );
const double m = floor( ((decimal - (double)d)*60.)*100. ) / 100.;
const double s = 3600.*(decimal - (double)d) - 60.*m;
std::stringstream dms;
dms << d << "/1 " << static_cast<int>(m*100) << "/100 " << fixed << setprecision(6) << s << "/1";
return dms.str();
}
......
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