mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-16 13:33:46 +02:00
replaced all sprintf by snprintf, cleaned up some other warnings
This commit is contained in:
parent
6b32a7d6e4
commit
16bdb25e21
23 changed files with 2742 additions and 2797 deletions
|
@ -191,7 +191,7 @@ constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
|
|||
{
|
||||
char temp1[128];
|
||||
std::string temp2;
|
||||
sprintf(temp1,"constraint[%u].type",i);
|
||||
snprintf(temp1,128,"constraint[%u].type",i);
|
||||
if( cf.contains_key( "constraints", temp1 ) )
|
||||
{
|
||||
std::string str_type = cf.get_value<std::string>( "constraints", temp1 );
|
||||
|
@ -204,17 +204,17 @@ constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
|
|||
new_c.type = constr_type_map[ str_type ];
|
||||
|
||||
//... read position of constraint
|
||||
sprintf(temp1,"constraint[%u].pos",i);
|
||||
snprintf(temp1,128,"constraint[%u].pos",i);
|
||||
temp2 = cf.get_value<std::string>( "constraints", temp1 );
|
||||
sscanf(temp2.c_str(), "%lf,%lf,%lf", &new_c.x, &new_c.y, &new_c.z);
|
||||
|
||||
if( new_c.type == halo)
|
||||
{
|
||||
//.. halo type constraints take mass and collapse redshift
|
||||
sprintf(temp1,"constraint[%u].mass",i);
|
||||
snprintf(temp1,128,"constraint[%u].mass",i);
|
||||
double mass = cf.get_value<double>( "constraints", temp1 );
|
||||
|
||||
sprintf(temp1,"constraint[%u].zform",i);
|
||||
snprintf(temp1,128,"constraint[%u].zform",i);
|
||||
double zcoll = cf.get_value<double>( "constraints", temp1 );
|
||||
new_c.Rg = pow((mass/pow(2.*M_PI,1.5)/rhom),1./3.);
|
||||
|
||||
|
@ -226,15 +226,15 @@ constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
|
|||
else if( new_c.type == peak )
|
||||
{
|
||||
//... peak type constraints take a scale and a peak height
|
||||
//sprintf(temp1,"constraint[%u].Rg",i);
|
||||
//snprintf(temp1,128,"constraint[%u].Rg",i);
|
||||
//new_c.Rg = cf.get_value<double>( "constraints", temp1 );
|
||||
//double mass = pow(new_c.Rg,3.0)*rhom*pow(2.*M_PI,1.5);
|
||||
|
||||
sprintf(temp1,"constraint[%u].mass",i);
|
||||
snprintf(temp1,128,"constraint[%u].mass",i);
|
||||
double mass = cf.get_value<double>( "constraints", temp1 );
|
||||
new_c.Rg = pow((mass/pow(2.*M_PI,1.5)/rhom),1./3.);
|
||||
double Rtophat = pow(mass/4.0*3.0/M_PI/rhom,1./3.);
|
||||
sprintf(temp1,"constraint[%u].nu",i);
|
||||
snprintf(temp1,128,"constraint[%u].nu",i);
|
||||
double nu = cf.get_value<double>( "constraints", temp1 );
|
||||
|
||||
std::vector<double> z,sigma;
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
char out[1024];
|
||||
va_list argptr;
|
||||
va_start(argptr, str);
|
||||
vsprintf(out, str, argptr);
|
||||
vsnprintf(out, 1024, str, argptr );
|
||||
va_end(argptr);
|
||||
std::string out_string = std::string(out);
|
||||
out_string.erase(std::remove(out_string.begin(), out_string.end(), '\n'),
|
||||
|
|
16
src/main.cc
16
src/main.cc
|
@ -231,12 +231,12 @@ void store_grid_structure(config_file &cf, const refinement_hierarchy &rh)
|
|||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
sprintf(str1, "offset(%d,%d)", i, j);
|
||||
sprintf(str2, "%ld", rh.offset(i, j));
|
||||
snprintf(str1, 128, "offset(%d,%d)", i, j);
|
||||
snprintf(str2, 128, "%ld", rh.offset(i, j));
|
||||
cf.insert_value("setup", str1, str2);
|
||||
|
||||
sprintf(str1, "size(%d,%d)", i, j);
|
||||
sprintf(str2, "%ld", rh.size(i, j));
|
||||
snprintf(str1, 128, "size(%d,%d)", i, j);
|
||||
snprintf(str2, 128, "%ld", rh.size(i, j));
|
||||
cf.insert_value("setup", str1, str2);
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ int main(int argc, const char *argv[])
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
char logfname[128];
|
||||
sprintf(logfname, "%s_log.txt", argv[1]);
|
||||
snprintf(logfname, 128, "%s_log.txt", argv[1]);
|
||||
music::logger::set_output(logfname);
|
||||
time_t ltime = time(NULL);
|
||||
music::ilog.Print("Opening log file \'%s\'.", logfname);
|
||||
|
@ -484,11 +484,11 @@ int main(int argc, const char *argv[])
|
|||
//
|
||||
{
|
||||
char tmpstr[128];
|
||||
sprintf(tmpstr, "%.12g", cosmo.pnorm);
|
||||
snprintf(tmpstr, 128, "%.12g", cosmo.pnorm);
|
||||
cf.insert_value("cosmology", "pnorm", tmpstr);
|
||||
sprintf(tmpstr, "%.12g", cosmo.dplus);
|
||||
snprintf(tmpstr, 128, "%.12g", cosmo.dplus);
|
||||
cf.insert_value("cosmology", "dplus", tmpstr);
|
||||
sprintf(tmpstr, "%.12g", cosmo.vfact);
|
||||
snprintf(tmpstr, 128, "%.12g", cosmo.vfact);
|
||||
cf.insert_value("cosmology", "vfact", tmpstr);
|
||||
}
|
||||
|
||||
|
|
|
@ -1347,11 +1347,11 @@ public:
|
|||
}
|
||||
|
||||
char strtmp[32];
|
||||
sprintf(strtmp, "%ld", xshift_[0]);
|
||||
snprintf(strtmp, 32, "%ld", xshift_[0]);
|
||||
cf_.insert_value("setup", "shift_x", strtmp);
|
||||
sprintf(strtmp, "%ld", xshift_[1]);
|
||||
snprintf(strtmp, 32, "%ld", xshift_[1]);
|
||||
cf_.insert_value("setup", "shift_y", strtmp);
|
||||
sprintf(strtmp, "%ld", xshift_[2]);
|
||||
snprintf(strtmp, 32, "%ld", xshift_[2]);
|
||||
cf_.insert_value("setup", "shift_z", strtmp);
|
||||
|
||||
rshift_[0] = -(double)xshift_[0] / ncoarse;
|
||||
|
|
2080
src/mg_operators.hh
2080
src/mg_operators.hh
File diff suppressed because it is too large
Load diff
|
@ -367,7 +367,7 @@ double solver<S, I, O>::compute_error(const MeshvarBnd<real_t> &u, const Meshvar
|
|||
ny = u.size(1),
|
||||
nz = u.size(2);
|
||||
|
||||
double err = 0.0, err2 = 0.0;
|
||||
double err = 0.0; //, err2 = 0.0;
|
||||
size_t count = 0;
|
||||
|
||||
double h = 1.0 / (1ul << ilevel), h2 = h * h;
|
||||
|
@ -642,5 +642,3 @@ void solver<S, I, O>::make_periodic(MeshvarBnd<real_t> *u)
|
|||
}
|
||||
|
||||
END_MULTIGRID_NAMESPACE
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
|||
char str[128];
|
||||
for( unsigned i=levelmin_; i<=levelmax_; ++i )
|
||||
{
|
||||
sprintf( str, "%s(%u,%d)", name.c_str(), i, icomp );
|
||||
snprintf( str, 128, "%s(%u,%d)", name.c_str(), i, icomp );
|
||||
*oit = cf_.get_value<unsigned>( "setup", str );
|
||||
++oit;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,6 @@ template<typename T >
|
|||
inline void HDFReadSelect( const std::string Filename, const std::string ObjName, const std::vector<unsigned>& ii, std::vector<T> &Data ){
|
||||
|
||||
hid_t HDF_Type, HDF_FileID, HDF_DatasetID, HDF_DataspaceID, HDF_MemspaceID;
|
||||
hsize_t HDF_StorageSize;
|
||||
|
||||
HDF_Type = GetDataType<T>();
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ public:
|
|||
void write_dm_velocity( int coord, const grid_hierarchy& gh )
|
||||
{
|
||||
char nyxname[256];
|
||||
sprintf( nyxname, "ParticleVelocities_%c", (char)('x'+coord) );
|
||||
snprintf( nyxname, 256, "ParticleVelocities_%c", (char)('x'+coord) );
|
||||
|
||||
double vunit = 1.0/(1.225e2*sqrt(the_sim_header.omega_m/the_sim_header.a_start));
|
||||
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
void write_dm_position( int coord, const grid_hierarchy& gh )
|
||||
{
|
||||
char nyxname[256];
|
||||
sprintf( nyxname, "ParticleDisplacements_%c", (char)('x'+coord) );
|
||||
snprintf( nyxname, 256,"ParticleDisplacements_%c", (char)('x'+coord) );
|
||||
|
||||
//dump_grid_data( nyxname, gh );
|
||||
dump_grid_data(the_sim_header.particle_idx+coord, nyxname, gh);
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
double vunit = 1.0/(1.225e2*sqrt(the_sim_header.omega_m/the_sim_header.a_start));
|
||||
|
||||
char nyxname[256];
|
||||
sprintf( nyxname, "GridVelocities_%c", (char)('x'+coord) );
|
||||
snprintf( nyxname, 256, "GridVelocities_%c", (char)('x'+coord) );
|
||||
dump_grid_data(coord+1, nyxname, gh);
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ public:
|
|||
void write_gas_density( const grid_hierarchy& gh )
|
||||
{
|
||||
char nyxname[256];
|
||||
sprintf( nyxname, "density" );
|
||||
snprintf( nyxname, 256, "density" );
|
||||
//FIXME factor and add have to be adjusted to the
|
||||
//corresponding nyx units...
|
||||
dump_grid_data(0, nyxname, gh);
|
||||
|
|
|
@ -300,12 +300,12 @@ protected:
|
|||
|
||||
// generate all temp file names
|
||||
char fnx[256], fny[256], fnz[256], fnvx[256], fnvy[256], fnvz[256];
|
||||
sprintf(fnx, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
sprintf(fny, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
sprintf(fnz, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
sprintf(fnvx, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
sprintf(fnvy, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
sprintf(fnvz, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
snprintf(fnx, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
snprintf(fny, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
snprintf(fnz, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
snprintf(fnvx, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
snprintf(fnvy, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
snprintf(fnvz, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
|
||||
// create buffers for temporary data
|
||||
T_store *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp6;
|
||||
|
@ -420,12 +420,12 @@ protected:
|
|||
|
||||
// generate all temp file names
|
||||
char fnx[256], fny[256], fnz[256], fnvx[256], fnvy[256], fnvz[256];
|
||||
sprintf(fnx, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
sprintf(fny, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
sprintf(fnz, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
sprintf(fnvx, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
sprintf(fnvy, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
sprintf(fnvz, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
snprintf(fnx, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
snprintf(fny, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
snprintf(fnz, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
snprintf(fnvx, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
snprintf(fnvy, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
snprintf(fnvz, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
|
||||
// create buffers for temporary data
|
||||
T_store *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp6;
|
||||
|
@ -645,7 +645,7 @@ public:
|
|||
double xfac = (double)header_.NGRIDC;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * nptot;
|
||||
|
@ -709,7 +709,7 @@ public:
|
|||
double vfac = (header_.aexpN * header_.NGRIDC) / (100.0);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * nptot;
|
||||
|
@ -772,7 +772,7 @@ public:
|
|||
double xfac = (double)header_.NGRIDC;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * nptot;
|
||||
|
@ -836,7 +836,7 @@ public:
|
|||
double vfac = (header_.aexpN * header_.NGRIDC) / (100.0);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * nptot;
|
||||
|
|
|
@ -297,12 +297,12 @@ class cart_output_plugin : public output_plugin
|
|||
|
||||
// generate all temp file names
|
||||
char fnx[256],fny[256],fnz[256],fnvx[256],fnvy[256],fnvz[256];
|
||||
sprintf( fnx, "___ic_temp_%05d.bin", 100*id_dm_pos+0 );
|
||||
sprintf( fny, "___ic_temp_%05d.bin", 100*id_dm_pos+1 );
|
||||
sprintf( fnz, "___ic_temp_%05d.bin", 100*id_dm_pos+2 );
|
||||
sprintf( fnvx, "___ic_temp_%05d.bin", 100*id_dm_vel+0 );
|
||||
sprintf( fnvy, "___ic_temp_%05d.bin", 100*id_dm_vel+1 );
|
||||
sprintf( fnvz, "___ic_temp_%05d.bin", 100*id_dm_vel+2 );
|
||||
snprintf( fnx, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+0 );
|
||||
snprintf( fny, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+1 );
|
||||
snprintf( fnz, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+2 );
|
||||
snprintf( fnvx, 256, "___ic_temp_%05d.bin", 100*id_dm_vel+0 );
|
||||
snprintf( fnvy, 256, "___ic_temp_%05d.bin", 100*id_dm_vel+1 );
|
||||
snprintf( fnvz, 256, "___ic_temp_%05d.bin", 100*id_dm_vel+2 );
|
||||
|
||||
// create buffers for temporary data
|
||||
T_store *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp6;
|
||||
|
@ -422,13 +422,13 @@ class cart_output_plugin : public output_plugin
|
|||
|
||||
// generate all temp file names
|
||||
char fnx[256],fny[256],fnz[256],fnvx[256],fnvy[256],fnvz[256],fnpma[256]; //add fields here
|
||||
sprintf( fnx, "___ic_temp_%05d.bin", 100*id_gas_pos+0 );
|
||||
sprintf( fny, "___ic_temp_%05d.bin", 100*id_gas_pos+1 );
|
||||
sprintf( fnz, "___ic_temp_%05d.bin", 100*id_gas_pos+2 );
|
||||
sprintf( fnvx, "___ic_temp_%05d.bin", 100*id_gas_vel+0 );
|
||||
sprintf( fnvy, "___ic_temp_%05d.bin", 100*id_gas_vel+1 );
|
||||
sprintf( fnvz, "___ic_temp_%05d.bin", 100*id_gas_vel+2 );
|
||||
sprintf( fnpma, "___ic_temp_%05d.bin", 100*id_gas_pma ); //add fields here
|
||||
snprintf( fnx, 256, "___ic_temp_%05d.bin", 100*id_gas_pos+0 );
|
||||
snprintf( fny, 256, "___ic_temp_%05d.bin", 100*id_gas_pos+1 );
|
||||
snprintf( fnz, 256, "___ic_temp_%05d.bin", 100*id_gas_pos+2 );
|
||||
snprintf( fnvx, 256, "___ic_temp_%05d.bin", 100*id_gas_vel+0 );
|
||||
snprintf( fnvy, 256, "___ic_temp_%05d.bin", 100*id_gas_vel+1 );
|
||||
snprintf( fnvz, 256, "___ic_temp_%05d.bin", 100*id_gas_vel+2 );
|
||||
snprintf( fnpma,256, "___ic_temp_%05d.bin", 100*id_gas_pma ); //add fields here
|
||||
|
||||
// create buffers for temporary data
|
||||
T_store *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp6, *tmp7; //add fields here
|
||||
|
@ -668,7 +668,7 @@ class cart_output_plugin : public output_plugin
|
|||
double xfac = (double) header_.NGRIDC;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_pos+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(T_store)*nptot;
|
||||
|
@ -746,7 +746,7 @@ class cart_output_plugin : public output_plugin
|
|||
//snl exit(1);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_vel+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_vel+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(T_store)*nptot;
|
||||
|
@ -819,7 +819,7 @@ class cart_output_plugin : public output_plugin
|
|||
}
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_gas_vel+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_gas_vel+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(T_store)*nptot;
|
||||
|
@ -873,7 +873,7 @@ class cart_output_plugin : public output_plugin
|
|||
|
||||
// write gas positions to cell centers
|
||||
for (int coord=0; coord < 3; coord++ ) {
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_gas_pos+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_gas_pos+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
ofs_temp.write( (char *)&blksize, sizeof(size_t) );
|
||||
|
||||
|
@ -924,7 +924,7 @@ class cart_output_plugin : public output_plugin
|
|||
{
|
||||
double pmafac = header_.Omb0 / header_.Om0 ;
|
||||
double pma;
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_gas_pma);
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_gas_pma);
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
ofs_temp.write( (char *)&blksize, sizeof(size_t) );
|
||||
|
||||
|
|
|
@ -106,11 +106,11 @@ protected:
|
|||
size_t nsz[3] = {size_t(ng[2]), size_t(ng[1]), size_t(ng[0])};
|
||||
|
||||
if (levelmin_ != levelmax_)
|
||||
sprintf(enzoname, "%s.%d", fieldname.c_str(), ilevel - levelmin_);
|
||||
snprintf(enzoname, 256, "%s.%d", fieldname.c_str(), ilevel - levelmin_);
|
||||
else
|
||||
sprintf(enzoname, "%s", fieldname.c_str());
|
||||
snprintf(enzoname, 256, "%s", fieldname.c_str());
|
||||
|
||||
sprintf(filename, "%s/%s", fname_.c_str(), enzoname);
|
||||
snprintf(filename, 512, "%s/%s", fname_.c_str(), enzoname);
|
||||
|
||||
HDFCreateFile(filename);
|
||||
write_sim_header(filename, the_sim_header);
|
||||
|
@ -221,11 +221,11 @@ protected:
|
|||
size_t nsz[3] = {size_t(ng[2]), size_t(ng[1]), size_t(ng[0])};
|
||||
|
||||
if (levelmin_ != levelmax_)
|
||||
sprintf(enzoname, "%s.%d", fieldname.c_str(), ilevel - levelmin_);
|
||||
snprintf(enzoname, 256, "%s.%d", fieldname.c_str(), ilevel - levelmin_);
|
||||
else
|
||||
sprintf(enzoname, "%s", fieldname.c_str());
|
||||
snprintf(enzoname, 256, "%s", fieldname.c_str());
|
||||
|
||||
sprintf(filename, "%s/%s", fname_.c_str(), enzoname);
|
||||
snprintf(filename, 512, "%s/%s", fname_.c_str(), enzoname);
|
||||
|
||||
HDFCreateFile(filename);
|
||||
write_sim_header(filename, the_sim_header);
|
||||
|
@ -355,7 +355,7 @@ public:
|
|||
|
||||
// write out a parameter file
|
||||
|
||||
sprintf(filename, "%s/parameter_file.txt", fname_.c_str());
|
||||
snprintf(filename, 256, "%s/parameter_file.txt", fname_.c_str());
|
||||
|
||||
std::ofstream ofs(filename, std::ios::trunc);
|
||||
|
||||
|
@ -551,7 +551,7 @@ public:
|
|||
void write_dm_velocity(int coord, const grid_hierarchy &gh)
|
||||
{
|
||||
char enzoname[256];
|
||||
sprintf(enzoname, "ParticleVelocities_%c", (char)('x' + coord));
|
||||
snprintf(enzoname, 256, "ParticleVelocities_%c", (char)('x' + coord));
|
||||
|
||||
double vunit = 1.0 / (1.225e2 * sqrt(the_sim_header.omega_m / the_sim_header.a_start));
|
||||
|
||||
|
@ -561,7 +561,7 @@ public:
|
|||
void write_dm_position(int coord, const grid_hierarchy &gh)
|
||||
{
|
||||
char enzoname[256];
|
||||
sprintf(enzoname, "ParticleDisplacements_%c", (char)('x' + coord));
|
||||
snprintf(enzoname, 256, "ParticleDisplacements_%c", (char)('x' + coord));
|
||||
|
||||
dump_grid_data(enzoname, gh);
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ public:
|
|||
double vunit = 1.0 / (1.225e2 * sqrt(the_sim_header.omega_m / the_sim_header.a_start));
|
||||
|
||||
char enzoname[256];
|
||||
sprintf(enzoname, "GridVelocities_%c", (char)('x' + coord));
|
||||
snprintf(enzoname, 256, "GridVelocities_%c", (char)('x' + coord));
|
||||
dump_grid_data(enzoname, gh, vunit);
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ public:
|
|||
{
|
||||
|
||||
char enzoname[256];
|
||||
sprintf(enzoname, "GridDensity");
|
||||
snprintf(enzoname, 256, "GridDensity");
|
||||
dump_grid_data(enzoname, gh, the_sim_header.omega_b / the_sim_header.omega_m, 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ protected:
|
|||
assert(n2dist[i] == 0);
|
||||
}
|
||||
|
||||
std::ifstream &open_and_check(std::string ffname, size_t npart, size_t offset = 0)
|
||||
std::ifstream open_and_check(std::string ffname, size_t npart, size_t offset = 0)
|
||||
{
|
||||
std::ifstream ifs(ffname.c_str(), std::ios::binary);
|
||||
size_t blk;
|
||||
|
@ -284,8 +284,8 @@ protected:
|
|||
|
||||
/*** positions ***/
|
||||
|
||||
sprintf(fc, "___ic_temp_%05d.bin", 100 * id_dm_pos + icomp);
|
||||
sprintf(fb, "___ic_temp_%05d.bin", 100 * id_gas_pos + icomp);
|
||||
snprintf(fc, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + icomp);
|
||||
snprintf(fb, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + icomp);
|
||||
|
||||
iffs1.open(fc, nptot, npfine * sizeof(T_store));
|
||||
iffs2.open(fb, nptot, npfine * sizeof(T_store));
|
||||
|
@ -315,8 +315,8 @@ protected:
|
|||
|
||||
/*** velocities ***/
|
||||
|
||||
sprintf(fc, "___ic_temp_%05d.bin", 100 * id_dm_vel + icomp);
|
||||
sprintf(fb, "___ic_temp_%05d.bin", 100 * id_gas_vel + icomp);
|
||||
snprintf(fc, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + icomp);
|
||||
snprintf(fb, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + icomp);
|
||||
|
||||
iffs1.open(fc, nptot, npfine * sizeof(T_store));
|
||||
iffs2.open(fb, nptot, npfine * sizeof(T_store));
|
||||
|
@ -359,20 +359,20 @@ protected:
|
|||
char fnx[256], fny[256], fnz[256], fnvx[256], fnvy[256], fnvz[256], fnm[256];
|
||||
char fnbx[256], fnby[256], fnbz[256], fnbvx[256], fnbvy[256], fnbvz[256];
|
||||
|
||||
sprintf(fnx, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
sprintf(fny, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
sprintf(fnz, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
sprintf(fnvx, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
sprintf(fnvy, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
sprintf(fnvz, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
sprintf(fnm, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf(fnx, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
snprintf(fny, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
snprintf(fnz, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
snprintf(fnvx, 256,"___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
snprintf(fnvy, 256,"___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
snprintf(fnvz, 256,"___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
snprintf(fnm, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
|
||||
sprintf(fnbx, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
sprintf(fnby, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
sprintf(fnbz, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
sprintf(fnbvx, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
sprintf(fnbvy, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
sprintf(fnbvz, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
snprintf(fnbx, 256,"___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
snprintf(fnby, 256,"___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
snprintf(fnbz, 256,"___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
snprintf(fnbvx,256,"___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
snprintf(fnbvy,256,"___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
snprintf(fnbvz,256,"___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
|
||||
pistream iffs1, iffs2, iffs3;
|
||||
|
||||
|
@ -440,7 +440,7 @@ protected:
|
|||
if (nfiles_ > 1)
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname, "%s.%d", fname_.c_str(), ifile);
|
||||
snprintf(ffname, 256, "%s.%d", fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary | std::ios::trunc);
|
||||
}
|
||||
else
|
||||
|
@ -833,7 +833,7 @@ public:
|
|||
for (unsigned ifile = 0; ifile < nfiles_; ++ifile)
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname, "%s.%d", fname_.c_str(), ifile);
|
||||
snprintf(ffname, 256, "%s.%d", fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary | std::ios::trunc);
|
||||
if (!ofs_.good())
|
||||
{
|
||||
|
@ -1011,7 +1011,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * npcoarse;
|
||||
|
@ -1090,7 +1090,7 @@ public:
|
|||
temp_data.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * npart;
|
||||
|
@ -1167,7 +1167,7 @@ public:
|
|||
size_t nwritten = 0;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * npart;
|
||||
|
@ -1245,7 +1245,7 @@ public:
|
|||
size_t nwritten = 0;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * npart;
|
||||
|
@ -1314,7 +1314,7 @@ public:
|
|||
temp_data.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof(T_store) * npart;
|
||||
|
|
|
@ -115,7 +115,7 @@ protected:
|
|||
nc_pf[nfiles - 1] += ncoarse - nc_assigned;
|
||||
}
|
||||
|
||||
std::ifstream &open_and_check(std::string ffname, size_t npart)
|
||||
std::ifstream open_and_check(std::string ffname, size_t npart)
|
||||
{
|
||||
std::ifstream ifs(ffname.c_str(), std::ios::binary);
|
||||
unsigned long long blk, expected;
|
||||
|
@ -253,20 +253,20 @@ protected:
|
|||
char fnx[256], fny[256], fnz[256], fnvx[256], fnvy[256], fnvz[256], fnm[256];
|
||||
char fnbx[256], fnby[256], fnbz[256], fnbvx[256], fnbvy[256], fnbvz[256];
|
||||
|
||||
sprintf(fnx, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
sprintf(fny, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
sprintf(fnz, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
sprintf(fnvx, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
sprintf(fnvy, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
sprintf(fnvz, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
sprintf(fnm, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf(fnx, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
snprintf(fny, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
snprintf(fnz, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
snprintf(fnvx,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
snprintf(fnvy,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
snprintf(fnvz,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
snprintf(fnm, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
|
||||
sprintf(fnbx, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
sprintf(fnby, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
sprintf(fnbz, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
sprintf(fnbvx, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
sprintf(fnbvy, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
sprintf(fnbvz, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
snprintf(fnbx, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
snprintf(fnby, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
snprintf(fnbz, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
snprintf(fnbvx,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
snprintf(fnbvy,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
snprintf(fnbvz,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
|
||||
pistream iffs1, iffs2, iffs3;
|
||||
|
||||
|
@ -342,7 +342,7 @@ protected:
|
|||
if (nfiles_ > 1)
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname, "%s.%d", fname_.c_str(), ifile);
|
||||
snprintf(ffname, 256, "%s.%d", fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary | std::ios::trunc);
|
||||
}
|
||||
else
|
||||
|
@ -720,7 +720,7 @@ public:
|
|||
for (unsigned ifile = 0; ifile < nfiles_; ++ifile)
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname, "%s.%d", fname_.c_str(), ifile);
|
||||
snprintf(ffname, 256,"%s.%d", fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary | std::ios::trunc);
|
||||
if (!ofs_.good())
|
||||
{
|
||||
|
@ -833,7 +833,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
unsigned long long blksize = sizeof(T_store) * npcoarse;
|
||||
|
@ -936,7 +936,7 @@ public:
|
|||
double xfac = header_.BoxSize;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
//... if baryons are present, then stagger the two fields
|
||||
|
@ -1141,7 +1141,7 @@ public:
|
|||
unsigned long long blksize;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
if (!do_glass_)
|
||||
|
@ -1292,7 +1292,7 @@ public:
|
|||
unsigned nwritten = 0;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
unsigned long long blksize;
|
||||
|
@ -1459,7 +1459,7 @@ public:
|
|||
temp_data.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf(temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + coord);
|
||||
std::ofstream ofs_temp(temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
unsigned long long blksize;
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
typedef float MyFloat;
|
||||
typedef long long MyIDType;
|
||||
|
||||
const int vert[8][3] = { {0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1} };
|
||||
// const int vert[8][3] = { {0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1} };
|
||||
const MyIDType vert_long[8][3] = { {0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1} };
|
||||
const int conn[][4] = { {1,0,2,4}, {3,1,2,4}, {3,5,1,4}, {3,6,5,4}, {3,2,6,4}, {3,7,5,6} };
|
||||
// const int conn[][4] = { {1,0,2,4}, {3,1,2,4}, {3,5,1,4}, {3,6,5,4}, {3,2,6,4}, {3,7,5,6} };
|
||||
|
||||
|
||||
std::map<MyIDType,size_t> idmap;
|
||||
|
@ -513,7 +513,7 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
std::ifstream& open_and_check( std::string ffname, size_t blksize, size_t offset=0 )
|
||||
std::ifstream open_and_check( std::string ffname, size_t blksize, size_t offset=0 )
|
||||
{
|
||||
std::ifstream ifs( ffname.c_str(), std::ios::binary );
|
||||
size_t blk;
|
||||
|
@ -594,17 +594,17 @@ protected:
|
|||
char fnx[256],fny[256],fnz[256],fnvx[256],fnvy[256],fnvz[256],fnm[256];
|
||||
char fnc[256], fnl[256], fnlid[256];
|
||||
|
||||
sprintf( fnx, "___ic_temp_%05d.bin", 100*id_dm_pos+0 );
|
||||
sprintf( fny, "___ic_temp_%05d.bin", 100*id_dm_pos+1 );
|
||||
sprintf( fnz, "___ic_temp_%05d.bin", 100*id_dm_pos+2 );
|
||||
sprintf( fnvx, "___ic_temp_%05d.bin", 100*id_dm_vel+0 );
|
||||
sprintf( fnvy, "___ic_temp_%05d.bin", 100*id_dm_vel+1 );
|
||||
sprintf( fnvz, "___ic_temp_%05d.bin", 100*id_dm_vel+2 );
|
||||
sprintf( fnm, "___ic_temp_%05d.bin", 100*id_dm_mass );
|
||||
snprintf( fnx, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+0 );
|
||||
snprintf( fny, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+1 );
|
||||
snprintf( fnz, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+2 );
|
||||
snprintf( fnvx,256, "___ic_temp_%05d.bin", 100*id_dm_vel+0 );
|
||||
snprintf( fnvy,256, "___ic_temp_%05d.bin", 100*id_dm_vel+1 );
|
||||
snprintf( fnvz,256, "___ic_temp_%05d.bin", 100*id_dm_vel+2 );
|
||||
snprintf( fnm, 256, "___ic_temp_%05d.bin", 100*id_dm_mass );
|
||||
|
||||
sprintf( fnc, "___ic_temp_%05d.bin", 100*id_dm_conn );
|
||||
sprintf( fnl, "___ic_temp_%05d.bin", 100*id_dm_level );
|
||||
sprintf( fnlid, "___ic_temp_%05d.bin", 100*id_dm_lagrangeid );
|
||||
snprintf( fnc, 256, "___ic_temp_%05d.bin", 100*id_dm_conn );
|
||||
snprintf( fnl, 256, "___ic_temp_%05d.bin", 100*id_dm_level );
|
||||
snprintf( fnlid, 256, "___ic_temp_%05d.bin", 100*id_dm_lagrangeid );
|
||||
|
||||
pistream iffs1, iffs2, iffs3;
|
||||
|
||||
|
@ -663,7 +663,7 @@ protected:
|
|||
if( nfiles_ > 1 )
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname,"%s.%d",fname_.c_str(), ifile);
|
||||
snprintf(ffname,256,"%s.%d",fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary|std::ios::trunc );
|
||||
}else{
|
||||
ofs_.open(fname_.c_str(), std::ios::binary|std::ios::trunc );
|
||||
|
@ -939,7 +939,7 @@ public:
|
|||
for( unsigned ifile=0; ifile<nfiles_; ++ifile )
|
||||
{
|
||||
char ffname[256];
|
||||
sprintf(ffname,"%s.%d",fname_.c_str(), ifile);
|
||||
snprintf(ffname,256,"%s.%d",fname_.c_str(), ifile);
|
||||
ofs_.open(ffname, std::ios::binary|std::ios::trunc );
|
||||
if(!ofs_.good())
|
||||
{
|
||||
|
@ -1062,7 +1062,7 @@ public:
|
|||
if( P[ip].Level != ilevel || !P[ip].can_refine() )
|
||||
continue;
|
||||
|
||||
MyIDType lidsum = 0, xc[3] = {0,0,0};
|
||||
MyIDType xc[3] = {0,0,0};
|
||||
|
||||
bool foundall = true;
|
||||
bool dorefine = true;
|
||||
|
@ -1116,7 +1116,7 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
lidsum += lid;
|
||||
// lidsum += lid;
|
||||
}
|
||||
|
||||
if( !foundall ) continue;
|
||||
|
@ -1206,7 +1206,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_mass );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_mass );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
double mfac = header_.Omega0 * rhoc * pow(header_.BoxSize,3.);
|
||||
|
@ -1264,7 +1264,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_conn );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_conn );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(long long)*num_p*8;
|
||||
|
@ -1323,7 +1323,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_level );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_level );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(int)*num_p;
|
||||
|
@ -1369,7 +1369,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_lagrangeid );
|
||||
snprintf( temp_fname, 256,"___ic_temp_%05d.bin", 100*id_dm_lagrangeid );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
size_t blksize = sizeof(size_t)*num_p;
|
||||
|
@ -1420,7 +1420,7 @@ public:
|
|||
double xfac = header_.BoxSize;
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_pos+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_pos+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
// write all particle masses
|
||||
|
@ -1486,7 +1486,7 @@ public:
|
|||
temp_dat.reserve(block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf( temp_fname, "___ic_temp_%05d.bin", 100*id_dm_vel+coord );
|
||||
snprintf( temp_fname, 256, "___ic_temp_%05d.bin", 100*id_dm_vel+coord );
|
||||
std::ofstream ofs_temp( temp_fname, std::ios::binary|std::ios::trunc );
|
||||
|
||||
// write all particle masses
|
||||
|
|
|
@ -70,11 +70,11 @@ public:
|
|||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
if( coord == 0 )
|
||||
sprintf(sstr,"level_%03d_DM_vx",ilevel);
|
||||
snprintf(sstr,128, "level_%03d_DM_vx",ilevel);
|
||||
else if( coord == 1 )
|
||||
sprintf(sstr,"level_%03d_DM_vy",ilevel);
|
||||
snprintf(sstr,128, "level_%03d_DM_vy",ilevel);
|
||||
else if( coord == 2 )
|
||||
sprintf(sstr,"level_%03d_DM_vz",ilevel);
|
||||
snprintf(sstr,128, "level_%03d_DM_vz",ilevel);
|
||||
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ public:
|
|||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
if( coord == 0 )
|
||||
sprintf(sstr,"level_%03d_DM_dx",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_DM_dx",ilevel);
|
||||
else if( coord == 1 )
|
||||
sprintf(sstr,"level_%03d_DM_dy",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_DM_dy",ilevel);
|
||||
else if( coord == 2 )
|
||||
sprintf(sstr,"level_%03d_DM_dz",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_DM_dz",ilevel);
|
||||
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
|
||||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
sprintf(sstr,"level_%03d_DM_rho",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_DM_rho",ilevel);
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
sprintf(sstr,"level_%03d_DM_potential",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_DM_potential",ilevel);
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
|
||||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
sprintf(sstr,"level_%03d_BA_potential",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_BA_potential",ilevel);
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
}
|
||||
|
@ -216,11 +216,11 @@ public:
|
|||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
if( coord == 0 )
|
||||
sprintf(sstr,"level_%03d_BA_vx",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_BA_vx",ilevel);
|
||||
else if( coord == 1 )
|
||||
sprintf(sstr,"level_%03d_BA_vy",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_BA_vy",ilevel);
|
||||
else if( coord == 2 )
|
||||
sprintf(sstr,"level_%03d_BA_vz",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_BA_vz",ilevel);
|
||||
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ public:
|
|||
|
||||
for( unsigned ilevel=0; ilevel<=levelmax_; ++ilevel )
|
||||
{
|
||||
sprintf(sstr,"level_%03d_BA_rho",ilevel);
|
||||
snprintf(sstr,128,"level_%03d_BA_rho",ilevel);
|
||||
write2HDF5( fname_, sstr, *gh.get_grid(ilevel) );
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -270,8 +270,8 @@ protected:
|
|||
|
||||
/*** positions ***/
|
||||
|
||||
sprintf (fc, "___ic_temp_%05d.bin", 100 * id_dm_pos + icomp);
|
||||
sprintf (fb, "___ic_temp_%05d.bin", 100 * id_gas_pos + icomp);
|
||||
snprintf (fc, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + icomp);
|
||||
snprintf (fb, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + icomp);
|
||||
|
||||
iffs1.open (fc, nptot, npfine * sizeof (T_store));
|
||||
iffs2.open (fb, nptot, npfine * sizeof (T_store));
|
||||
|
@ -301,8 +301,8 @@ protected:
|
|||
|
||||
/*** velocities ***/
|
||||
|
||||
sprintf (fc, "___ic_temp_%05d.bin", 100 * id_dm_vel + icomp);
|
||||
sprintf (fb, "___ic_temp_%05d.bin", 100 * id_gas_vel + icomp);
|
||||
snprintf (fc, 256, "___ic_temp_%05d.bin", 100 * id_dm_vel + icomp);
|
||||
snprintf (fb, 256, "___ic_temp_%05d.bin", 100 * id_gas_vel + icomp);
|
||||
|
||||
iffs1.open (fc, nptot, npfine * sizeof (T_store));
|
||||
iffs2.open (fb, nptot, npfine * sizeof (T_store));
|
||||
|
@ -351,21 +351,21 @@ protected:
|
|||
char fnbx[256], fnby[256], fnbz[256], fnbvx[256], fnbvy[256], fnbvz[256],
|
||||
fnbm[256];
|
||||
|
||||
sprintf (fnx, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
sprintf (fny, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
sprintf (fnz, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
sprintf (fnvx, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
sprintf (fnvy, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
sprintf (fnvz, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
sprintf (fnm, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf (fnx, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 0);
|
||||
snprintf (fny, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 1);
|
||||
snprintf (fnz, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + 2);
|
||||
snprintf (fnvx,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 0);
|
||||
snprintf (fnvy,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 1);
|
||||
snprintf (fnvz,256, "___ic_temp_%05d.bin", 100 * id_dm_vel + 2);
|
||||
snprintf (fnm, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
|
||||
sprintf (fnbx, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
sprintf (fnby, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
sprintf (fnbz, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
sprintf (fnbvx, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
sprintf (fnbvy, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
sprintf (fnbvz, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
sprintf (fnbm, "___ic_temp_%05d.bin", 100 * id_gas_mass);
|
||||
snprintf (fnbx, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 0);
|
||||
snprintf (fnby, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 1);
|
||||
snprintf (fnbz, 256, "___ic_temp_%05d.bin", 100 * id_gas_pos + 2);
|
||||
snprintf (fnbvx,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 0);
|
||||
snprintf (fnbvy,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 1);
|
||||
snprintf (fnbvz,256, "___ic_temp_%05d.bin", 100 * id_gas_vel + 2);
|
||||
snprintf (fnbm, 256, "___ic_temp_%05d.bin", 100 * id_gas_mass);
|
||||
|
||||
|
||||
pistream ifs_x, ifs_y, ifs_z, ifs_vx, ifs_vy, ifs_vz, ifs_m;
|
||||
|
@ -641,13 +641,13 @@ public:
|
|||
|
||||
unsigned levelmax = cf_.get_value<unsigned>("setup","levelmax");
|
||||
|
||||
sprintf(tempstr,"size(%d,0)",levelmax);
|
||||
snprintf(tempstr,256,"size(%d,0)",levelmax);
|
||||
nfine[0] = cf_.get_value<unsigned>("setup",tempstr);
|
||||
|
||||
sprintf(tempstr,"size(%d,1)",levelmax);
|
||||
snprintf(tempstr,256,"size(%d,1)",levelmax);
|
||||
nfine[1] = cf_.get_value<unsigned>("setup",tempstr);
|
||||
|
||||
sprintf(tempstr,"size(%d,2)",levelmax);
|
||||
snprintf(tempstr,256,"size(%d,2)",levelmax);
|
||||
nfine[2] = cf_.get_value<unsigned>("setup",tempstr);
|
||||
|
||||
if( nfine[0]!=nfine[1] || nfine[0]!=nfine[2] )
|
||||
|
@ -658,7 +658,7 @@ public:
|
|||
|
||||
double resfac = (double)nfine[0]/(double)np_resample_;
|
||||
|
||||
sprintf(tempstr,"%g",resfac*0.5);
|
||||
snprintf(tempstr,256,"%g",resfac*0.5);
|
||||
cf_.insert_value("setup","baryon_staggering",std::string(tempstr));
|
||||
|
||||
cf_.insert_value("output","glass_cicdeconvolve","yes");
|
||||
|
@ -716,7 +716,7 @@ public:
|
|||
temp_dat.reserve (block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf (temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_mass);
|
||||
std::ofstream ofs_temp (temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
|
||||
|
@ -801,7 +801,7 @@ public:
|
|||
temp_dat.reserve (block_buf_size_);
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf (temp_fname, "___ic_temp_%05d.bin", 100 * id_gas_mass);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_gas_mass);
|
||||
ofs_temp.open (temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
|
||||
|
@ -950,7 +950,7 @@ public:
|
|||
|
||||
|
||||
char temp_fname[256];
|
||||
sprintf (temp_fname, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
snprintf(temp_fname, 256, "___ic_temp_%05d.bin", 100 * id_dm_pos + coord);
|
||||
std::ofstream ofs_temp (temp_fname, std::ios::binary | std::ios::trunc);
|
||||
|
||||
size_t blksize = sizeof (T_store) * nptot |