Browse Source

Add fixed iK filtering of raw files

master
J.-S. Caux 4 years ago
parent
commit
4d25d4114e
2 changed files with 96 additions and 0 deletions
  1. 34
    0
      src/EXECS/Produce_Filtered_RAW_File_for_iK.cc
  2. 62
    0
      src/UTILS/Filter_RAW_File_for_iK.cc

+ 34
- 0
src/EXECS/Produce_Filtered_RAW_File_for_iK.cc View File

@@ -0,0 +1,34 @@
1
+/**********************************************************
2
+
3
+This software is part of J.-S. Caux's ABACUS library.
4
+
5
+Copyright (c) J.-S. Caux.
6
+
7
+-----------------------------------------------------------
8
+
9
+File:  Filter_RAW_File_for_iK.cc
10
+
11
+Purpose:  produce a .raw file filtered for a specific iK
12
+
13
+***********************************************************/
14
+
15
+#include "ABACUS.h"
16
+
17
+using namespace std;
18
+using namespace ABACUS;
19
+
20
+
21
+int main(int argc, char* argv[])
22
+{
23
+  if (argc != 3) {
24
+    cout << "Arguments needed: rawfile, iKneeded." << endl;
25
+    ABACUSerror("");
26
+  }
27
+
28
+  const char* rawfilename = argv[1];
29
+  int iKneeded = atoi(argv[2]);
30
+
31
+  Filter_RAW_File_for_iK (rawfilename, iKneeded);
32
+
33
+  return(0);
34
+}

+ 62
- 0
src/UTILS/Filter_RAW_File_for_iK.cc View File

@@ -0,0 +1,62 @@
1
+/**********************************************************
2
+
3
+This software is part of J.-S. Caux's ABACUS library.
4
+
5
+Copyright (c) J.-S. Caux.
6
+
7
+-----------------------------------------------------------
8
+
9
+File:  Filter_RAW_File_for_iK.cc
10
+
11
+Purpose:  for a given RAW file, keep only the momentum iK entries
12
+
13
+***********************************************************/
14
+
15
+#include "ABACUS.h"
16
+
17
+using namespace std;
18
+
19
+
20
+namespace ABACUS {
21
+
22
+  void Filter_RAW_File_for_iK (const char ff_file[], int iKneeded)
23
+  {
24
+    DP omega;
25
+    int iK;
26
+    DP ff;
27
+    DP dev;
28
+    string label;
29
+
30
+    ifstream infile;
31
+    infile.open(ff_file);
32
+
33
+    if (infile.fail()) ABACUSerror("The input file was not opened successfully in Sort_RAW_File. ");
34
+
35
+    stringstream outfilename;
36
+    string outfilename_string;
37
+    outfilename << ff_file << "_iK_" << iKneeded;
38
+    outfilename_string = outfilename.str();
39
+    const char* outfilename_c_str = outfilename_string.c_str();
40
+
41
+    ofstream outfile;
42
+    outfile.open(outfilename_c_str);
43
+    outfile.precision(16);
44
+
45
+    int Ndata = 0;
46
+    while ((infile.peek()) != EOF) {
47
+
48
+      infile >> omega;
49
+      infile >> iK;
50
+      infile >> ff;
51
+      infile >> dev;
52
+      infile >> label;
53
+
54
+      if (iK == iKneeded) outfile << endl << omega << "\t" << iK << "\t" << ff << "\t" << dev << "\t" << label;
55
+    }
56
+    infile.close();
57
+    outfile.close();
58
+
59
+    return;
60
+  }
61
+
62
+} // namespace ABACUS

Loading…
Cancel
Save