Esempio n. 1
0
void out_ktab(MeshS *pM, OutputS *pOut)
{
  GridS *pGrid=pM->Domain[0][0].Grid;
  int i,nx1;
  FILE *pFile;
  char fmt[80],*fname,*plev=NULL,*pdom=NULL;
  char levstr[8],domstr[8];
  Real *data=NULL;
  Real dmin, dmax, xworld;

/* Add a white space to the format, setup format for integer zone columns */
  if(pOut->dat_fmt == NULL){
     sprintf(fmt," %%12.8e"); /* Use a default format */
  }
  else{
    sprintf(fmt," %s",pOut->dat_fmt);
  }

/* compute 1D array of data */
  data = OutData1(pGrid,pOut,&nx1);
  if (data == NULL) return;  /* slice not in range of Grid */

  minmax1(data,nx1,&dmin,&dmax);


  if((fname = ath_fname(plev,pM->outfilename,0,0,0,0,
      pOut->id,"tab")) == NULL){
    ath_error("[output_tab]: Error constructing filename\n");
  }

  pFile = fopen(fname,"a");
/* open filename */
  if (pFile == NULL) {
    ath_error("[output_tab]: Unable to open tab file %s\n",fname);
  }

/* write data */

  if (pOut->num == 0) {
  	for (i=0; i<nx1; i++) {
  		fprintf(pFile,"%12d\t",pGrid->Disp[0]+i);
  	}
  	fprintf(pFile,"\n");
  }
  for (i=0; i<nx1; i++) {
  	fprintf(pFile,fmt,data[i]);
  	fprintf(pFile,"\t");
  }
  fprintf(pFile,"\n");
/* Compute and store global min/max, for output at end of run */
  pOut->gmin = MIN(dmin,pOut->gmin);
  pOut->gmax = MAX(dmax,pOut->gmax);

  fclose(pFile);
  free_1d_array(data); /* Free the memory we malloc'd */
}
Esempio n. 2
0
void run(int len, int trials, unsigned seed) {
    double t1, t2;
    int t;
    for (t = 0; t < trials; t++) {
	init(seed);
	start_counter();
	minmax1(a1, b1, len);
	t1 = get_counter();
	start_counter();
	minmax2(a2, b2, len);
	t2 = get_counter();
	printf("%d\t%.2f\t%.2f\n", len, t1/len, t2/len);
    }
}
static void minmax(REAL value, REAL *minima, REAL *maxima, int *nminima, int *nmaxima, int row, int *rowmin, int *rowmax, int col, int *colmin, int *colmax)
{
  minmax1(value, -1.0, minima, nminima, row, rowmin, col, colmin);
  minmax1(value, +1.0, maxima, nmaxima, row, rowmax, col, colmax);
}