testing/icgen/random_verschillende_resoluties_N-GenIC/gadget3_64/read_ic.c
void distribute_file(int nfiles, int firstfile, int firsttask, int lasttask, int *filenr, int *master,
		     int *last)
{
  int ntask, filesleft, filesright, tasksleft, tasksright;

  if(nfiles > 1)
    {
      ntask = lasttask - firsttask + 1;

      filesleft = (int) ((((double) (ntask / 2)) / ntask) * nfiles);
      if(filesleft <= 0)
	filesleft = 1;
      if(filesleft >= nfiles)
	filesleft = nfiles - 1;

      filesright = nfiles - filesleft;

      tasksleft = ntask / 2;
      tasksright = ntask - tasksleft;

      distribute_file(filesleft, firstfile, firsttask, firsttask + tasksleft - 1, filenr, master, last);
      distribute_file(filesright, firstfile + filesleft, firsttask + tasksleft, lasttask, filenr, master,
		      last);
    }
  else
    {
      if(ThisTask >= firsttask && ThisTask <= lasttask)
	{
	  *filenr = firstfile;
	  *master = firsttask;
	  *last = lasttask;
	}
    }
}
/*! This function assigns a certain number of files to processors, such that
 *  each processor is exactly assigned to one file, and the number of cpus per
 *  file is as homogenous as possible. The number of files may at most be
 *  equal to the number of processors.
 */
This function assigns a certain number of files to processors, such that
each processor is exactly assigned to one file, and the number of cpus per
file is as homogenous as possible. The number of files may at most be
equal to the number of processors.
This function assigns a certain number of files to processors such that each processor is exactly assigned to one file and the number of cpus per file is as homogenous as possible . The number of files may at most be equal to the number of processors .
void distribute_file(int nfiles, int firstfile, int firsttask, int lasttask, int *filenr, int *master,
		     int *last)
{
  int ntask, filesleft, filesright, tasksleft, tasksright;
  if(nfiles > 1)
    {
      ntask = lasttask - firsttask + 1;
      filesleft = (int) ((((double) (ntask / 2)) / ntask) * nfiles);
      if(filesleft <= 0)
	filesleft = 1;
      if(filesleft >= nfiles)
	filesleft = nfiles - 1;
      filesright = nfiles - filesleft;
      tasksleft = ntask / 2;
      tasksright = ntask - tasksleft;
      distribute_file(filesleft, firstfile, firsttask, firsttask + tasksleft - 1, filenr, master, last);
      distribute_file(filesright, firstfile + filesleft, firsttask + tasksleft, lasttask, filenr, master,
		      last);
    }
  else
    {
      if(ThisTask >= firsttask && ThisTask <= lasttask)
	{
	  *filenr = firstfile;
	  *master = firsttask;
	  *last = lasttask;
	}
    }
}
void distribute_file ( int nfiles , int firstfile , int firsttask , int lasttask , int * filenr , int * master , int * last ) { int ntask , filesleft , filesright , tasksleft , tasksright ; if ( nfiles > 1 ) { ntask = lasttask - firsttask + 1 ; filesleft = ( int ) ( ( ( ( double ) ( ntask / 2 ) ) / ntask ) * nfiles ) ; if ( filesleft <= 0 ) filesleft = 1 ; if ( filesleft >= nfiles ) filesleft = nfiles - 1 ; filesright = nfiles - filesleft ; tasksleft = ntask / 2 ; tasksright = ntask - tasksleft ; distribute_file ( filesleft , firstfile , firsttask , firsttask + tasksleft - 1 , filenr , master , last ) ; distribute_file ( filesright , firstfile + filesleft , firsttask + tasksleft , lasttask , filenr , master , last ) ; } else { if ( ThisTask >= firsttask && ThisTask <= lasttask ) { * filenr = firstfile ; * master = firsttask ; * last = lasttask ; } } }
This function assigns a certain number of files to processors, such that
  each processor is exactly assigned to one file, and the number of cpus per
  file is as homogenous as possible.
This function assigns a certain number of files to processors such that each processor is exactly assigned to one file and the number of cpus per file is as homogenous as possible .