Commit 99eb98cd authored by stefanwessel's avatar stefanwessel
Browse files

added support for skipping initial bins while merging data (banana test for thermalization)

git-svn-id: https://svn.rwth-aachen.de/repos/sw440870_load_leveller/trunk@25 36cca2a8-63f0-4188-8a56-663e3b0d1cf3
parent a90e615b
......@@ -332,7 +332,7 @@ bool measurements :: read(std::string path) {
}
bool measurements :: merge(std::string path) {
bool measurements :: merge(std::string path, int skipbins) {
if (appendmode()) {
std::string lfn=path+"meas";
std::string lfnd=path+"data";
......@@ -343,7 +343,7 @@ bool measurements :: merge(std::string path) {
}
idump lbd(lfn.c_str());
idump lbdd(lfnd.c_str());
bool success=merge_appendmode(lbd,lbdd);
bool success=merge_appendmode(lbd,lbdd,skipbins);
lbd.close();
lbdd.close();
return success;
......@@ -351,7 +351,7 @@ bool measurements :: merge(std::string path) {
else {
std::string lfn=path+"meas";
idump lbd(lfn.c_str());
bool success=merge(lbd);
bool success=merge(lbd,skipbins);
lbd.close();
return success;
}
......@@ -390,19 +390,33 @@ bool measurements :: read(idump& bd) {
}
bool measurements :: merge(idump& bd) {
bool measurements :: merge(idump& bd, int skipbins) {
if (!bd)
return false;
else {
bool madeit=true;
if((obs_v.size() == 0))
read(bd);
if((obs_v.size() == 0)) {
uint number_of_observables;
bd.read(number_of_observables);
for (uint i=0;i<number_of_observables;++i) {
observable *o = new observable("",1,1,1);
if (o->read(bd,skipbins)) {
obs_v.push_back(o);
eo[o->name()]=obs_v.size()-1;
tag[o->name()]=1;
}
else {
madeit=false;
break;
}
}
}
else {
uint number_of_observables;
bd.read(number_of_observables);
//std::cout << number_of_observables <<" observables" <<std::endl;
for (uint i=0;i<number_of_observables;++i) {
if (!(obs_v[i]->merge(bd))) {
if (!(obs_v[i]->merge(bd,skipbins))) {
madeit=false;
break;
}
......@@ -445,16 +459,17 @@ bool measurements :: read_appendmode(idump& bd) {
}
bool measurements :: merge_appendmode(idump& bd, idump& bdd) {
bool measurements :: merge_appendmode(idump& bd, idump& bdd, int skipbins) {
if (skipbins) {cout <<" bool measurements :: merge_appendmode(idump& bd, idump& bdd, int skipbins) NOT IMPLEMENTED FOR FINITE skipbins"<<endl;exit(-1);}
if (!bd) return false;
uint number_of_observables;
bd.read(number_of_observables);
bd.read(chunks);
bool madeit=true;
//std::cout << chunks << " chunks, " << number_of_observables <<" obs." <<std::endl;
std::cout << " (" << chunks << " chunks, " << number_of_observables <<" observables) ";
for (uint cn=1;cn<=chunks;++cn) { //now, we load all the data
for (uint i=0;i<number_of_observables;++i) {
if (!(obs_v[i]->merge_appendmode(bdd))) {
if (!(obs_v[i]->merge_appendmode(bdd,skipbins))) {
madeit=false;
break;
}
......
......@@ -193,17 +193,20 @@ class measurements
return (MCL_MEASUREMENTS_APPEND==1) ? true : false;
}
void rebin(int new_bin_length) {for (uint i=0;i<obs_v.size();++i) obs_v[i]->rebin(new_bin_length);}
void write(odump&);
bool read(idump&);
bool merge(idump&);
bool merge(idump&,int skipbins=0);
void write_appendmode(odump&,odump&);
bool read_appendmode(idump&);
bool merge_appendmode(idump&,idump&);
bool merge_appendmode(idump&,idump&,int skipbins=0);
void write(std::string);
bool read(std::string);
bool merge(std::string);
bool merge(std::string,int skipbins=0);
void reset();
void clear();
......
......@@ -104,6 +104,7 @@ void observable :: rebin(int new_bin_length) {
}
void observable :: get_statistics(ostream& os) {
#ifdef GET_STATISTICS_COUT
cout <<" "<< name_ <<" with "<< bins() <<" bins "<<endl;
......@@ -299,6 +300,7 @@ void observable :: binning(){
}
}
void observable :: reset()
{
length = initial_length;
......@@ -323,7 +325,7 @@ void observable :: write(odump& d)
d.write(&samples[0],(current_bin+1)*vector_length_);
}
bool observable :: read(idump& d)
bool observable :: read(idump& d, int skipbins)
{
if (!d)
return false;
......@@ -335,15 +337,26 @@ bool observable :: read(idump& d)
d.read(initial_length);
d.read(current_bin);
d.read(current_bin_filling);
samples.resize(length*vector_length_,0);
d.read(&samples[0],(current_bin+1)*vector_length_);
if (skipbins) {
samples.resize(length*vector_length_,0);
if (skipbins>current_bin) skipbins=current_bin;
samples.resize(length*vector_length_,0);
d.read(&samples[0],(skipbins)*vector_length_);
samples.resize(length*vector_length_,0);
d.read(&samples[0],(current_bin+1-skipbins)*vector_length_);
current_bin-=skipbins;
}
else {
samples.resize(length*vector_length_,0);
d.read(&samples[0],(current_bin+1)*vector_length_);
}
analysis_done=0;
simple_analysis_done=0;
return true;
}
}
bool observable :: merge(idump& d, int check_bin_length)
bool observable :: merge(idump& d, int skipbins, int check_bin_length)
{
if (!d)
return false;
......@@ -367,14 +380,27 @@ bool observable :: merge(idump& d, int check_bin_length)
d.read(current_binm);
luint current_bin_fillingm;
d.read(current_bin_fillingm);
length+=current_binm;
valarray<double> old=samples;
samples.resize(length*vector_length_);
if (current_binm) d.read(&samples[0],current_binm*vector_length_);
samples[slice(current_binm*vector_length_,old.size(),1)]=old;
if (skipbins) {
if (skipbins>current_binm) skipbins=current_binm;
length+=current_binm-skipbins;
samples.resize(length*vector_length_,0);
d.read(&samples[0],skipbins*vector_length_);
samples.resize(length*vector_length_,0);
d.read(&samples[0],(current_binm-skipbins)*vector_length_);
current_bin+=current_binm-skipbins;
}
else {
length+=current_binm;
samples.resize(length*vector_length_,0);
if (current_binm)
d.read(&samples[0],current_binm*vector_length_);
samples[slice(current_binm*vector_length_,old.size(),1)]=old;
current_bin+=current_binm;
}
d.read(&old[0],vector_lengthm);//the last bin from file
//is not full and we not merge it
current_bin+=current_binm;
//but we still need to read it in b/c other observables usually follow
analysis_done=0;
simple_analysis_done=0;
}
......@@ -411,7 +437,8 @@ void observable :: write_appendmode(odump& d,odump& dd)
bool observable :: read_appendmode(idump& d)
{
{ //here, we read in only the current bin, not all previous bins
//to access the full data, use merge, which can be used to read in all previous bins from all chunks
if (!d) return false;
d.read(name_);
d.read(vector_length_);
......@@ -427,7 +454,7 @@ bool observable :: read_appendmode(idump& d)
return true;
}
bool observable :: merge_appendmode(idump& dd, int check_bin_length)
bool observable :: merge_appendmode(idump& dd, int skipbins, int check_bin_length)
{
if (!dd)
return false;
......
......@@ -65,12 +65,16 @@ class observable
void reset();
void write(odump&);
bool read(idump&);
bool merge(idump&, int check_bin_length=0);
bool read(idump&, int skipbins=0);
bool merge(idump& id) {return merge(id,0,0);}
bool merge(idump& id, int skipbins) {return merge(id,skipbins,0);}
bool merge(idump& id, int skipbins, int check_bin_length);
void write_appendmode(odump&,odump&); //separates data/structural info on observable; data output is appended
bool read_appendmode(idump&);
bool merge_appendmode(idump&, int check_bin_length=0);
bool merge_appendmode(idump& id) {return merge_appendmode(id,0,0);}
bool merge_appendmode(idump& id, int skipbins) {return merge_appendmode(id,skipbins,0);}
bool merge_appendmode(idump& id, int skipbins, int check_bin_length);
void analyse() {binning();simple_analysis_done=true;analysis_done=true;}
void simple_analyse() {simple();simple_analysis_done=true;}
......
......@@ -27,6 +27,8 @@ struct one_task
{
int task_id;
int is_done;
int n_bins;
int bins_done;
int n_steps;
int steps_done;
int mes_done;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment