Fix core WST file
[jabaws.git] / binaries / src / tcoffee / t_coffee_source / util_job_handling.c
index 8f730d2..838d911 100644 (file)
@@ -18,8 +18,9 @@ Job_TC* print_lib_job ( Job_TC *job,char *string, ...)
   char **value;
   char **name;
   int a, np, n;
-  char bname[LONG_STRING];
-  char bval[LONG_STRING];
+    
+  char bname[100];
+  char bval[100];
   
   list=string2list2(string, " =");
   n=atoi (list[0]);
@@ -28,24 +29,20 @@ Job_TC* print_lib_job ( Job_TC *job,char *string, ...)
   name =vcalloc ( (n-1)/2, sizeof (char*));
   value=vcalloc ( (n-1)/2, sizeof (char*));
   
-
+  
   va_start (ap, string);
   for (a=1, np=0; a<n; a++)
     {
-      if (list[a][0]=='%')
+      if (list[a][0]=='%' && list[a][1]=='s')
+       {
+         value[np++]=duplicate_string (va_arg (ap,char *));
+       }
+      else if (list[a][0]=='%')
        {
          if ( list[a][1]=='d')sprintf (bval, "%d", va_arg (ap,int));
-         else if ( list[a][1]=='s')sprintf (bval, "%s", va_arg (ap,char *));
-         
          else if ( list[a][1]=='f')sprintf (bval, "%lf",(float) va_arg (ap,double));
          else if ( list[a][1]=='p')sprintf (bval, "%ld", (long)va_arg (ap,void *));
-         /*
-           Before 64 Bits
-         else if ( list[a][1]=='f')sprintf (bval, "%f",(float) va_arg (ap,double));
-         else if ( list[a][1]=='p')sprintf (bval, "%d", (long)va_arg (ap,void *));
-         */
-         value[np]=duplicate_string (bval);
-         np++;
+         value[np++]=duplicate_string (bval);
        }
       else
        {
@@ -79,7 +76,7 @@ Job_TC *print_lib_job2 ( Job_TC* job, int n, char **name, char **value)
       else if ( strstr(name[a], "io") && !job->io){job->io=vcalloc ( 1, sizeof (Job_io_TC));job->pl[job->np++]=(void*)job->io;}
       else if ( strstr(name[a], "param") && !job->param){job->param=vcalloc ( 1, sizeof (Job_param_TC));job->pl[job->np++]=(void*)job->param;}
       
-      if (           strm (name[a], "control"))                {job->control=(struct Job_control_TC*)atoi(value[a]);string=0;}
+      if (           strm (name[a], "control"))                {job->control=(struct Job_control_TC*)atol(value[a]);string=0;}
       else if (      strm (name[a], "control->submitF"))       {(job->control) ->submitF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
       else if (      strm (name[a], "control->retrieveF"))     {(job->control) ->retrieveF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
       else if (      strm (name[a], "control->mode"))   {(job->control)->mode=value[a];string=1;}
@@ -230,8 +227,7 @@ Job_TC*** split_job_list (Job_TC *job, int ns)
  
   if   (nj==0)return NULL;
   else split=(nj/ns)+1;
-  
-
+   
   n=a=u=0;
   jl[a][0]=job;
   while (job)
@@ -252,6 +248,30 @@ Job_TC*** split_job_list (Job_TC *job, int ns)
       n++;
       job=job->c;
     }
+
+  /*Display job details when debugging
+  a=0;
+  while (jl[a])
+    {
+      Job_TC *start,* end;
+      int todo=0;
+      
+      start=job=jl[a][0];
+      end=jl[a][1];
+      while (job!=end){todo++;job=job->c;}
+      job=start;
+      while (job!=end)
+       {
+         HERE ("--- %d %d %s",a, job, job->param->aln_c);
+         job=job->c;
+       }
+      a++;
+    }
+  
+    a=0;
+    while (jl[a]){HERE ("**** %d %d ", jl [a][0], jl[a][1]);a++;}
+    myexit (0);
+  */
   return jl;
 }
 
@@ -288,11 +308,34 @@ Job_TC* retrieve_job ( Job_TC *job)
       return NULL;
     }
 }
-/*********************************COPYRIGHT NOTICE**********************************/
+int **n2splits (int splits, int tot)
+{
+  int **l;
+  int a,b,delta;
+  
+  if (splits==0)return NULL;
+  else if ( tot==0)return NULL;
+  else
+    {
+      
+      l=declare_int (splits,2);
+      delta=tot/splits;
+      
+      for (a=0,b=0; a<splits && b<tot; a++,b+=delta)
+       {
+         l[a][0]=b;
+         l[a][1]=MIN((b+delta),tot);
+       }
+      l[splits-1][1]=MAX((l[splits-1][1]),tot);
+      return l;
+    }
+}
+  
+/******************************COPYRIGHT NOTICE*******************************/
 /*© Centro de Regulacio Genomica */
 /*and */
 /*Cedric Notredame */
-/*Tue Oct 27 10:12:26 WEST 2009. */
+/*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
 /*All rights reserved.*/
 /*This file is part of T-COFFEE.*/
 /**/
@@ -316,4 +359,4 @@ Job_TC* retrieve_job ( Job_TC *job)
 /**/
 /**/
 /*     */
-/*********************************COPYRIGHT NOTICE**********************************/
+/******************************COPYRIGHT NOTICE*******************************/