Skip to content
Snippets Groups Projects
Commit 1f03d8ad authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

fixed use of wrong HAVE_ for memory streams, improved error handling

parent 566c28a5
No related branches found
No related tags found
1 merge request!312CMake Improvements and fixes
...@@ -8,6 +8,10 @@ include(CheckIncludeFileCXX) ...@@ -8,6 +8,10 @@ include(CheckIncludeFileCXX)
include(CheckIncludeFiles) include(CheckIncludeFiles)
include(CMakePrintHelpers) include(CMakePrintHelpers)
add_library(cdolib)
add_library(operators)
add_executable(cdo)
# --- Language Standards # --- Language Standards
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
...@@ -21,9 +25,9 @@ configure_file ( ...@@ -21,9 +25,9 @@ configure_file (
"${PROJECT_SOURCE_DIR}/cmake/cdo_config_features.h.in" "${PROJECT_SOURCE_DIR}/cmake/cdo_config_features.h.in"
"${PROJECT_BINARY_DIR}/src/cdo_config_features.h" "${PROJECT_BINARY_DIR}/src/cdo_config_features.h"
) )
# --- Other compile definitions currently required TEMP # --- Other compile definitions currently required TEMP
list(APPEND cdo_compile_definitions list(APPEND cdo_compile_definitions
restrict= restrict=
CDI_SIZE_TYPE=size_t #size type for cdi, in cdo its size_t CDI_SIZE_TYPE=size_t #size type for cdi, in cdo its size_t
YAC_FOR_CDO YAC_FOR_CDO
HAVE_CONFIG_H=1 HAVE_CONFIG_H=1
...@@ -83,6 +87,8 @@ find_package(netCDF 4.0 REQUIRED) ...@@ -83,6 +87,8 @@ find_package(netCDF 4.0 REQUIRED)
if (TARGET netCDF::netcdf) if (TARGET netCDF::netcdf)
message(DEBUG "Checking for netCDF_HAS_NC4 flag equal 'yes' : flag is: ${netCDF_HAS_NC4}") message(DEBUG "Checking for netCDF_HAS_NC4 flag equal 'yes' : flag is: ${netCDF_HAS_NC4}")
list(APPEND cdo_compile_definitions HAVE_NETCDF=${netCDF_FOUND}) list(APPEND cdo_compile_definitions HAVE_NETCDF=${netCDF_FOUND})
list(APPEND cdo_compile_definitions HAVE_LIBNETCDF=${netCDF_FOUND})
list(APPEND cdo_compile_definitions HAVE_NETCDF4=${netCDF_FOUND})
else() else()
message(WARNING "Netcdf not found, compiling without netcdf") message(WARNING "Netcdf not found, compiling without netcdf")
endif () endif ()
...@@ -98,6 +104,7 @@ if(CMOR_ROOT) ...@@ -98,6 +104,7 @@ if(CMOR_ROOT)
find_package(CMOR) find_package(CMOR)
if(TARGET CMOR::CMOR) if(TARGET CMOR::CMOR)
list(APPEND cdo_compile_definitions "HAVE_LIBCMOR=1") list(APPEND cdo_compile_definitions "HAVE_LIBCMOR=1")
target_link_libraries(operators PUBLIC CMOR::CMOR Uuid::uuid json-c Udunits)
endif() endif()
endif() endif()
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <pthread.h> #include <pthread.h>
#endif #endif
#ifdef HAVE_LIBNETCDF #ifdef HAVE_NETCDF
#include <netcdf.h> #include <netcdf.h>
#include <netcdf_mem.h> #include <netcdf_mem.h>
#endif #endif
...@@ -306,7 +306,7 @@ Process::create_output() ...@@ -306,7 +306,7 @@ Process::create_output()
{ {
int ncid = -1; int ncid = -1;
#ifdef HAVE_LIBNETCDF #ifdef HAVE_NETCDF
if (auto retVal = nc_create_mem("test_name", 0, 4096, &ncid)) if (auto retVal = nc_create_mem("test_name", 0, 4096, &ncid))
{ {
printf("Error: %s\n", nc_strerror(retVal)); printf("Error: %s\n", nc_strerror(retVal));
...@@ -316,10 +316,14 @@ Process::create_output() ...@@ -316,10 +316,14 @@ Process::create_output()
int streamID = streamOpenWriteNCMem(ncid); int streamID = streamOpenWriteNCMem(ncid);
#else #else
int streamID = -1; int streamID = -100103;
#endif #endif
if (streamID < 0) { throw std::runtime_error("ERROR: could not open stream from memory"); }
std::stringstream ss = std::stringstream();
ss << "ERROR: could not open output stream to memory: errcode: ";
ss << std::to_string(streamID);
if (streamID < 0) { throw std::runtime_error(ss.str());}
return { ncid, streamID }; return { ncid, streamID };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment