예제 #1
0
int
main(int argc, char *argv[])
{
    sparsegraph sg,sh,*this;
    int n,codetype;
    int argnum,i,j,outcode;
    char *arg,sw;
    boolean badargs;
    boolean sswitch,gswitch,qswitch,vswitch,xswitch,Xswitch;
    boolean pswitch,Lswitch,tswitch,yswitch,Yswitch;
    long Lvalue;
    double t;
    char *infilename,*outfilename;
    FILE *infile,*outfile;
    nauty_counter nin,nout;
    int status,xstatus,ystatus,tvalue,imin,imax;
    DYNALLSTAT(int,ham1,ham1_sz);
    DYNALLSTAT(int,ham2,ham2_sz);

    HELP;

    INITSEED;
    ran_init(seed);

    sswitch = gswitch = yswitch = qswitch = vswitch = FALSE;
    tswitch = xswitch = Xswitch = Lswitch = pswitch = FALSE;
    Yswitch = FALSE;
    infilename = outfilename = NULL;

    argnum = 0;
    badargs = FALSE;
    for (j = 1; !badargs && j < argc; ++j)
    {
        arg = argv[j];
        if (arg[0] == '-' && arg[1] != '\0')
        {
            ++arg;
            while (*arg != '\0')
            {
                sw = *arg++;
                     SWBOOLEAN('s',sswitch)
                else SWBOOLEAN('g',gswitch)
                else SWBOOLEAN('q',qswitch)
                else SWBOOLEAN('x',xswitch)
                else SWBOOLEAN('y',yswitch)
                else SWBOOLEAN('Y',Yswitch)
                else SWBOOLEAN('X',Xswitch)
                else SWBOOLEAN('v',vswitch)
		else SWBOOLEAN('p',pswitch)
		else SWLONG('L',Lswitch,Lvalue,"-L")
		else SWINT('t',tswitch,tvalue,"-t")
                else badargs = TRUE;
            }
        }
        else
        {
            ++argnum;
예제 #2
0
int
main(int argc, char *argv[])
{
    sparsegraph sg;
    int n,codetype;
    int argnum,i,j,outcode,tvalue;
    char *arg,sw;
    boolean badargs;
    boolean sswitch,gswitch,qswitch,Lswitch,tswitch,vswitch,uswitch;
    long Lvalue;
    double t;
    char *infilename,*outfilename;
    FILE *infile,*outfile;
    nauty_counter nin,nout,nNO,nYES,nTIMEOUT;
    int status;
    DYNALLSTAT(int,cyc,cyc_sz);

    HELP;

    INITSEED;
    ran_init(seed);

    uswitch = sswitch = gswitch = Lswitch = qswitch = vswitch = tswitch = FALSE;
    infilename = outfilename = NULL;

    argnum = 0;
    badargs = FALSE;
    for (j = 1; !badargs && j < argc; ++j)
    {
        arg = argv[j];
        if (arg[0] == '-' && arg[1] != '\0')
        {
            ++arg;
            while (*arg != '\0')
            {
                sw = *arg++;
                     SWBOOLEAN('s',sswitch)
                else SWBOOLEAN('g',gswitch)
                else SWBOOLEAN('u',uswitch)
                else SWBOOLEAN('q',qswitch)
                else SWBOOLEAN('v',vswitch)
		else SWLONG('L',Lswitch,Lvalue,"-L")
		else SWINT('t',tswitch,tvalue,"-t")
                else badargs = TRUE;
            }
        }
        else
        {
            ++argnum;
예제 #3
0
파일: main.c 프로젝트: TheJoris/Gillespie
/**
  Main program.
  @return error code or EXIT_SUCCESS if successful
*/
int main(int argc, char *argv[])
{
  int i;

  sys.input = NULL;
  sys.output = NULL;
  sys.needs_queue = FALSE;
  sys.volume = 1.;              // initial volume factor
  sys.doubling_time = -1;       // no growth at all
  sys.doubling_time_std = 0;    // the doubling time is exact
  sys.last_division = NAN;      // to distinguish from given division times
  sys.growth_type = GROWTH_EXPONENTIAL;
  sys.division_type = DIVIDE_HALF;
  sys.output_stats = FALSE;
  sys.output_conc = OUTPUT_AUTOMATIC;
  sys.output_kaic = FALSE;
  sys.output_phos = FALSE;
  sys.output_quite = FALSE;
  sys.species = NULL;
  sys.tau_init = 0.;
  
  // check command line parameters
  while( TRUE )
  {
    static struct option long_options[] =
    {
      // These options set a flag.
      {"a_bionmial",    no_argument, 0,  'a'},
      {"conc",          no_argument, 0,  'c'},
      {"exponential",   no_argument, 0,  'e'},
      {"linear",        no_argument, 0,  'l'},
      {"help",          no_argument, 0,  'h'},
      {"input",   required_argument, 0,  'i'},
      {"number",        no_argument, 0,  'n'},
      {"output",  required_argument, 0,  'o'},
      {"phos",          no_argument, 0,  'p'},
      {"quite",         no_argument, 0,  'q'},
      {"seed",    optional_argument, 0,  's'},
      {"total",         no_argument, 0,  't'},
      {"verbose",       no_argument, 0,  'v'},
      {"species", required_argument, 0, 1000},
    };

    // getopt_long stores the option index here.
    int option_index = 0;
    
    // parse the next option
    i = getopt_long( argc, argv, "acehlnpqstv", long_options, &option_index );
    
    // Detect the end of the options.
    if( i == -1 )
      break;
    
    switch(i) 
    {
      case 'a': // also --a_binomial
        sys.division_type = DIVIDE_HALF;
      break;
      case 'c': // also --conc
        sys.output_conc = OUTPUT_CONCENTRATION;
      break;
      case 'e': // also --exponential
        sys.growth_type = GROWTH_EXPONENTIAL;
      break;
      case 'h': // also --help
        show_help();
        return EXIT_SUCCESS;
      break;
      case 'l': // also --linear
        sys.growth_type = GROWTH_LINEAR;
      break;
      case 'i': // only --input
        if( NULL == optarg )
        {
          fprintf( stderr, "If the option '--input' is given, a filename has to be added" );
          return EXIT_FAILURE;
        }
        sys.input = malloc( ( strlen(optarg) + 1 ) * sizeof( char ) );
        strcpy( sys.input, optarg );
      break;
      case 'n': // also --number
        sys.output_conc = OUTPUT_COPYNUMBER;
      break;
      case 'o': // only --output
        if( NULL == optarg )
        {
          fprintf( stderr, "If the option '--output' is given, a filename has to be added" );
          return EXIT_FAILURE;
        }
        sys.output = malloc( ( strlen(optarg) + 1 ) * sizeof( char ) );
        strcpy( sys.output, optarg );
        printf( "files: %s - %s\n", sys.output, optarg );
      break;
      case 'p':
        sys.output_phos = TRUE;
      break;
      case 'q':
        sys.output_quite = TRUE;
      break;
      case 's':
        if( NULL == optarg )
        {
          // init random number generator with seed based on current time
          ran_init(0);
        }
        else
        {
          long seed;
          if( 1 != sscanf( optarg, "%ld%*s", &seed ) )
          {
            fprintf( stderr, "If a value for '--seed' is given, it has to be a long integer number.\n" );
            return EXIT_FAILURE;
          }
          ran_init( seed );
        }
      break;
      case 't':
        sys.output_kaic = TRUE;
      break;
      case 'v':
        sys.output_stats = TRUE;
      break;
      case 1000: // only --species
        if( NULL == optarg )
        {
          fprintf( stderr, "If the option '--species' is given, an identifier has to be added" );
          return EXIT_FAILURE;
        }
        sys.species = malloc( ( strlen(optarg) + 1 ) * sizeof( char ) );
        strcpy( sys.species, optarg );
      break;
      default:
        abort();
    }
  }

	// load data from files and initialize program
  start();

	
	// cleanup
  return finish ();
}
예제 #4
0
void CreateRandColors(int n)
{
	int i=0, ind0, ind1, ind2;
    char aux[6];
    
    ran_init(n);
	for (i = 0; i<n; i++)
	{
		strcpy(NShape[i].color, "\0");
		strcpy(aux, "\0");

        ind1 = KRAN(4096);
        
	    NShape[i].labcol=(ind1/128) % 2;
	    for (ind0 = 0; ind0<3; ind0++)
		{
            ind2 = ind1 % 16;
            ind1 = (ind1-ind2) / 16;
            switch (ind2)
            {
				case 0:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "00");
                    strcat(NShape[i].color, aux);
                    break;
				case 1:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "11");
                    strcat(NShape[i].color, aux);
                    break;
				case 2:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "22");
                    strcat(NShape[i].color, aux);
                    break;
				case 3:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "33");
                    strcat(NShape[i].color, aux);
                    break;
				case 4:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "44");
                    strcat(NShape[i].color, aux);
                    break;
				case 5:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "55");
                    strcat(NShape[i].color, aux);
                    break;
				case 6:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "66");
                    strcat(NShape[i].color, aux);
                    break;
				case 7:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "77");
                    strcat(NShape[i].color, aux);
                    break;
				case 8:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "88");
                    strcat(NShape[i].color, aux);
                    break;
				case 9:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "99");
                    strcat(NShape[i].color, aux);
                    break;
				case 10:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "AA");
                    strcat(NShape[i].color, aux);
                    break;
				case 11:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "BB");
                    strcat(NShape[i].color, aux);
                    break;
				case 12:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "CC");
                    strcat(NShape[i].color, aux);
                    break;
				case 13:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "DD");
                    strcat(NShape[i].color, aux);
                    break;
				case 14:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "EE");
                    strcat(NShape[i].color, aux);
                    break;
				case 15:
                    strcpy(aux, NShape[i].color);
                    strcpy(NShape[i].color, "FF");
                    strcat(NShape[i].color, aux);
                    break;
            }
		}
	}
}