WSL/SLF GitLab Repository

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

The CMakeLists were not making Visual C++ happy. This has been fixed. Several...

The CMakeLists were not making Visual C++ happy. This has been fixed. Several types issues have been fixed. The /Wp64 option of Visual C++ has been turned off, since it reports wrongly some things as errors (dixit Microsoft and my own experience).
parent e9edae25
......@@ -47,7 +47,7 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
#SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs" FORCE)
SET(WARNINGS "/W4")
SET(EXTRA_WARNINGS "/Wp64") #/Wall
#SET(EXTRA_WARNINGS "/Wp64") #/Wall
SET(OPTIM "/O2 /Vmb /DNDEBUG /MD /DNOSAFECHECKS")
SET(ARCH_OPTIM "/arch:SSE2")
SET(ARCH_SAFE "")
......
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
SET(LIBPREFIX "lib") #make sure ALL plugins are libXXX for ALL plateforms
SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") #for Visual C++ import libraries
OPTION( BUILD_SHARED_LIBS "Set to OFF to build only static libraries" ON )
IF(PROJ4)
FIND_PATH(LIBPROJ_INCLUDE_DIR "proj_api.h")
FIND_LIBRARY(LIBPROJ proj)
......
......@@ -627,12 +627,12 @@ void SMETWriter::check_formatting()
}
}
void SMETWriter::set_width(const std::vector<size_t>& vec_width)
void SMETWriter::set_width(const std::vector<int>& vec_width)
{
ascii_width = vec_width;
}
void SMETWriter::set_precision(const std::vector<size_t>& vec_precision)
void SMETWriter::set_precision(const std::vector<int>& vec_precision)
{
ascii_precision = vec_precision;
}
......
......@@ -84,7 +84,7 @@ class SMETCommon {
/**
* @class SMETReader
* @brief The SMETReader class enables to read a SMET formatted file.
* @brief The SMETReader class enables to read a SMET formatted file.
* Data and header info can be extracted through this class.
*
* @author Thomas Egger
......@@ -107,7 +107,7 @@ class SMETReader {
* @param[out] vec_timestamp A vector of string to hold the timestamp of each line
* @param[out] vec_data A vector of double holding all double values of all lines sequentially
*/
void read(const std::string& timestamp_start, const std::string& timestamp_end,
void read(const std::string& timestamp_start, const std::string& timestamp_end,
std::vector<std::string>& vec_timestamp, std::vector<double>& vec_data);
/**
......@@ -152,7 +152,7 @@ class SMETReader {
* @return The value for the key, if the key is not present return (int)nodata
*/
int get_header_intvalue(const std::string& key) const;
/**
* @brief Check whether timestamp is a part of the fields
* @return true if timestamp is a column in the SMET file, false otherwise
......@@ -197,7 +197,7 @@ class SMETReader {
void get_units_conversion(std::vector<double>& offset, std::vector<double>& multiplier) const;
/**
* @brief Set whether the values returned should be converted according to
* @brief Set whether the values returned should be converted according to
* unit_offset and multiplier or whether the user should get the raw data returned
* @param[in] in_mksa True if the user wants MKSA values returned, false otherwise (default)
*/
......@@ -242,7 +242,7 @@ class SMETReader {
/**
* @class SMETWriter
* @brief The SMETWriter class that enables to write a SMET formatted file.
* @brief The SMETWriter class that enables to write a SMET formatted file.
* The user constructs a SMETWriter class and fills in the header values
* Finally the user may call write(...) and pass the data to be written
*
......@@ -278,8 +278,8 @@ class SMETWriter {
* @brief Write a SMET file, providing ASCII ISO formatted timestamps and data
* @param[in] vec_timestamp A vector with one ASCII date/time combined string for each line
* @param[in] data All the data to be written sequentially into the columns, the data
* is aligned sequentially, not per line; Total size of the vector:
* Total size of the vector: vec_timestamp.size() * nr_of_fields
* is aligned sequentially, not per line; Total size of the vector:
* Total size of the vector: vec_timestamp.size() * nr_of_fields
* (timestamp is not counted as field)
*/
void write(const std::vector<std::string>& vec_timestamp, const std::vector<double>& data);
......@@ -297,7 +297,7 @@ class SMETWriter {
* @param[in] vec_precision Set the precision for every column to be written
* (timestamp is not counted if present)
*/
void set_precision(const std::vector<size_t>& vec_precision);
void set_precision(const std::vector<int>& vec_precision);
/**
* @brief Set width for each field (except timestamp), otherwise a default
......@@ -305,7 +305,7 @@ class SMETWriter {
* @param[in] vec_width Set the width for every column to be written
* (timestamp is not counted if present)
*/
void set_width(const std::vector<size_t>& vec_width);
void set_width(const std::vector<int>& vec_width);
private:
void cleanup() throw();
......@@ -330,7 +330,7 @@ class SMETWriter {
char location_wgs84, location_epsg;
std::vector<std::string> other_header_keys; //this vector is used to preserve the sequence of header keys
std::vector<size_t> ascii_precision, ascii_width;
std::vector<int> ascii_precision, ascii_width;
std::map< std::string, std::string > header;
std::set<std::string> mandatory_header_keys;
std::ofstream fout; //Output file streams
......
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
SET(LIBPREFIX "lib") #make sure ALL plugins are libXXX for ALL plateforms
SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") #for Visual C++ import libraries
OPTION( BUILD_SHARED_LIBS "Set to OFF to build only static libraries" ON )
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
......
......@@ -100,7 +100,7 @@ void GeotopIO::readLanduse(Grid2DObject&)
throw IOException("Nothing implemented here", AT);
}
void GeotopIO::initParamNames(std::map<std::string, unsigned int>& mapParam)
void GeotopIO::initParamNames(std::map<std::string, size_t>& mapParam)
{
mapParam["Iprec"] = MeteoData::HNW;
mapParam["WindS"] = MeteoData::VW;
......@@ -118,14 +118,14 @@ void GeotopIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMe
string path="";
vector<string> vecSequence;
vector<int> ymdhm = vector<int>(5);
map<string, unsigned int> mapParam;
map<string, size_t> mapParam;
initParamNames(mapParam);
cfg.getValue("METEOPATH", "Output", path);
cfg.getValue("METEOSEQ", "Output", vecSequence);
//Check whether vecSequence is valid, that is the keys are part of mapParam
for (unsigned int ii=0; ii<vecSequence.size(); ii++){
map<string,unsigned int>::iterator it = mapParam.find(vecSequence[ii]);
for (size_t ii=0; ii<vecSequence.size(); ii++){
map<string,size_t>::iterator it = mapParam.find(vecSequence[ii]);
if (it == mapParam.end())
throw InvalidFormatException("Key " + vecSequence[ii] +" invalid in io.ini:METEODESTSEQ", AT);
}
......@@ -135,7 +135,7 @@ void GeotopIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMe
fout << "/* Automatically generated by MeteoIO */\n\n";
fout << "index{2}\n\n";
fout << "1: double matrix meteo_station{" << vecMeteo.size() << ",13}\n";
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
if (vecMeteo.at(ii).size()>0){
Coords coord = vecMeteo.at(ii).at(0).meta.position;
coord.setProj(coordout, coordoutparam); //Setting the output projection
......@@ -152,7 +152,7 @@ void GeotopIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMe
fout.close(); //finished writing meta data
//Writing actual meteo files
for (unsigned int ii=0; ii<vecMeteo.size(); ii++){
for (size_t ii=0; ii<vecMeteo.size(); ii++){
stringstream ss;
ss.fill('0');
ss << path << "/" << "_meteo" << setw(4) << (ii+1) << ".txt";
......@@ -162,7 +162,7 @@ void GeotopIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMe
fout << fixed << showpoint << setprecision(5);
for (unsigned int jj=0; jj<vecMeteo.at(ii).size(); jj++){
for (size_t jj=0; jj<vecMeteo.at(ii).size(); jj++){
ss.str(""); //clear the stringstream
Date tmp_date(vecMeteo[ii][jj].date);
tmp_date.setTimeZone(out_tz);
......@@ -175,7 +175,7 @@ void GeotopIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMe
MeteoData tmpmd = vecMeteo[ii][jj];
convertUnitsBack(tmpmd);
for (unsigned int kk=0; kk<vecSequence.size(); kk++){
for (size_t kk=0; kk<vecSequence.size(); kk++){
if (jj==0){ //This is for writing the header
if (kk==0) fout << "Date";
fout << "," << vecSequence[kk];
......@@ -210,12 +210,10 @@ void GeotopIO::readStationData(const Date&, std::vector<StationData>& vecStation
void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex)
const size_t& /*stationindex*/)
{
vector<std::string> tmpvec, vecColumnNames;
string line="", filename="", path="", prefix="";
(void)stationindex;
vecMeteo.clear();
cfg.getValue("METEOPATH", "Input", path);
......@@ -232,7 +230,7 @@ void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::cout << "[i] GEOtopIO: Found " << myStations.size() << " station(s)" << std::endl;
for (unsigned int ii=0; ii<myStations.size(); ii++) {
for (size_t ii=0; ii<myStations.size(); ii++) {
vecMeteo.push_back( vector<MeteoData>() );
stringstream ss;
......@@ -258,9 +256,9 @@ void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
//Go through file, save key value pairs
try {
getline(fin, line, eoln); //read complete line meta information
unsigned int ncols = IOUtils::readLineToVec(line, tmpvec, ',');
size_t ncols = IOUtils::readLineToVec(line, tmpvec, ',');
std::map<std::string, unsigned int> mapHeader;
std::map<std::string, size_t> mapHeader;
makeColumnMap(tmpvec, vecColumnNames, mapHeader);
if (ncols == 0)
......@@ -292,7 +290,7 @@ void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
if ((md.date >= dateStart) && (md.date <= dateEnd)){
current_fpointer = tmp_fpointer;
for (unsigned int jj=1; jj<ncols; jj++) {
for (size_t jj=1; jj<ncols; jj++) {
if (!IOUtils::convertString(tmpdata[jj], tmpvec.at(jj), std::dec))
throw InvalidFormatException(filename + ": " + line, AT);
}
......@@ -315,7 +313,7 @@ void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
}
//save stream position and the corresponding end date
if (current_fpointer != -1) vec_streampos.at(ii)[dateEnd] = current_fpointer;
if (current_fpointer != static_cast<streampos>(-1)) vec_streampos.at(ii)[dateEnd] = current_fpointer;
} catch(std::exception& e) {
cleanup();
throw;
......@@ -363,7 +361,7 @@ void GeotopIO::parseDate(const std::string& datestring, const std::string& filea
void GeotopIO::makeColumnMap(const std::vector<std::string>& tmpvec,
const std::vector<std::string>& vecColumnNames,
std::map<std::string, unsigned int>& mapHeader)
std::map<std::string, size_t>& mapHeader)
{
/*
#1 Precipitation intensity (mm/h)
......@@ -382,7 +380,7 @@ void GeotopIO::makeColumnMap(const std::vector<std::string>& tmpvec,
#14 Temperature of the soil surface (for Dirichlet conditions)
*/
for (unsigned int ii=0; ii<vecColumnNames.size(); ii++){
for (size_t ii=0; ii<vecColumnNames.size(); ii++){
std::string current="";
switch(ii){
case 0: mapHeader["hnw"] = tmpvec.size(); current="hnw"; break;
......@@ -403,7 +401,7 @@ void GeotopIO::makeColumnMap(const std::vector<std::string>& tmpvec,
}
//Go through the columns and seek out which parameter corresponds with which column
for (unsigned int jj=1; jj<tmpvec.size(); jj++){
for (size_t jj=1; jj<tmpvec.size(); jj++){
if (tmpvec[jj].length() >= vecColumnNames[ii].length())
if (vecColumnNames[ii] == tmpvec[jj].substr(0, vecColumnNames[ii].length()))
mapHeader[current] = jj;
......@@ -441,13 +439,13 @@ void GeotopIO::readMetaData(std::vector<StationData>& vecStation, std::vector<st
if (line.substr(0,2) == "1:"){//in section 1
do {
getline(fin, line, eoln);
unsigned int ncols = IOUtils::readLineToVec(line, tmpvec);
size_t ncols = IOUtils::readLineToVec(line, tmpvec);
if (ncols != 13){
break;
} else {
std::vector<double> tmpdata=std::vector<double>(ncols);
for (unsigned int jj=0; jj<ncols; jj++) {
for (size_t jj=0; jj<ncols; jj++) {
if (!IOUtils::convertString(tmpdata.at(jj), tmpvec.at(jj), std::dec))
throw InvalidFormatException(metafile + ": " + line, AT);
}
......@@ -481,7 +479,7 @@ void GeotopIO::readMetaData(std::vector<StationData>& vecStation, std::vector<st
if (line.length()>2) line = line.substr(1,line.length()-2);
IOUtils::readLineToVec(line,vecColumnNames, ',');
for (unsigned int ii=0; ii<vecColumnNames.size(); ii++){
for (size_t ii=0; ii<vecColumnNames.size(); ii++){
IOUtils::trim(vecColumnNames[ii]); //trim the column headers
}
}
......
......@@ -50,8 +50,8 @@ class GeotopIO : public IOInterface {
virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name="");
......@@ -61,12 +61,12 @@ class GeotopIO : public IOInterface {
virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& name);
private:
void initParamNames(std::map<std::string, unsigned int>& mapParam);
void initParamNames(std::map<std::string, size_t>& mapParam);
void readMetaData(std::vector<StationData>& vecStation, std::vector<std::string>& vecColumnNames,
const std::string& metafile);
const std::string& metafile);
void makeColumnMap(const std::vector<std::string>& tmpvec,
const std::vector<std::string>& vecColumnNames,
std::map<std::string, unsigned int>& mapHeader);
const std::vector<std::string>& vecColumnNames,
std::map<std::string, size_t>& mapHeader);
void convertUnits(MeteoData& meteo);
void convertUnitsBack(MeteoData& meteo);
void cleanup() throw();
......
......@@ -469,7 +469,7 @@ void SMETIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
mywriter.set_header_value("station_name", sd.stationName);
mywriter.set_header_value("nodata", IOUtils::nodata);
vector<size_t> myprecision, mywidth; //set meaningful precision/width for each column
vector<int> myprecision, mywidth; //set meaningful precision/width for each column
if (outputIsAscii) {
ss << "timestamp";
......@@ -500,7 +500,7 @@ void SMETIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
}
//Add all other used parameters
size_t tmpwidth, tmpprecision;
int tmpwidth, tmpprecision;
for (size_t ll=0; ll<MeteoData::nrOfParameters; ll++){
if (vecParamInUse[ll]) {
std::string column=MeteoData::getParameterName(ll);
......@@ -561,7 +561,7 @@ void SMETIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
}
}
void SMETIO::getFormatting(const size_t& param, size_t& prec, size_t& width)
void SMETIO::getFormatting(const size_t& param, int& prec, int& width)
{
if ((param == MeteoData::TA) || (param == MeteoData::TSS) || (param == MeteoData::TSG)){
prec = 2;
......
......@@ -71,7 +71,7 @@ class SMETIO : public IOInterface {
bool checkConsistency(const std::vector<MeteoData>& vecMeteo, StationData& sd);
void checkForUsedParameters(const std::vector<MeteoData>& vecMeteo, double& timezone,
std::vector<bool>& vecParamInUse);
void getFormatting(const size_t& param, size_t& prec, size_t& width);
void getFormatting(const size_t& param, int& prec, int& width);
double olwr_to_tss(const double& olwr);
size_t nr_stations; //number of stations to read from
......
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