#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define DEBUG 0

void getnewjob(double *job, double *job_input_array, int num_fieldlines, int current_job)
{
  extern int length;

  /* Structure of job array
     job[0] = job_number
     job[1] = job_color
     job[2] = current_time
     job[3] = job_status
     job[4] = main_x0
     job[5] = main_y0
     job[6] = main_z0
     job[7] = vx0
     job[8] = vy0
     job[9] = vz0   */

  int i = 0;
  
  if ( current_job > num_fieldlines - 1 )
    /* numfieldlines run from 0 to n-1 */
    {
      job[0] = -1; /* setting up of the end condition */
      job[1] = job[2] = job[3] = job[4] = job[5] = job[6] = job[7] = job[8] = job[9] = 0;
    }
      
  else
    {
      job[0] = job_input_array[current_job * length + 0];
      job[1] = job_input_array[current_job * length + 1];
      job[2] = job_input_array[current_job * length + 2];
      job[3] = job_input_array[current_job * length + 3];
      job[4] = job_input_array[current_job * length + 4];
      job[5] = job_input_array[current_job * length + 5];
      job[6] = job_input_array[current_job * length + 6];
      job[7] = job_input_array[current_job * length + 7];
      job[8] = job_input_array[current_job * length + 8];
      job[9] = job_input_array[current_job * length + 9];     
    }

  if (DEBUG)
    for (i=0; i<length; i++)
      printf("%f\t", job[i]);
}
