/* * Run StateMod for the provided dataset based on the run mode from the command line. * @param datasetToRun the dataset to run * @param runMode the run mode to execute */ public static void runStateMod(StateMod_DataSet datasetToRun, StateModRunModeType runMode) { // Create a StateMod simulator StateModRunner stateModRunner = new StateModRunner(datasetToRun); //TODO @jurentie 03/26/2019 - Need to figure out how to use enumeration classes for SateModRunMode /*if (runMode == StateModRunModeType.BASEFLOWS) * { * stateModRunner.RunBaseflows(); * } * else if (runMode == StateModRunModeType.CHECK) * { * stateModRunner.RunCheck(); * } * else if (runMode == StateModRunModeType.SIMULATE) * { * stateModRunner.RunSimulation(); * }*/ }
/** * Parse command line arguments. * @param args command line arguments * @param initialChecks if true, only parse arguments relevant to initialization. * If false, parse arguments relevant to dataset and simulation. */ public static void parseArgs(string[] args, Boolean initialChecks) { // Loop through the arguments twice // - the first pass is concerned only with determining the response file and working directory // so that the log file can be opened, and some trivial actions like printing usage and version // - the second pass processes all the other arguments int ipassToCheck = 0; if (initialChecks) { // Only check command line arguments that result in immediate action (usage, version) and // determine the response file and working directory ipassToCheck = 0; } else { // Else pass all other command line arguments // - currently nothing defined but when enabled will be able to set on the dataset object ipassToCheck = 1; } for (int ipass = 0; ipass < 2; ipass++) { for (int i = 0; i < args.Length; i++) { if (args[i].Equals("-baseflows", StringComparison.InvariantCultureIgnoreCase) || args[i].Equals("--baseflows", StringComparison.InvariantCultureIgnoreCase)) { //TODO @jurentie 03/26/2019 - Need to figure out how to use enumeration classes for SateModRunMode runMode = StateModRunModeType.BASEFLOWS; } else if (args[i].Equals("-check", StringComparison.InvariantCultureIgnoreCase) || args[i].Equals("--check", StringComparison.InvariantCultureIgnoreCase)) { //TODO @jurentie 03/26/2019 - Need to figure out how to use enumeration classes for SateModRunMode runMode = StateModRunModeType.CHECK; } else if ((ipass == ipassToCheck) && (args[i].Equals("-h", StringComparison.InvariantCultureIgnoreCase) || args[i].Equals("--help", StringComparison.InvariantCultureIgnoreCase))) { // Print the version information printUsage(); quitProgram(0); } else if ((args[i].Equals("-sim", StringComparison.InvariantCultureIgnoreCase) || args[i].Equals("--sim", StringComparison.InvariantCultureIgnoreCase))) { //TODO @jurentie 03/26/2019 - Need to figure out how to use enumeration classes for SateModRunMode runMode = StateModRunModeType.SIMULATE; } else if (args[i].Equals("-v", StringComparison.InvariantCultureIgnoreCase) || args[i].Equals("--version", StringComparison.InvariantCultureIgnoreCase)) { // Print the version information printVersion(); quitProgram(0); } else if (args[i].StartsWith("-")) { // Unrecognized option Console.WriteLine("Unrecognized option \"" + args[i] + "\""); printUsage(); quitProgram(1); } else if (ipass == ipassToCheck) { // The "response file" that contains a list of all StateMod input files - allow it // to include .rsp or not on command line setResponseFile(args[i]); } } } }