190 {
191 TRACE();
192
193#if defined(MAIA_MS_COMPILER) || defined(_SX)
194#pragma message("WARNING: Not implemented!")
195#else
196 opterr = 0;
197 while(true) {
198 int c = 0;
199 DIR* directory = nullptr;
200 string inputDirectory;
201 string outputDirectory;
202 int option_index = 0;
203 static option long_options[] = {
204 {"debug", 1, 0, 'd'}, {"help", 0, 0, 'h'}, {"input", 1, 0, 'i'}, {"output", 1, 0, 'o'},
205 {"version", 0, 0, 'v'}, {"compiler", 0, 0, 'c'}, {"build-type", 0, 0, 'b'}, {0, 0, 0, 0}};
206
207 c = getopt_long(
m_argc,
m_argv,
"d:hi:o:p:vcb", long_options, &option_index);
208 if(c == -1) {
209 break;
210 }
211
212 switch(c) {
213 case 0:
214 cout << "option " << long_options[option_index].name << endl;
215 if(optarg != nullptr) cout << "with arg " << optarg << endl;
216 cout << endl;
217 break;
218
219 case 'd':
223 cout << "SET DEBUG LEVEL TO: " << atoi(optarg) << endl;
224 }
225 m_log <<
"SET DEBUG LEVEL TO: " << atoi(optarg) << endl;
226 DEBUG("Environment::parseCommandline: option -d " << atoi(optarg), MAIA_DEBUG_IO);
227 } else {
228 cerr << "Error: debug level out of range!" << endl;
229 cerr << "Specified debug level is " << atoi(optarg) << ", but must be in the range of " << endl;
231 cerr << "Debug level is unchanged" << endl;
232 return;
233 }
234 break;
235
236 case 'h':
237 cout <<
"usage: " <<
m_argv[0] <<
" [-h] [-b] [-c] [--debug LEVEL] [--input DIRECTORY] "
238 << "[--output DIRECTORY] [-v] [PROPERTY_FILE]" << endl
239 << endl
240 << "positional arguments:" << endl
241 <<
" PROPERTY_FILE name of property file to use (default: '" <<
m_propertyFileInput <<
"')\n"
242 << endl
243 << "optional arguments:\n"
244 << " -b, --build-type show build type that was used\n"
245 << " -c, --compiler show used compiler\n"
246 << " -d, --debug LEVEL use specified debug level\n"
247 << " -h, --help this help screen\n"
248 << " -i, --input DIRECTORY specified directory is used for all "
249 "input files\n"
250 << " -o, --output DIRECTORY specified directory is used for all "
251 "output files\n"
252 << " -v, --version show MAIA version\n"
253 << endl;
256 MPI_Finalize();
257 exit(0);
258 break;
259
260 case 'i':
261 directory = opendir(optarg);
262 if(directory != nullptr) {
263 closedir(directory);
264 inputDirectory.append(optarg);
265 DEBUG("Environment::parseCommandline: option -i " << optarg, MAIA_DEBUG_IO);
266 } else {
267 stringstream errorMessage;
268 errorMessage << " error opening inputDirectory \"" << optarg << "\"!" << endl;
269 mTerm(1, AT_, errorMessage.str());
270 }
271 break;
272
273 case 'o':
274 directory = opendir(optarg);
275 if(directory != nullptr) {
276 closedir(directory);
277 outputDirectory.append(optarg);
278 DEBUG("Environment::parseCommandline: option -o " << optarg, MAIA_DEBUG_IO);
279 } else {
280 stringstream errorMessage;
281 errorMessage << "Error opening outputDirectory \"" << optarg << "\"!";
282 mTerm(1, AT_, errorMessage.str());
283 }
284 break;
285
286 case 'v':
287
288#ifndef MAIA_VERSION_STRING
289#define MAIA_VERSION_STRING unknown
290#endif
291 cout << XSTRINGIFY(MAIA_VERSION_STRING) << endl;
294 MPI_Finalize();
295 exit(0);
296 break;
297
298 case 'c':
299
300#ifndef MAIA_COMPILER_STRING
301#define MAIA_COMPILER_STRING unknown
302#endif
303 cout << XSTRINGIFY(MAIA_COMPILER_STRING) << endl;
306 MPI_Finalize();
307 exit(0);
308 break;
309
310 case 'b':
311
312#ifndef MAIA_BUILD_TYPE_STRING
313#define MAIA_BUILD_TYPE_STRING unknown
314#endif
315 cout << XSTRINGIFY(MAIA_BUILD_TYPE_STRING) << endl;
318 MPI_Finalize();
319 exit(0);
320 break;
321
322 case '?':
323 break;
324
325 default:
326 cerr << "Environment::parseCommandline: Error getopt returned "
327 "unkown option code \""
328 << c << "\"" << endl;
329 }
330 }
331
332
335 }
336
339 }
340#endif
341}
MString m_propertyFileInput
static MInt m_argc
Reads the name of the property-file and creates a new Application.
void close(MBool forceClose=false)
Pass the close call to the respective internal buffer.
static const MInt m_minLevel
static const MInt m_maxLevel
enum { MAIA_DEBUG_ASSERTION=1, MAIA_DEBUG_IO=2, MAIA_DEBUG_ALLOCATION=4, MAIA_DEBUG_TRACE=8, MAIA_DEBUG_TRACE_IN=16, MAIA_DEBUG_TRACE_OUT=32, MAIA_DEBUG_LEVEL1=64, MAIA_DEBUG_LEVEL2=128, MAIA_DEBUG_LEVEL3=256, MAIA_DEBUG_LEVEL4=512, MAIA_DEBUG_LEVEL5=1024, MAIA_DEBUG_USER1=2048, MAIA_DEBUG_USER2=4096, MAIA_DEBUG_USER3=8192, MAIA_DEBUG_USER4=16384, MAIA_DEBUG_USER5=32768 } MDebugLevel
This enum holds the error levels of the DEBUG class.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
MInt globalDomainId()
Return global domain id.