Commit 5f2e54d6 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

added options for checking attributes, added use of new module_info files

parent 245e23f0
Pipeline #4947 passed with stages
in 16 minutes and 30 seconds
......@@ -54,6 +54,7 @@
#endif
#include "module_list.h"
#include "module_info.h"
#include "percentiles.h"
#include "util_wildcards.h"
#include "util_string.h"
......@@ -97,6 +98,7 @@ static int numThreads = 0;
static int timer_total;
static int CDO_netcdf_hdr_pad = 0;
static int CDO_Rusage = 0;
static bool applyDryRun = false;
extern "C" void streamGrbDefDataScanningMode(int scanmode);
......@@ -982,8 +984,10 @@ evaluateExpectOptions(const std::string &arg)
static int
parseOptionsLong(int argc, char *argv[])
{
int lprintoperators = 0;
int lprintoperatorsno = 0;
ModListOptions modListOpt;
int loperators_no = 0;
int lprintOperators = 0;
int attribRequest = 0;
int lprintVariableInputDesc = 0;
int lpedantic = 0;
// These variables must be initialized with each while loop run!
......@@ -1033,8 +1037,9 @@ parseOptionsLong(int argc, char *argv[])
{ "float" , no_argument , (int*)&Options::CDO_Memtype , (int)MemType::Float },
{ "double" , no_argument , (int*)&Options::CDO_Memtype , (int)MemType::Double },
{ "rusage" , no_argument , &CDO_Rusage , 1 },
{ "operators_no_output" , no_argument , &lprintoperatorsno , 1 },
{ "operators" , no_argument , &lprintoperators , 1 },
{ "attribs" , optional_argument , &attribRequest , 1 },
{ "operators" , no_argument , &lprintOperators , 1 },
{ "operators_no_output" , no_argument , &loperators_no , 1 },
{ "pedantic" , no_argument , &lpedantic , 1 },
{ "no_warnings" , no_argument , nullptr , 'w' },
{ "color" , required_argument , &lcolor , 'C' },
......@@ -1049,6 +1054,7 @@ parseOptionsLong(int argc, char *argv[])
{ "sort" , no_argument , nullptr , 'Q' },
{ "sortname" , no_argument , &lsortname , 1 },
{ "sortparam" , no_argument , &lsortparam , 1 },
{ "argumentGroups" , no_argument , &lprintVariableInputDesc , 1 },
{ "variableInput" , no_argument , &lprintVariableInputDesc , 1 },
{ "table" , required_argument , nullptr , 't' },
{ "verbose" , no_argument , nullptr , 'v' },
......@@ -1066,6 +1072,8 @@ parseOptionsLong(int argc, char *argv[])
{
// IMPORTANT: BY EVERY OPTION that takes arguments you MUST set its trigger variable to ZERO;
// otherwise the parameters of other options get wrongly assigned.
attribRequest = 0;
lprintOperators = 0;
lasync_worker = 0;
lcellsearchmethod = 0;
lcolor = 0;
......@@ -1104,7 +1112,17 @@ parseOptionsLong(int argc, char *argv[])
return -1;
// break;
case 0:
if (lnetcdf_hdr_pad)
if (loperators_no)
{
std::string request = "noOutput";
if(!modListOpt.parseRequest(request)){exit(EXIT_FAILURE);}
}
else if (attribRequest || lprintOperators)
{
std::string request = CDO_optarg ? CDO_optarg : "";
if(!modListOpt.parseRequest(request)){exit(EXIT_FAILURE);}
}
else if (lnetcdf_hdr_pad)
{
const int netcdf_hdr_pad = cstrToNumBytes(CDO_optarg);
if (netcdf_hdr_pad >= 0) CDO_netcdf_hdr_pad = netcdf_hdr_pad;
......@@ -1222,6 +1240,7 @@ parseOptionsLong(int argc, char *argv[])
}
#endif
break;
case 'A': applyDryRun = true; break;
case 'a': CdoDefault::TaxisType = TAXIS_ABSOLUTE; break;
case 'b': setDefaultDataType(CDO_optarg); break;
case 'C': evaluateColorOptions(CDO_optarg); break;
......@@ -1297,13 +1316,9 @@ parseOptionsLong(int argc, char *argv[])
MpMO::enablePedantic(true);
}
if (lprintoperators || lprintoperatorsno)
if (modListOpt.modInfoRequested())
{
set_text_color(stderr, GREEN);
const bool print_no_output = lprintoperatorsno > 0;
operatorPrintList(print_no_output);
// operatorPrintAll();
reset_text_color(stderr);
operatorPrintList(modListOpt);
return 1;
}
if (lprintVariableInputDesc)
......@@ -1820,19 +1835,7 @@ main(int argc, char *argv[])
if (numThreads > 1) fprintf(stderr, "Warning: Option -P failed, OpenMP support not compiled in!\n");
#endif
std::vector<std::string> new_argv(&argv[CDO_optind], argv + argc);
new_argv = expandWildCards(new_argv);
new_argv = expandApply(new_argv);
if (Options::cdoVerbose) std::cerr << argvToString(new_argv) << std::endl;
///*TEMP*/ // should not be needed when std::string is standard string
std::vector<char *> new_cargv(new_argv.size());
for (unsigned long i = 0; i < new_argv.size(); i++)
{
new_cargv[i] = strdup(new_argv[i].c_str());
}
// temprorary end
// temprorary end
if (CDO_optind >= argc)
{
if (!Version && !Help)
......@@ -1848,6 +1851,25 @@ main(int argc, char *argv[])
if (lstop) return status;
std::vector<std::string> new_argv(&argv[CDO_optind], argv + argc);
new_argv = expandWildCards(new_argv);
ApplyStatus expandSuccess;
new_argv = expandApply(new_argv, expandSuccess);
if (expandSuccess != ApplyStatus::OK) return -1;
if (applyDryRun == true || expandSuccess != ApplyStatus::OK)
{
std::cerr << argvToString(new_argv) << std::endl;
exit(applyDryRun ? 0 : -1);
}
///*TEMP*/ // should not be needed when std::string is standard string
std::vector<char *> new_cargv(new_argv.size());
for (unsigned long i = 0; i < new_argv.size(); i++)
{
new_cargv[i] = strdup(new_argv[i].c_str());
}
if (CdoDefault::TableID != CDI_UNDEFID) cdiDefTableID(CdoDefault::TableID);
set_external_proj_func();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment