Ejemplo n.º 1
0
 /*@@
   @routine    CCTKi_CommandLineErrorLevel
   @date       Wed Feb 17 00:58:56 1999
   @author     Tom Goodale
   @desc
               Sets the CCTK error level from a command line argument.
   @enddesc
   @calls      CCTKi_SetErrorLevel
               CCTKi_CommandLineUsage

   @var        argument
   @vdesc      option argument
   @vtype      const char *
   @vio        in
   @endvar
@@*/
void CCTKi_CommandLineErrorLevel (const char *argument)
{
  char *endptr;
  long int errorlevel;


  errorlevel = strtol (argument, &endptr, 10);
  if (endptr && *endptr == 0)
  {
    CCTKi_SetErrorLevel (errorlevel);
  }
  else
  {
    CCTKi_CommandLineUsage ();
  }
}
Ejemplo n.º 2
0
/*@@
   @routine    CCTKi_CommandLineWarningLevel
   @date       Wed Feb 17 00:58:56 1999
   @author     Tom Goodale
   @desc
               Sets the CCTK warning level from a command line argument.
   @enddesc
   @calls      CCTKi_SetWarningLevel
               CCTKi_CommandLineUsage

   @var        argument
   @vdesc      option argument
   @vtype      const char *
   @vio        in
   @endvar
@@*/
void CCTKi_CommandLineWarningLevel (const char *argument)
{
  char *endptr;
  long int warninglevel;


  warninglevel = strtol (argument, &endptr, 10);
  if (endptr && *endptr == 0)
  {
    CCTKi_SetWarnLevel (warninglevel);
  }
  else
  {
    CCTKi_CommandLineUsage ();
  }
}
Ejemplo n.º 3
0
 /*@@
   @routine    CCTKi_CommandLineTestParameters
   @date       Tue Apr 18 15:00:45 2000
   @author     Tom Goodale
   @desc

   @enddesc
   @calls      CCTKi_CommandLineUsage

   @var        argument
   @vdesc      option argument
   @vtype      const char *
   @vio        in
   @endvar
@@*/
void CCTKi_CommandLineTestParameters (const char *argument)
{
  int nprocs;
  char *endptr;


  if (argument == NULL)
  {
    nprocs = 1;
  }
  else
  {
    nprocs = strtol (argument, &endptr, 10);
    if (! (endptr && *endptr == 0))
    {
      CCTKi_CommandLineUsage ();
    }
  }

  paramchecking = 1;
  cctki_paramchecking = 1;
  cctki_paramcheck_nprocs = nprocs;
}
Ejemplo n.º 4
0
 /*@@
   @routine    CCTKi_ProcessCommandLine
   @date       Thu Sep 24 10:33:31 1998
   @author     Tom Goodale
   @desc 
   Processes the command line arguments.
   @enddesc 
   @calls    CCTKi_CommandLineTestThornCompiled CCTKi_CommandLineDescribeAllParameters CCTKi_CommandLineDescribeParameter CCTKi_CommandLineTestParameters CCTKi_CommandLineWarningLevel CCTKi_CommandLineErrorLevel CCTKi_CommandLineParameterLevel CCTKi_CommandLineRedirectStdout CCTKi_CommandLineListThorns() CCTKi_CommandLineVersion() CCTKi_CommandLineHelp
   @calledby   
   @history 
 
   @endhistory 
   @var     inargc
   @vdesc   Number of runtime arguments
   @vtype   int *
   @vio     inout
   @vcomment 
 
   @endvar 
   @var     inargv
   @vdesc   Command line arguments
   @vtype   char ***
   @vio     inout
   @vcomment 
 
   @endvar 
   @var     ConfigData
   @vdesc   Flesh configuration data
   @vtype   tFleshConfig
   @vio     inout
   @vcomment 
 
   @endvar 

   @returntype int
   @returndesc
   0 -- success
   @endreturndesc

@@*/
int CCTKi_ProcessCommandLine(int *inargc, char ***inargv, tFleshConfig *ConfigData)
{

  int option_index = 0;
  int c;
  int ignore;

  /* Store the command line */
  argc = *inargc;

  argv = *inargv;

  ignore = 0;

  /* Process the command line - needs some work !*/

  if(argc>1)
  {
    while (1)
    {
      struct option long_options[] =
      {
        {"help", no_argument, NULL, 'h'},
        {"describe-all-parameters", optional_argument, NULL, 'O'},
        {"describe-parameter",      required_argument, NULL, 'o'},
        {"test-parameters",         optional_argument, NULL, 'x'},
        {"warning-level",           required_argument, NULL, 'W'},
        {"error-level",             required_argument, NULL, 'E'},
        {"parameter-level",         required_argument, NULL, 256},
        {"redirect-stdout",         no_argument,       NULL, 'r'},
        {"list-thorns",             no_argument,       NULL, 'T'},
        {"test-thorn-compiled",     required_argument, NULL, 't'},
        {"version",                 no_argument,       NULL, 'v'},
        {"ignore-next",             no_argument,       NULL, 'i'},
        {0, 0, 0, 0}
      };
      
      c = getopt_long_only (argc, argv, "hO::o:x::W:E:rTt:vi",
                            long_options, &option_index);
      if (c == -1)
        break;
  
      if(!ignore)
      {
        switch (c)
        {
          case 't': CCTKi_CommandLineTestThornCompiled(optarg); break;
          case 'O': CCTKi_CommandLineDescribeAllParameters(optarg); break;
          case 'o': CCTKi_CommandLineDescribeParameter(optarg); break;
          case 'x': CCTKi_CommandLineTestParameters(optarg); break;
          case 'W': CCTKi_CommandLineWarningLevel(optarg); break;
          case 'E': CCTKi_CommandLineErrorLevel(optarg); break;
          case 256: CCTKi_CommandLineParameterLevel(optarg); break;
          case 'r': CCTKi_CommandLineRedirectStdout(); break;
          case 'T': CCTKi_CommandLineListThorns(); break;
          case 'v': CCTKi_CommandLineVersion(); break;
          case 'i': ignore = 1; break;
          case 'h': 
          case '?':
            CCTKi_CommandLineHelp(); break;
          default:
            printf ("?? getopt returned character code 0%o ??\n", c);
        }
      }
      else
      {
        printf("Ignoring option\n");
        ignore = 0;
      }
    }

    if(argc > optind)
    {
      ConfigData->parameter_file_name = argv[optind];
      parameter_file_name = ConfigData->parameter_file_name;
    }
    else
    {
      CCTKi_CommandLineUsage();
    }
  }
  else
  {
    CCTKi_CommandLineUsage();
  }

  CCTKi_CommandLineFinished();

  return 0;
}