From 4d25d4114e09fa6c823f0644f873c714d3134b06 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" Date: Thu, 19 Mar 2020 21:21:54 +0100 Subject: [PATCH] Add fixed iK filtering of raw files --- src/EXECS/Produce_Filtered_RAW_File_for_iK.cc | 34 ++++++++++ src/UTILS/Filter_RAW_File_for_iK.cc | 62 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/EXECS/Produce_Filtered_RAW_File_for_iK.cc create mode 100644 src/UTILS/Filter_RAW_File_for_iK.cc diff --git a/src/EXECS/Produce_Filtered_RAW_File_for_iK.cc b/src/EXECS/Produce_Filtered_RAW_File_for_iK.cc new file mode 100644 index 0000000..e3913b9 --- /dev/null +++ b/src/EXECS/Produce_Filtered_RAW_File_for_iK.cc @@ -0,0 +1,34 @@ +/********************************************************** + +This software is part of J.-S. Caux's ABACUS library. + +Copyright (c) J.-S. Caux. + +----------------------------------------------------------- + +File: Filter_RAW_File_for_iK.cc + +Purpose: produce a .raw file filtered for a specific iK + +***********************************************************/ + +#include "ABACUS.h" + +using namespace std; +using namespace ABACUS; + + +int main(int argc, char* argv[]) +{ + if (argc != 3) { + cout << "Arguments needed: rawfile, iKneeded." << endl; + ABACUSerror(""); + } + + const char* rawfilename = argv[1]; + int iKneeded = atoi(argv[2]); + + Filter_RAW_File_for_iK (rawfilename, iKneeded); + + return(0); +} diff --git a/src/UTILS/Filter_RAW_File_for_iK.cc b/src/UTILS/Filter_RAW_File_for_iK.cc new file mode 100644 index 0000000..c2882a2 --- /dev/null +++ b/src/UTILS/Filter_RAW_File_for_iK.cc @@ -0,0 +1,62 @@ +/********************************************************** + +This software is part of J.-S. Caux's ABACUS library. + +Copyright (c) J.-S. Caux. + +----------------------------------------------------------- + +File: Filter_RAW_File_for_iK.cc + +Purpose: for a given RAW file, keep only the momentum iK entries + +***********************************************************/ + +#include "ABACUS.h" + +using namespace std; + + +namespace ABACUS { + + void Filter_RAW_File_for_iK (const char ff_file[], int iKneeded) + { + DP omega; + int iK; + DP ff; + DP dev; + string label; + + ifstream infile; + infile.open(ff_file); + + if (infile.fail()) ABACUSerror("The input file was not opened successfully in Sort_RAW_File. "); + + stringstream outfilename; + string outfilename_string; + outfilename << ff_file << "_iK_" << iKneeded; + outfilename_string = outfilename.str(); + const char* outfilename_c_str = outfilename_string.c_str(); + + ofstream outfile; + outfile.open(outfilename_c_str); + outfile.precision(16); + + int Ndata = 0; + while ((infile.peek()) != EOF) { + + infile >> omega; + infile >> iK; + infile >> ff; + infile >> dev; + infile >> label; + + if (iK == iKneeded) outfile << endl << omega << "\t" << iK << "\t" << ff << "\t" << dev << "\t" << label; + } + infile.close(); + outfile.close(); + + return; + } + +} // namespace ABACUS