diff --git a/CMakeLists.txt b/CMakeLists.txt index 598843c1..c40d60b9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(Boost_NO_WARN_NEW_VERSIONS ON) + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(MACOSX TRUE) set(CMAKE_FIND_FRAMEWORK LAST) # framework gdal, etc can end up superceeding other search paths diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 9cf1a61c..032af270 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -16,28 +16,19 @@ add_library(SNOWPACK OBJECT ${SNOWPACK_SRCS} ) - target_link_libraries(SNOWPACK PUBLIC - MeteoIO::MeteoIO - ) + MeteoIO::MeteoIO + Boost::headers + Boost::system + Boost::filesystem + Boost::date_time + Boost::log + Boost::thread + Boost::regex + Boost::iostreams + Boost::program_options +) -if(BUILD_WITH_CONAN) - target_link_libraries(SNOWPACK PUBLIC - Boost::Boost - ) -else() - target_link_libraries(SNOWPACK PUBLIC - Boost::headers - Boost::system - Boost::filesystem - Boost::date_time - Boost::log - Boost::thread - Boost::regex - Boost::iostreams - Boost::program_options - ) -endif() target_include_directories(SNOWPACK PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/ # needed for logger.hpp... that's a funny dependence, what is meant by "third party"? @@ -45,28 +36,26 @@ target_include_directories(SNOWPACK PUBLIC ################################### add_library(SNOBAL OBJECT - ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snobal/sno.cpp - ) + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snobal/sno.cpp +) target_link_libraries(SNOBAL PUBLIC - Func::Func - ) - - -if(BUILD_WITH_CONAN) - target_link_libraries(SNOBAL PUBLIC - Boost::Boost - ) -else() - target_link_libraries(SNOBAL PUBLIC - Boost::headers - Boost::log - ) + Func::Func + Boost::headers + Boost::log +) +if(OpenMP_FOUND) + target_link_libraries(SNOBAL PUBLIC OpenMP::OpenMP_CXX) endif() - target_include_directories(SNOBAL PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/ # needed for logger.hpp... that's a funny dependence ) +message(FATAL "${CHM_BUILD_FLAGS}") + +set_target_properties( SNOBAL + PROPERTIES + COMPILE_FLAGS ${CHM_BUILD_FLAGS}) + ################################### add_library(FSM OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/FSM/FSM2_CHM.f90 @@ -86,9 +75,7 @@ set(THIRD_PARTY_TARGETS set_target_properties( SNOWPACK PROPERTIES COMPILE_FLAGS ${CHM_BUILD_FLAGS}) -set_target_properties( SNOBAL - PROPERTIES - COMPILE_FLAGS ${CHM_BUILD_FLAGS}) + # third party includes in CHM src files to be specified relative to this directory FOREACH(target ${THIRD_PARTY_TARGETS}) diff --git a/third_party/snowpack/plugins/SnowpackIO.cc b/third_party/snowpack/plugins/SnowpackIO.cc deleted file mode 100644 index 460a9236..00000000 --- a/third_party/snowpack/plugins/SnowpackIO.cc +++ /dev/null @@ -1,248 +0,0 @@ -/* - * SNOWPACK stand-alone - * - * Copyright WSL Institute for Snow and Avalanche Research SLF, DAVOS, SWITZERLAND -*/ -/* This file is part of Snowpack. - Snowpack is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Snowpack is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Snowpack. If not, see . -*/ - -#include "SnowpackIO.h" - -#include "AsciiIO.h" -#include "SmetIO.h" - -/* #undef PLUGIN_IMISIO */ -/* #undef PLUGIN_CAAMLIO */ - -#ifdef PLUGIN_CAAMLIO - #include -#endif -#ifdef PLUGIN_IMISIO - #include -#endif - -using namespace std; -using namespace mio; - -SnowpackIO::SnowpackIO(const SnowpackConfig& cfg): - vecExtension(), imisdbio(NULL), caamlio(NULL), smetio(NULL), asciiio(NULL), - input_snow_as_smet(false), output_snow_as_smet(false), - input_snow_as_caaml(false), output_snow_as_caaml(false), - input_snow_as_ascii(false), output_snow_as_ascii(false), - output_prf_as_ascii(false), output_prf_as_caaml(false), output_prf_as_imis(false), - output_ts_as_ascii(false), output_ts_as_smet(false), output_haz_as_imis(false) - -{ - //Format of initial snow profile: - const string in_snow = cfg.get("SNOW", "Input"); - if (in_snow == "SNOOLD") { - input_snow_as_ascii = true; - } else if (in_snow == "CAAML") { - input_snow_as_caaml = true; - } else if (in_snow == "SMET") { - input_snow_as_smet = true; - } else - throw InvalidArgumentException("Invalid input snow profile format '"+in_snow+"'. Please choose from SMET, CAAML, SNOOLD", AT); - - //Format of transitional and final snow profile(s): - const string out_snow = cfg.get("SNOW", "Output"); - if (out_snow == "SNOOLD") { - output_snow_as_ascii = true; - vecExtension.push_back("snoold"); //Snow-cover profile file (I/O) - } else if (out_snow == "CAAML") { - output_snow_as_caaml = true; - vecExtension.push_back("haz"); //Snow-cover profile file (I/O) - vecExtension.push_back("caaml"); //Snow-cover profile file (I/O & SnopViz) - vecExtension.push_back("acaaml"); //Aggregated snow-cover profile file (I/O & SnopViz) - } else if (out_snow == "SMET") { - output_snow_as_smet = true; - vecExtension.push_back("haz"); //Snow-cover profile file (I/O) - vecExtension.push_back("sno"); //Snow-cover profile file (I/O) - } else - throw InvalidArgumentException("Invalid output snow profile format '"+out_snow+"'. Please choose from SMET, CAAML, SNOOLD", AT); - - std::vector vecProfileFmt = cfg.get("PROF_FORMAT", "Output"); - if (vecProfileFmt.size() > 3) { - throw InvalidArgumentException("The key PROF_FORMAT in [Output] can take three values at most", AT); - } else { - for (size_t ii=0; ii SnowpackIO::getExtensions() -{ - return vecExtension; -} - -bool SnowpackIO::snowCoverExists(const std::string& i_snowfile, const std::string& stationID) const -{ - if (input_snow_as_ascii) { - return asciiio->snowCoverExists(i_snowfile, stationID); -#ifdef PLUGIN_CAAMLIO - } else if (input_snow_as_caaml){ - return caamlio->snowCoverExists(i_snowfile, stationID); -#endif - } else { - return smetio->snowCoverExists(i_snowfile, stationID); - } -} - -void SnowpackIO::readSnowCover(const std::string& i_snowfile, const std::string& stationID, - SN_SNOWSOIL_DATA& SSdata, ZwischenData& Zdata) -{ - if (input_snow_as_ascii) { - asciiio->readSnowCover(i_snowfile, stationID, SSdata, Zdata); -#ifdef PLUGIN_CAAMLIO - } else if (input_snow_as_caaml) { - caamlio->readSnowCover(i_snowfile, stationID, SSdata, Zdata); -#endif - } else { - smetio->readSnowCover(i_snowfile, stationID, SSdata, Zdata); - } -} - -void SnowpackIO::writeSnowCover(const mio::Date& date, const SnowStation& Xdata, - const ZwischenData& Zdata, const bool& forbackup) -{ - if (output_snow_as_ascii) { - asciiio->writeSnowCover(date, Xdata, Zdata, forbackup); -#ifdef PLUGIN_CAAMLIO - } else if (output_snow_as_caaml) { - caamlio->writeSnowCover(date, Xdata, Zdata, forbackup); -#endif - } else { - smetio->writeSnowCover(date, Xdata, Zdata, forbackup); - } -} - -void SnowpackIO::writeTimeSeries(const SnowStation& Xdata, const SurfaceFluxes& Sdata, const CurrentMeteo& Mdata, - const ProcessDat& Hdata, const double wind_trans24) -{ - if (output_ts_as_ascii) - asciiio->writeTimeSeries(Xdata, Sdata, Mdata, Hdata, wind_trans24); - else if (output_ts_as_smet) - smetio->writeTimeSeries(Xdata, Sdata, Mdata, Hdata, wind_trans24); -} - -void SnowpackIO::writeProfile(const mio::Date& date, const SnowStation& Xdata) -{ - if (output_prf_as_ascii) - asciiio->writeProfile(date, Xdata); - -#ifdef PLUGIN_CAAMLIO - if (output_prf_as_caaml) - caamlio->writeProfile(date, Xdata); -#endif - -#ifdef PLUGIN_IMISIO - if (output_prf_as_imis) - imisdbio->writeProfile(date, Xdata); -#endif -} - -#ifdef PLUGIN_IMISIO -bool SnowpackIO::writeHazardData(const std::string& stationID, const std::vector& Hdata, - const std::vector& Hdata_ind, const size_t& num) -{ - if(output_haz_as_imis) - return imisdbio->writeHazardData(stationID, Hdata, Hdata_ind, num); - return false; -} -#else -bool SnowpackIO::writeHazardData(const std::string& /*stationID*/, const std::vector& /*Hdata*/, - const std::vector& /*Hdata_ind*/, const size_t& /*num*/) -{ - return false; -} -#endif - -SnowpackIO& SnowpackIO::operator=(const SnowpackIO& source) -{ - if(this != &source) { - imisdbio = source.imisdbio; - caamlio = source.caamlio; - asciiio = source.asciiio; - smetio = source.smetio; - output_prf_as_ascii = source.output_prf_as_ascii; - output_prf_as_caaml = source.output_prf_as_caaml; - output_prf_as_imis = source.output_prf_as_imis; - output_snow_as_caaml = source.output_snow_as_caaml; - output_snow_as_smet = source.output_snow_as_smet; - input_snow_as_caaml = source.input_snow_as_caaml; - input_snow_as_smet = source.input_snow_as_smet; - output_ts_as_ascii = source.output_ts_as_ascii; - output_haz_as_imis = source.output_haz_as_imis; - } - return *this; -}