Exemple #1
0
static cosmoPk_t
local_constructPkFromModel(parse_ini_t ini, const char *sectionName)
{
	cosmoPk_t    pk;
	cosmoModel_t model = cosmoModel_newFromIni(ini, sectionName);
	double       kmin, kmax;
	uint32_t     numPoints;

	getFromIni(&kmin, parse_ini_get_double, ini,
	           "powerSpectrumKmin", sectionName);
	getFromIni(&kmax, parse_ini_get_double, ini,
	           "powerSpectrumKmax", sectionName);
	getFromIni(&numPoints, parse_ini_get_uint32, ini,
	           "powerSpectrumNumPoints", sectionName);

	pk = cosmoPk_newFromModel(model, kmin, kmax, numPoints,
	                          cosmoTF_getTypeFromIni(ini, sectionName));
	cosmoModel_del(&model);

	return pk;
}
extern gridWriter_t
gridWriterFactory_newFromIniGrafic(parse_ini_t ini, const char *sectionName)
{
	gridWriterGrafic_t writer;
	grafic_t           grafic;
	bool               isWhiteNoise;
	uint32_t           *size = NULL;


	assert(ini != NULL);
	assert(sectionName != NULL);

	writer = gridWriterGrafic_new();
	grafic = gridWriterGrafic_getGrafic(writer);

	if (parse_ini_get_bool(ini, "isWhiteNoise", sectionName, &isWhiteNoise))
		grafic_setIsWhiteNoise(grafic, isWhiteNoise);

	if (!parse_ini_get_int32list(ini, "size", sectionName, 3,
	                             (int32_t **)&size)) {
		fprintf(stderr, "FATAL:  Could not get size from section %s.\n",
		        sectionName);
		exit(EXIT_FAILURE);
	}
	grafic_setSize(grafic, size);
	xfree(size);

	if (grafic_getIsWhiteNoise(grafic)) {
		int iseed;
		getFromIni(&iseed, parse_ini_get_int32, ini, "iseed", sectionName);
		grafic_setIseed(grafic, iseed);
	} else {
		double tmp;
		float  xOff[3] = {0.0, 0.0, 0.0};
		getFromIni(&tmp, parse_ini_get_double, ini, "dx", sectionName);
		grafic_setDx(grafic, (float)tmp);
		grafic_setXoff(grafic, xOff);
		getFromIni(&tmp, parse_ini_get_double, ini, "astart", sectionName);
		grafic_setAstart(grafic, (float)tmp);
		getFromIni(&tmp, parse_ini_get_double, ini, "omegam", sectionName);
		grafic_setOmegam(grafic, (float)tmp);
		getFromIni(&tmp, parse_ini_get_double, ini, "omegav", sectionName);
		grafic_setOmegav(grafic, (float)tmp);
		getFromIni(&tmp, parse_ini_get_double, ini, "h0", sectionName);
		grafic_setH0(grafic, (float)tmp);
	}

	return (gridWriter_t)writer;
} /* gridWriterFactory_newFromIniGrafic */
extern gridWriter_t
gridWriterFactory_newFromIniHDF5(parse_ini_t ini, const char *sectionName)
{
	assert(ini != NULL);
	assert(sectionName != NULL);

	gridWriterHDF5_t writer;
	bool             tmp, doChunking, doChecksum, doCompression;


	writer = gridWriterHDF5_new();
	tmp    = parse_ini_get_bool(ini, "doChunking", sectionName, &doChunking);
	if (tmp && doChunking) {
		int32_t           *sizeFile;
		gridPointUint32_t sizeCode;
		if (!parse_ini_get_int32list(ini, "chunkSize", sectionName,
		                             NDIM, (int32_t **)&sizeFile)) {
			fprintf(stderr, "Could not get chunkSize from section %s.\n",
			        sectionName);
			diediedie(EXIT_FAILURE);
		}
		for (int i = 0; i < NDIM; i++)
			sizeCode[i] = sizeFile[i];
		xfree(sizeFile);
		gridWriterHDF5_setChunkSize(writer, sizeCode);
	}

	if (parse_ini_get_bool(ini, "doChecksum", sectionName, &doChecksum))
		gridWriterHDF5_setDoChecksum(writer, doChecksum);

	tmp = parse_ini_get_bool(ini, "doCompression", sectionName,
	                         &doCompression);
	if (tmp && doCompression) {
		char *filterName;
		getFromIni(&filterName, parse_ini_get_string, ini,
		           "filterName", sectionName);
	}


	return (gridWriter_t)writer;
} /* gridWriterFactory_newFromIniHDF5 */
Exemple #4
0
static void
local_readRequired(io_parameter_t params, parse_ini_t ini)
{
	assert(params != NULL);
	assert(ini != NULL);

	int32_t tmpInt;

	/* Get the input file name */
	getFromIni(&(params->icfile_name), parse_ini_get_string,
	           ini, "ic_filename", local_secName);

	/* Get the type of the input file */
	getFromIni(&tmpInt, parse_ini_get_int32,
	           ini, "ic_filetype", local_secName);
	params->ic_filetype = (io_file_type_t)tmpInt;

	/* Get the outfile prefix */
	getFromIni(&(params->outfile_prefix), parse_ini_get_string,
	           ini, "outfile_prefix", local_secName);

	/* Get the domain grid size */
	getFromIni(&(params->NGRID_DOM), parse_ini_get_int32,
	           ini, "LgridDomain", local_secName);

	/* Get the maximum grid size */
	getFromIni(&(params->NGRID_MAX), parse_ini_get_int32,
	           ini, "LgridMax", local_secName);
  
	/* Get the refinment criterion for the domain grid */
	getFromIni(&(params->Nth_dom), parse_ini_get_double,
	           ini, "NperDomCell", local_secName);

	/* Get the refinement criterion for the refinment grids */
	getFromIni(&(params->Nth_ref), parse_ini_get_double,
	           ini, "NperRefCell", local_secName);

	/* Shall we use rho_back or rho_crit for halo edge */
	getFromIni(&(params->UseRhoBack), parse_ini_get_int32,
	           ini, "RhoVir", local_secName);

	/* Get virial overdensity criterion */
	getFromIni(&(params->UserDvir), parse_ini_get_double,
	           ini, "Dvir", local_secName);

	/* Get the maximum gather radius */
	getFromIni(&(params->MaxGatherRad), parse_ini_get_double,
	           ini, "MaxGatherRad", local_secName);

	/* Get the tune parameter for the escape velocity */
	getFromIni(&(params->AHF_VTUNE), parse_ini_get_double,
	           ini, "VescTune", local_secName);
  
	/* Get the maximum gather radius */
	getFromIni(&(params->AHF_MINPART), parse_ini_get_int32,
	           ini, "NminPerHalo", local_secName);
  
#ifdef WITH_MPI
	/* Get the number of readers */
	getFromIni(&(params->reader), parse_ini_get_uint32,
	           ini, "NcpuReading", local_secName);
	/* Get the LOADBALANCE_DOMAIN_GRID */
	getFromIni(&(params->lb_level), parse_ini_get_int32,
	           ini, "LevelDomainDecomp", local_secName);
#else
  params->reader   = 1;
	params->lb_level = 0;
#endif

#ifdef AHF_LRSI
	/* Get LRSI specific things */
	getFromIni(&(params->lrsi_beta), parse_ini_get_double,
	           ini, "lrsi_beta", local_secName);
	getFromIni(&(params->lrsi_r_s), parse_ini_get_double,
	           ini, "lrsi_r_s", local_secName);
#endif
  
#if (defined AHFmixHaloIDandSnapID || defined SUSSING2013)
	getFromIni(&(params->isnap), parse_ini_get_uint64,
	           ini, "snapID", local_secName);
#endif
  
#ifdef DARK_ENERGY
	/* Get name of file containing the dark energy relevant tables */
	getFromIni(&(params->defile_name), parse_ini_get_string,
	           ini, "de_filename", local_secName);
#endif
  
  

  /* read additional information for some input file formats and write the respective IO_FILE.info */
  
  /*-----------------
   *     GADGET
   *-----------------*/
  if(params->ic_filetype == IO_FILE_GADGET || params->ic_filetype == IO_FILE_MGADGET)
   {
    /* Get GADGET_MUNIT */
    getFromIni(&(params->GADGET_m2Msunh), parse_ini_get_double,
               ini, "GADGET_MUNIT", "GADGET");
    /* Get GADGET_LUNIT */
    getFromIni(&(params->GADGET_l2Mpch), parse_ini_get_double,
               ini, "GADGET_LUNIT", "GADGET");
    
#ifdef VERBOSE2
    fprintf(stderr,"GADGET_LUNIT       = %g\n",params->GADGET_l2Mpch);
    fprintf(stderr,"GADGET_MUNIT       = %g\n",params->GADGET_m2Msunh);
    fprintf(stderr,"\n");
#endif
    
    // nothing to write here as GADGET_stuff will be passed on ;-)
    
   }
  
  /*-----------------
   *       ART
   *-----------------*/
  if(params->ic_filetype == IO_FILE_ART)
   {
    FILE   *fpout;
    double ART_BOXSIZE, ART_MUNIT;
    
    getFromIni(&ART_BOXSIZE, parse_ini_get_double,
               ini, "ART_BOXSIZE", "ART");
    getFromIni(&ART_MUNIT, parse_ini_get_double,
               ini, "ART_MUNIT", "ART");
    
#ifdef VERBOSE
    fprintf(stderr,"ART_BOXSIZE       = %20.10lf\n",ART_BOXSIZE);
    fprintf(stderr,"ART_MUNIT         = %20.10lf\n",ART_MUNIT);
    fprintf(stderr,"\n");
#endif

#ifdef WITH_MPI
    if(global_mpi.rank == 0) // only the master should write the file
     {
#endif
      if( (fpout = fopen("art.info","w")) == NULL)
       {
        fprintf(stderr,"Could not open art.info\nAborting\n");
        exit(0);
       }    
      fprintf(fpout,"%20.10lf \t\t ART_BOXSIZE\n",ART_BOXSIZE);
      fprintf(fpout,"%20.10lf \t\t ART_MUNIT\n",ART_MUNIT);
      fclose(fpout);
#ifdef WITH_MPI
     }
#endif
   }
  
  /*-----------------
   *      TIPSY
   *-----------------*/
  if(params->ic_filetype == IO_FILE_TIPSY)
   {
    FILE   *fpout;
    double TIPSY_BOXSIZE, TIPSY_MUNIT, TIPSY_VUNIT, TIPSY_EUNIT, TIPSY_OMEGA0, TIPSY_LAMBDA0;
    
    getFromIni(&TIPSY_BOXSIZE, parse_ini_get_double,
               ini, "TIPSY_BOXSIZE", "TIPSY");
    getFromIni(&TIPSY_MUNIT, parse_ini_get_double,
               ini, "TIPSY_MUNIT", "TIPSY");
    getFromIni(&TIPSY_VUNIT, parse_ini_get_double,
               ini, "TIPSY_VUNIT", "TIPSY");
    getFromIni(&TIPSY_EUNIT, parse_ini_get_double,
               ini, "TIPSY_EUNIT", "TIPSY");
    getFromIni(&TIPSY_OMEGA0, parse_ini_get_double,
               ini, "TIPSY_OMEGA0", "TIPSY");
    getFromIni(&TIPSY_LAMBDA0, parse_ini_get_double,
               ini, "TIPSY_LAMBDA0", "TIPSY");
    
#ifdef VERBOSE
    fprintf(stderr,"TIPSY_OMEGA0      = %20.10lf\n",TIPSY_OMEGA0);
    fprintf(stderr,"TIPSY_LAMBDA0     = %20.10lf\n",TIPSY_LAMBDA0);
    fprintf(stderr,"TIPSY_BOXSIZE     = %20.10lf\n",TIPSY_BOXSIZE);
    fprintf(stderr,"TIPSY_VUNIT       = %20.10lf\n",TIPSY_VUNIT);
    fprintf(stderr,"TIPSY_MUNIT       = %20.10lf\n",TIPSY_MUNIT);
    fprintf(stderr,"TIPSY_EUNIT       = %20.10lf\n",TIPSY_EUNIT);
    fprintf(stderr,"\n");
#endif
    
#ifdef WITH_MPI
    if(global_mpi.rank == 0) // only the master should write the file
     {
#endif
      if( (fpout = fopen("tipsy.info","w")) == NULL)
       {
        fprintf(stderr,"Could not open tipsy.info\nAborting\n");
        exit(0);
       }    
      fprintf(fpout,"%20.10lf \t\t TIPSY_OMEGA0\n",TIPSY_OMEGA0);
      fprintf(fpout,"%20.10lf \t\t TIPSY_LAMBDA0\n",TIPSY_LAMBDA0);
      fprintf(fpout,"%20.10lf \t\t TIPSY_BOXSIZE\n",TIPSY_BOXSIZE);
      fprintf(fpout,"%20.10lf \t\t TIPSY_VUNIT\n",TIPSY_VUNIT);
      fprintf(fpout,"%20.10lf \t\t TIPSY_MUNIT\n",TIPSY_MUNIT);
      fprintf(fpout,"%20.10lf \t\t TIPSY_EUNIT\n",TIPSY_EUNIT);
      fclose(fpout);
#ifdef WITH_MPI
     }
#endif

   }

  /*-----------------
   *    CUBEP3M
   *-----------------*/
  if(params->ic_filetype == IO_FILE_CUBEP3M || params->ic_filetype == IO_FILE_MCUBEP3M)
   {
    FILE   *fpout;
    double CUBEP3M_BOXSIZE, CUBEP3M_NGRID, CUBEP3M_NODES_DIM, CUBEP3M_OMEGA0, CUBEP3M_LAMBDA0;
    
    getFromIni(&CUBEP3M_BOXSIZE, parse_ini_get_double,
               ini, "CUBEP3M_BOXSIZE", "CUBEP3M");
    getFromIni(&CUBEP3M_NGRID, parse_ini_get_double,
               ini, "CUBEP3M_NGRID", "CUBEP3M");
    getFromIni(&CUBEP3M_NODES_DIM, parse_ini_get_double,
               ini, "CUBEP3M_NODES_DIM", "CUBEP3M");
    getFromIni(&CUBEP3M_OMEGA0, parse_ini_get_double,
               ini, "CUBEP3M_OMEGA0", "CUBEP3M");
    getFromIni(&CUBEP3M_LAMBDA0, parse_ini_get_double,
               ini, "CUBEP3M_LAMBDA0", "CUBEP3M");
    
#ifdef VERBOSE
    fprintf(stderr,"CUBEP3M_OMEGA0      = %20.10lf\n",CUBEP3M_OMEGA0);
    fprintf(stderr,"CUBEP3M_LAMBDA0     = %20.10lf\n",CUBEP3M_LAMBDA0);
    fprintf(stderr,"CUBEP3M_BOXSIZE     = %20.10lf\n",CUBEP3M_BOXSIZE);
    fprintf(stderr,"CUBEP3M_NGRID       = %20.10lf\n",CUBEP3M_NGRID);
    fprintf(stderr,"CUBEP3M_NODES_DIM   = %20.10lf\n",CUBEP3M_NODES_DIM);
    fprintf(stderr,"\n");
#endif
    
#ifdef WITH_MPI
    if(global_mpi.rank == 0) // only the master should write the file
     {
#endif
      if( (fpout = fopen("cubep3m.info","w")) == NULL)
       {
        fprintf(stderr,"Could not open cubep3m.info\nAborting\n");
        exit(0);
       }    
      fprintf(fpout,"%20.10lf \t\t CUBEP3M_OMEGA0\n",CUBEP3M_OMEGA0);
      fprintf(fpout,"%20.10lf \t\t CUBEP3M_LAMBDA0\n",CUBEP3M_LAMBDA0);
      fprintf(fpout,"%20.10lf \t\t CUBEP3M_BOXSIZE\n",CUBEP3M_BOXSIZE);
      fprintf(fpout,"%20.10lf \t\t CUBEP3M_NGRID\n",CUBEP3M_NGRID);
      fprintf(fpout,"%20.10lf \t\t CUBEP3M_NODES_DIM\n",CUBEP3M_NODES_DIM);
      fclose(fpout);
#ifdef WITH_MPI
     }
#endif
   }
  
} /* local_readRequired */