preCICE v3.3.0
Loading...
Searching...
No Matches
validate.cpp
Go to the documentation of this file.
1#include <iostream>
3#include <precice/Tooling.hpp>
4#include <stdexcept>
5#include <string>
6
8{
9 std::cerr << "Usage:\n\n";
10 std::cerr << "precice-config-validate FILE [ PARTICIPANT [ COMMSIZE ] ]\n";
11}
12
13int main(int argc, char **argv)
14{
15 const int args = argc - 1;
16
17 if (args < 1 || args > 3) {
18 printUsage();
19 return 1;
20 }
21
22 using namespace precice::tooling;
23
24 std::string file(argv[1]);
25 std::string participant = (args > 1) ? std::string(argv[2]) : "";
26
27 int size = 1;
28 if (args == 3) {
29 try {
30 size = std::stoi(argv[3]);
31 } catch (std::invalid_argument &e) {
32 std::cerr << "ERROR: passed COMMSIZE is not a valid number\n";
33 printUsage();
34 return 1;
35 }
36 }
37
38 try {
39 precice::tooling::checkConfiguration(file, participant, size);
40 } catch (const ::precice::Error &) {
41 return 2;
42 }
43 return 0;
44}
Contains the preCICE tooling API.
Definition Tooling.cpp:13
void checkConfiguration(const std::string &filename, const std::string &participant, int size)
Checks a given configuration.
Definition Tooling.cpp:32
T stoi(T... args)
int main(int argc, char **argv)
Definition validate.cpp:13
void printUsage()
Definition validate.cpp:7