Ejemplo n.º 1
0
void run_monopole_corr_neighbors(Catalog cat_dat,double *corr,
								 double *ercorr,unsigned long long *DD,
								 int nb_r, double r_max, int nthreads)
{
  //////
  // Main routine for monopole using neighbor boxes
  
  // lint n_dat;
  int nside;
  // Catalog cat_dat;
  NeighborBox *boxes;

  nside=optimal_nside(l_box,r_max,cat_dat.np);
  boxes=catalog_to_boxes(nside,cat_dat);


//  printf("*** Correlating\n");
 // timer(0);
  corr_mono_box_neighbors(nside,boxes,cat_dat.np, cat_dat.pos,DD,nb_r,r_max,nthreads);
  
 // timer(1);

  make_CF(DD,cat_dat.np,corr,ercorr,nb_r,r_max);
  // write_CF(fnameOut,corr,ercorr,DD);

  free_catalog(cat_dat);
  free_boxes(nside,boxes);

 // timer(5);
}
Ejemplo n.º 2
0
catalog_t *
load_catalog (xio_file f, CONST char **error)
{
  int i;
  int line = 1;
  int size;
  int c;
  catalog_t *catalog = alloc_catalog ();
  static char errort[40];
  char name[1024];
  char value[1024];
  if (catalog == NULL)
    {
      *error = "Out of memory";
    }
  if (f == NULL)
    {
      *error = "File could not be opended";
      free_catalog (catalog);
      return NULL;
    }
  /* Just very simple parsing loop of format 
   * [blanks]name[blanks]"value"[blanks]
   * Blanks should be comments using # or space, newline, \r and tabulator
   * Value shoud contain and \ seqences where \\ means \ and
   * \[something] means something. Should be used for character "
   */
  while (!xio_feof (f))
    {

      do
	{
	  c = xio_getc (f);
	  if (c == '\n')
	    line++;
	  if (c == '#')
	    {
	      while ((c = xio_getc (f)) != '\n' && c != XIO_EOF);
	      line++;
	    }
	}
      while (c == ' ' || c == '\n' || c == '\r' || c == '\t');
      /*Skip blanks */
      if (c == XIO_EOF)
	{
	  if (xio_feof (f))
	    break;
	  free_catalog (catalog);
	  seterror ("read error");
	  xio_close (f);
	  return NULL;
	}
      i = 0;

      /*read name */
      do
	{
	  name[i] = c;
	  i++;
	  c = xio_getc (f);
	  if (c == '\n')
	    line++;
	  if (i == 1024)
	    {
	      seterror ("Name is too long(1024 or more characters)");
	      free_catalog (catalog);
	      xio_close (f);
	      return NULL;
	    }
	}
      while (c != '\n' && c != ' ' && c != '\t' && c != XIO_EOF);

      /*Skip blanks */
      while (c == ' ' || c == '\n' || c == '\r' || c == '\t')
	{
	  c = xio_getc (f);
	  if (c == '\n')
	    line++;
	  if (c == '#')
	    {
	      while ((c = xio_getc (f)) != '\n' && c != XIO_EOF);
	      line++;
	    }
	}

      /*Skip blanks */
      if (c == XIO_EOF)
	{
	  if (xio_feof (f))
	    seterror ("Inexpected end of file after name field");
	  else
	    seterror ("read error");
	  free_catalog (catalog);
	  xio_close (f);
	  return NULL;
	}
      name[i] = 0;
      if (c != '"')
	{
	  seterror ("Begin of value field expected (\")");
	  free_catalog (catalog);
	  xio_close (f);
	  return NULL;
	}
      c = xio_getc (f);
      if (c == '\n')
	line++;
      i = 0;

      size = 0;
      do
	{
	  if (c == '\\')
	    value[i] = xio_getc (f);
	  else
	    value[i] = c;
	  i++;
	  c = xio_getc (f);
	  if (c == '\n')
	    line++, size = 0;
	  if (size == 40 && c != '"')
	    {
	      fprintf (stderr, "Warning - too long text at line %i\n", line);
	    }
	  size++;
	  if (i == 1024)
	    {
	      seterror ("Value is too long(1024 or more characters)");
	      free_catalog (catalog);
	      xio_close (f);
	      return NULL;
	    }
	}
      while (c != '"' && c != XIO_EOF);

      if (c == XIO_EOF)
	{
	  seterror ("Inexpeced end of file in value filed");
	  free_catalog (catalog);
	  xio_close (f);
	  return NULL;
	}
      value[i] = 0;
      find_variable (catalog, name, value);
    }				/*while */
  xio_close (f);
  return (catalog);
}				/*load_catalog */