#include <stdio.h>
#include "config.h"
#include <time.h>

int exptnum;

void run(int x,char *param){

    if (x==nparam){
        printf("Running %s%s\n ",program,param);
        char command[maxstr];        
        
        sprintf(command,"%s%s > %s%s.%i",program,param,tempdir,name,exptnum);
        printf("%s\n",command);
        system(command);
        exptnum++;
        
        return;
    }

    int i,tmp;
    for (i=0;i<dd[x];i++){
        tmp=strlen(param);
        strcat(param," ");
        strcat(param,paramset[x][i]);

        run(x+1,param);
        
        param[tmp]=0;
    }
}

int main(int argc,char *argv[]){

    time_t seconds,current;
    seconds = time (NULL);
       
   if (readDatabase(argv[1])==0){
        printf("Name or id is not found\n");
        return;
   }
   
   readParam(tmp);

   exptnum=0;
   
   char pr[maxstr];
   pr[0]=0;
   
//   printf("son\n");
   run(0,pr);  // run the experiment
   
   current=time(NULL);
   printf("Time (in seconds): %ld\n",current-seconds);
}
