Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit a9ddc18c authored by Christof Metzger-Kraus's avatar Christof Metzger-Kraus
Browse files

adding stand-alone SDDS reader. Not doing much yet

parent 15155025
No related branches found
No related tags found
No related merge requests found
......@@ -5,4 +5,6 @@ FIND_PACKAGE(SDDS)
IF(SDDS_FOUND)
ADD_SUBDIRECTORY(sdds2opal)
ADD_SUBDIRECTORY(opal2sdds)
ENDIF(SDDS_FOUND)
\ No newline at end of file
ENDIF(SDDS_FOUND)
ADD_SUBDIRECTORY(SDDSReader)
\ No newline at end of file
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.10)
PROJECT (StandAloneSDDSReader)
SET (StandAloneSDDSReader_VERSION_MAJOR 0)
SET (StandAloneSDDSReader_VERSION_MINOR 1)
configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
set (CMAKE_CXX_FLAGS
"${IPPL_CMAKE_CXX_FLAGS} -DPARALLEL_IO ${CMAKE_CXX_FLAGS}"
)
SET (PARSERPATH "${CMAKE_SOURCE_DIR}/src/Structure")
INCLUDE_DIRECTORIES (
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/Classic
)
SET (SRCS
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/array.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/associate.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/ast.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/column.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/data.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/description.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/file.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/include.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/parameter.cpp
${CMAKE_SOURCE_DIR}/src/Structure/SDDSParser/version.cpp
${CMAKE_SOURCE_DIR}/src/Utilities/OpalException.cpp
${CMAKE_SOURCE_DIR}/src/Classic/Utilities/ClassicException.cpp
)
SET (LIBS
${Boost_LIBRARIES}
${MPI_LIBRARIES}
z
dl
)
ADD_EXECUTABLE( SDDSReader main.cpp ${SRCS})
TARGET_LINK_LIBRARIES( SDDSReader ${LIBS} )
INSTALL(TARGETS SDDSReader RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
\ No newline at end of file
#define VERSION_MAJOR ${StandAloneSDDSReader_VERSION_MAJOR}
#define VERSION_MINOR ${StandAloneSDDSReader_VERSION_MINOR}
\ No newline at end of file
#include "config.h"
#include "Structure/SDDSParser.h"
#include <string>
#include <vector>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <cstdio>
void printInfo(const std::string &input);
void printUsage(char **argv);
int main(int argc, char **argv) {
std::string inputFile(""), outputFile("/dev/stdout");
if (argc == 1) {
printUsage(argv);
return 0;
}
if (argc == 2 && std::string(argv[1]).substr(0, 2) != "--") {
inputFile = std::string(argv[1]);
} else {
for (int i = 1; i < argc; ++ i) {
if (std::string(argv[i]) == "--input" && i + 1 < argc) {
inputFile = std::string(argv[++ i]);
} else if (std::string(argv[i]) == "--output" && i + 1 < argc) {
outputFile = std::string(argv[++ i]);
} else if (std::string(argv[i]) == "--help") {
printUsage(argv);
return 0;
} else {
inputFile = std::string(argv[i]);
}
}
}
if (inputFile == "") {
std::cerr << "Error: no input file provided!\n" << std::endl;
printUsage(argv);
return 1;
}
SDDS::SDDSParser parser;
try {
parser.setInput(inputFile);
parser.run();
} catch (OpalException ex) {
std::cerr << ex.where() << "\n"
<< ex.what() << std::endl;
return 1;
}
double mins = 0.0, maxs = 0.0;
try {
auto sdata = parser.getColumnData("s");
mins = boost::get<double>(sdata.front());
maxs = boost::get<double>(sdata.back());
} catch (OpalException ex) {
std::cerr << ex.where() << "\n"
<< ex.what() << std::endl;
return 1;
}
std::cout << "data range: [" << mins << " m, " << maxs << " m]" << std::endl;
return 0;
}
void printUsage(char **argv) {
std::string name(argv[0]), indent(" ");
name = name.substr(name.find_last_of('/') + 1);
unsigned int width = 25;
std::cout << name << " version " << VERSION_MAJOR << "." << VERSION_MINOR << "\n"
<< "Usage\n\n"
<< indent << name << " [options] <path to input>\n\n"
<< "Options\n\n"
<< indent << std::setw(width) << std::left << "--input <path to input>" << "= path to input file\n"
<< indent << std::setw(width) << std::left << "--output <file name>" << "= name of output. If omitted, directed\n"
<< indent << std::setw(width + 2) << " " << "to stdout\n"
<< indent << std::setw(width) << std::left << "--step <step number>" << "= step of the H5Hut file that should be\n"
<< indent << std::setw(width + 2) << " " << "exported. Default: last step\n"
<< indent << std::setw(width) << std::left << "--binary" << "= whether SDDS output should be in \n"
<< indent << std::setw(width + 2) << std::left << " " << "binary format. Default: ASCII\n"
<< indent << std::setw(width) << std::left << "--info" << "= printing path length corresponding to step\n"
<< indent << std::setw(width) << std::left << "--help" << "= this help\n"
<< std::endl;
}
\ No newline at end of file
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