WSL/SLF GitLab Repository

Commit 8862b535 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The POPC compilation is slowly improving... One still needs to force the...

The POPC compilation is slowly improving... One still needs to force the compiler to popcc, but otherwise it seems to work. Necessary includes have been added when popc is activated. A cmake method for finding popc has been implemented.

Small optimization/clean up in A3DIO for special points reading.
parent bf5a2508
......@@ -99,6 +99,8 @@ IF(DEST STREQUAL "optimized")
SET(ARCH "${ARCH_OPTIM}")
ENDIF(DEST STREQUAL "optimized")
SET(POPC OFF CACHE BOOL "Compile for POPC ON or OFF")
###########################################################
#finally, SET compile flags
SET(CMAKE_CXX_FLAGS_RELEASE "${_VERSION} ${ARCH} ${OPTIM} ${CFLAGS} ${PLATFORM}" CACHE STRING "" FORCE)
......
......@@ -744,10 +744,8 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
void A3DIO::readSpecialPoints(std::vector<Coords>& pts)
{
std::string filename="", line_in="";
std::vector<std::string> tmpvec;
std::vector< std::pair<int,int> > mypts;
cfg.getValue("SPECIALPTSFILE", "Input", filename); // cout << tmp << endl;
cfg.getValue("SPECIALPTSFILE", "Input", filename);
if (!IOUtils::fileExists(filename)) {
throw FileNotFoundException(filename, AT);
}
......@@ -762,6 +760,7 @@ void A3DIO::readSpecialPoints(std::vector<Coords>& pts)
while (!fin.eof()) {
getline(fin, line_in, eoln);
std::vector<std::string> tmpvec;
if (IOUtils::readLineToVec(line_in, tmpvec)==2) { //Try to convert
int x, y;
......@@ -775,18 +774,12 @@ void A3DIO::readSpecialPoints(std::vector<Coords>& pts)
throw ConversionFailedException("Conversion of a value failed in " + filename + " line: " + line_in, AT);
}
std::pair<int,int> tmppair(x,y);
mypts.push_back(tmppair);
Coords tmp_pts;
tmp_pts.setGridIndex(x, y, IOUtils::inodata, false);
pts.push_back(tmp_pts);
}
}
cleanup();
//Now put everything into the output vector TODO: don't do any intermediate steps... copy directly into vector!
Coords tmp_pts;
for (size_t jj=0; jj<mypts.size(); jj++) {
tmp_pts.setGridIndex(mypts.at(jj).first, mypts.at(jj).second, IOUtils::inodata, false);
pts.push_back(tmp_pts);
}
}
int A3DIO::create1DFile(const std::vector< std::vector<MeteoData> >& data)
......
......@@ -55,67 +55,38 @@ SET(meteoio_sources
${meteofilters_sources}
)
if (DEST MATCHES "par")
SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc;ph;)
SET(meteoio_sources
marshal_meteoio.cc
IOHandler.ph
#IOManager.ph
${meteoio_sources}
)
SET_SOURCE_FILES_PROPERTIES( ${meteoio_sources} PROPERTIES LANGUAGE CXX )
SET_SOURCE_FILES_PROPERTIES( IOHandler.ph PROPERTIES KEEP_EXTENSION TRUE)
#SET_SOURCE_FILES_PROPERTIES( IOManager.ph PROPERTIES KEEP_EXTENSION TRUE)
IF(BUILD_STATIC_LIBS)
SET(STATICNAME ${PROJECT_NAME}_STATIC_par)
SET(STATICLIBNAME ${PROJECT_NAME}popc)
ADD_LIBRARY(${STATICNAME} STATIC ${meteoio_sources})
TARGET_LINK_LIBRARIES(${STATICNAME} ${LIBPROJ})
ENDIF(BUILD_STATIC_LIBS)
#SET(SHAREDNAME ${PROJECT_NAME}_par)
INCLUDE(CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER(popcc POPCC)
CMAKE_FORCE_CXX_COMPILER(popcc POPCC)
IF(POPC)
FIND_PACKAGE(Popc REQUIRED)
ADD_DEFINITIONS(-D_POPC_)
INCLUDE_DIRECTORIES(${Popc_INCLUDE_DIRS})
#TARGET_LINK_LIBRARIES(${STATICNAME} ${Popc_LIBRARIES} ${SHAREDNAME})
ENDIF(POPC)
ADD_CUSTOM_COMMAND(
OUTPUT "${PROJECT_SOURCE_DIR}/lib/PackMeteoIO.o"
COMMAND popcc -o ${PROJECT_SOURCE_DIR}/lib/PackMeteoIO.o -c ${PROJECT_SOURCE_DIR}/meteoio/PackMeteoIO.cc -I${PROJECT_SOURCE_DIR} -combine -pipe "${ARCH} ${OPTIM} ${CFLAGS} ${PLATFORM} ${WARNINGS} ${EXTRA_WARNINGS}"
DEPENDS ${STATICNAME}
)
ADD_CUSTOM_COMMAND(
OUTPUT "${PROJECT_SOURCE_DIR}/lib/meteoio.module"
COMMAND popcc -object -parocld=c++ -o ${PROJECT_SOURCE_DIR}/lib/meteoio.module ${PROJECT_SOURCE_DIR}/lib/PackMeteoIO.o -L${PROJECT_SOURCE_DIR}/lib -lmeteoiopopc -rdynamic -lc -ldl -lm -lstdc++ ${LIBPROJ}
DEPENDS ${STATICNAME} ${PROJECT_SOURCE_DIR}/lib/PackMeteoIO.o
)
ADD_CUSTOM_TARGET(weirdstuff ALL DEPENDS lib/meteoio.module)
ELSE(DEST MATCHES "par")
IF(BUILD_STATIC_LIBS)
SET(STATICNAME ${PROJECT_NAME}_STATIC)
SET(STATICLIBNAME ${PROJECT_NAME})
ADD_LIBRARY(${STATICNAME} STATIC ${meteoio_sources})
TARGET_LINK_LIBRARIES(${STATICNAME} ${LIBPROJ})
ENDIF(BUILD_STATIC_LIBS)
IF(BUILD_STATIC_LIBS)
SET(STATICNAME ${PROJECT_NAME}_STATIC)
SET(STATICLIBNAME ${PROJECT_NAME})
ADD_LIBRARY(${STATICNAME} STATIC ${meteoio_sources})
TARGET_LINK_LIBRARIES(${STATICNAME} ${LIBPROJ} ${Popc_LIBRARIES})
ENDIF(BUILD_STATIC_LIBS)
SET(SHAREDNAME ${PROJECT_NAME})
ADD_LIBRARY(${SHAREDNAME} ${meteoio_sources})
TARGET_LINK_LIBRARIES(${SHAREDNAME} ${LIBPROJ})
SET_TARGET_PROPERTIES(${SHAREDNAME} PROPERTIES
PREFIX "${LIBPREFIX}"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
CLEAN_DIRECT_OUTPUT 1
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
SOVERSION "${VERSION_MAJOR}"
)
INSTALL(TARGETS ${SHAREDNAME}
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT libraries
)
ENDIF(DEST MATCHES "par")
SET(SHAREDNAME ${PROJECT_NAME})
ADD_LIBRARY(${SHAREDNAME} ${meteoio_sources})
TARGET_LINK_LIBRARIES(${SHAREDNAME} ${LIBPROJ} ${Popc_LIBRARIES})
SET_TARGET_PROPERTIES(${SHAREDNAME} PROPERTIES
PREFIX "${LIBPREFIX}"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
CLEAN_DIRECT_OUTPUT 1
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
SOVERSION "${VERSION_MAJOR}"
)
INSTALL(TARGETS ${SHAREDNAME}
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT libraries
)
#static library. Please keep in mind that for Windows, a dll is a runtime
IF(BUILD_STATIC_LIBS)
......
......@@ -50,6 +50,7 @@ namespace mio {
class ConfigProxy;
#ifdef _POPC_
#include <paroc_base.h>
class Config : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
......
......@@ -44,6 +44,7 @@ typedef void(Coords::*convfunc)(double, double, double&, double&) const;
*/
#ifdef _POPC_
#include <paroc_base.h>
class Coords : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
......
......@@ -58,6 +58,7 @@ namespace mio {
*/
#ifdef _POPC_
#include <paroc_base.h>
class DateDummy {}; //HACK for POPC
class Date : POPBase {
......
......@@ -37,6 +37,7 @@ namespace mio {
*/
#ifdef _POPC_
#include <paroc_base.h>
class Grid2DObjetctDummy {}; //HACK for POPC
class Grid2DObject : POPBase {
......
......@@ -37,6 +37,7 @@ namespace mio {
*/
#ifdef _POPC_
#include <paroc_base.h>
class Grid3DObjetctDummy {}; //HACK for POPC
class Grid3DObject : POPBase {
......
......@@ -41,6 +41,7 @@ namespace mio {
*/
#ifdef _POPC_
#include <paroc_exception.h>
class IOException : public POPException {
#else
class IOException : public std::exception {
......
......@@ -93,6 +93,7 @@ class IOManager; //forward declaration
*/
#ifdef _POPC_
#include <paroc_base.h>
class Meteo2DInterpolator : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
......
......@@ -87,6 +87,7 @@ class MeteoGrids {
*/
#ifdef _POPC_
#include <paroc_base.h>
class MeteoData : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
......
......@@ -38,6 +38,7 @@ namespace mio {
*/
#ifdef _POPC_
#include <paroc_base.h>
class StationData :POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
......@@ -75,7 +76,7 @@ class StationData {
* @return azimuth of the local slope expressed as a bearing (0 is North, in degrees, clockwise)
*/
double getAzimuth() const;
/**
* @brief General setter function
* @param i_position Position of the station
......@@ -103,7 +104,7 @@ class StationData {
bool operator!=(const StationData&) const; ///<Operator that tests for inequality
/**
* @brief Simple merge strategy.
* @brief Simple merge strategy.
* If some fields of the first argument are empty, they will be filled by the macthing field from the
* second argument.
* @param sd1 first StationData to merge, highest priority
......@@ -113,7 +114,7 @@ class StationData {
static StationData merge(const StationData& sd1, const StationData& sd2);
/**
* @brief Simple merge strategy.
* @brief Simple merge strategy.
* If some fields of the current object are empty, they will be filled by the macthing field from the
* provided argument.
* @param sd2 extra StationData to merge, lowest priority
......
......@@ -30,6 +30,9 @@
#include <vector>
#include <string>
#include <paroc_memspool.h>
#include <paroc_buffer.h>
namespace mio {
typedef Array2D<double> DOUBLE2D; //HACK for POPC
......
......@@ -705,10 +705,63 @@ bool SMETIO::checkConsistency(const std::vector<MeteoData>& vecMeteo, StationDat
return true;
}
void SMETIO::readSpecialPoints(std::vector<Coords>&)
void SMETIO::readSpecialPoints(std::vector<Coords>& pts)
{
//Nothing so far
//The code below is not valid yet, due to issues with libsmet -> invalid this method
throw IOException("Nothing implemented here", AT);
std::string filename="", line_in="";
cfg.getValue("SPECIALPTSFILE", "Input", filename);
if (!IOUtils::fileExists(filename)) {
throw FileNotFoundException(filename, AT);
}
smet::SMETReader myreader(filename);
vector<double> vec_data;
myreader.read(vec_data);
const size_t nr_fields = myreader.get_nr_of_fields();
const int epsg = myreader.get_header_intvalue("epsg");
const double smet_nodata = myreader.get_header_doublevalue("nodata");
if(myreader.location_in_data(smet::WGS84)==true) {
size_t lat_fd=IOUtils::unodata, lon_fd=IOUtils::unodata;
size_t alt_fd=IOUtils::unodata;
for(size_t ii=0; ii<nr_fields; ii++) {
const string tmp = myreader.get_field_name(ii);
if(tmp=="latitude") lat_fd=ii;
if(tmp=="longitude") lon_fd=ii;
if(tmp=="altitude") alt_fd=ii;
}
for(size_t ii=0; ii<vec_data.size(); ii+=nr_fields) {
Coords point;
point.setLatLon(vec_data[ii+lat_fd], vec_data[ii+lon_fd], vec_data[ii+alt_fd]);
pts.push_back(point);
}
} else if(myreader.location_in_data(smet::EPSG)==true) {
if(epsg==(int)floor(smet_nodata + 0.1))
throw InvalidFormatException("In file \""+filename+"\", missing EPSG code in header!", AT);
size_t east_fd=IOUtils::unodata, north_fd=IOUtils::unodata;
size_t alt_fd=IOUtils::unodata;
for(size_t ii=0; ii<nr_fields; ii++) {
const string tmp = myreader.get_field_name(ii);
if(tmp=="easting") east_fd=ii;
if(tmp=="northing") north_fd=ii;
if(tmp=="altitude") alt_fd=ii;
}
for(size_t ii=0; ii<vec_data.size(); ii+=nr_fields) {
Coords point;
point.setEPSG(epsg);
point.setXY(vec_data[ii+east_fd], vec_data[ii+north_fd], vec_data[ii+alt_fd]);
pts.push_back(point);
}
} else {
throw InvalidFormatException("File \""+filename+"\" does not contain expected location information in DATA section!", AT);
}
for(size_t ii=0; ii<pts.size(); ii++) {
std::cout << pts[ii] << "\n";
}
}
void SMETIO::write2DGrid(const Grid2DObject& /*grid_in*/, const std::string& /*name*/)
......
INCLUDE(LibFindMacros)
# Finally the library itself
FIND_LIBRARY(Popc_LIBRARY
NAMES libparoc_common.a
PATHS
ENV LD_LIBRARY_PATH
"~/usr/lib"
"/usr/local/lib"
"/usr/lib"
"/opt/lib"
DOC "Location of the libparoc_common, like /usr/lib/libparoc_common.a"
)
#build POPC_ROOT so we can provide a hint for searching for the header file
IF("${Popc_LIBRARY}" MATCHES "^(.+)lib[\\/]libparoc_common\\.(.+)$")
SET(POPC_ROOT "${CMAKE_MATCH_1}")
ENDIF("${Popc_LIBRARY}" MATCHES "^(.+)lib[\\/]libparoc_common\\.(.+)$")
# locate main header file
FIND_PATH(Popc_INCLUDE_DIR
NAMES paroc_base.h
#HINTS ${POPC_ROOT}/include
PATHS
"${POPC_ROOT}/include"
"~/usr/include"
"/usr/local/include"
"/usr/include"
"/opt/include"
DOC "Location of the popc headers, like /usr/include"
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
SET(Popc_PROCESS_INCLUDES Popc_INCLUDE_DIR)
SET(Popc_PROCESS_LIBS Popc_LIBRARY)
libfind_process(Popc)
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