|
@@ -23,19 +23,11 @@ using namespace ABACUS;
|
23
|
23
|
|
24
|
24
|
namespace ABACUS {
|
25
|
25
|
|
26
|
|
- void Benchmark_RAW_File (const char ff_file[], char whichDSF)
|
|
26
|
+ void Benchmark_RAW_File (const string ff_file, char whichDSF)
|
27
|
27
|
{
|
28
|
|
- // Check size of raw file:
|
29
|
|
- struct stat statbuf;
|
|
28
|
+ string filename = ff_file;
|
30
|
29
|
|
31
|
|
- stat (ff_file, &statbuf);
|
32
|
|
- int filesize = statbuf.st_size;
|
33
|
|
-
|
34
|
|
- // Determine the number of entries approximately
|
35
|
|
- int entry_size = 2* sizeof(float) + 2*sizeof(int);
|
36
|
|
-
|
37
|
|
- //const int MAXDATA = 50000000;
|
38
|
|
- const int MAXDATA = filesize/entry_size + 10;
|
|
30
|
+ const int MAXDATA = count_lines(filename);
|
39
|
31
|
|
40
|
32
|
DP* omega = new DP[MAXDATA];
|
41
|
33
|
int* iK = new int[MAXDATA];
|
|
@@ -45,7 +37,7 @@ namespace ABACUS {
|
45
|
37
|
string* label = new string[MAXDATA];
|
46
|
38
|
|
47
|
39
|
ifstream infile;
|
48
|
|
- infile.open(ff_file);
|
|
40
|
+ infile.open(filename);
|
49
|
41
|
|
50
|
42
|
if (infile.fail()) ABACUSerror("The input file was not opened successfully in Benchmark_RAW_File. ");
|
51
|
43
|
|
|
@@ -73,14 +65,10 @@ namespace ABACUS {
|
73
|
65
|
for (int i = 0; i < Ndata; ++i) sr_cont[i] = fabs(omega[i]) * ff[i] * ff[i];
|
74
|
66
|
}
|
75
|
67
|
|
76
|
|
- stringstream outfilename;
|
77
|
|
- string outfilename_string;
|
78
|
|
- outfilename << ff_file << "_bmk";
|
79
|
|
- outfilename_string = outfilename.str();
|
80
|
|
- const char* outfilename_c_str = outfilename_string.c_str();
|
|
68
|
+ string outfilename = replace_all(filename, ".", "_") + ".bmk";
|
81
|
69
|
|
82
|
70
|
ofstream outfile1;
|
83
|
|
- outfile1.open(outfilename_c_str);
|
|
71
|
+ outfile1.open(outfilename);
|
84
|
72
|
outfile1.precision(16);
|
85
|
73
|
|
86
|
74
|
for (int i = 0; i < Ndata; i++) {
|
|
@@ -93,12 +81,8 @@ namespace ABACUS {
|
93
|
81
|
// Now the ordered one
|
94
|
82
|
QuickSort(sr_cont, index, 0, Ndata - 1);
|
95
|
83
|
|
96
|
|
- outfilename << "_srt";
|
97
|
|
- outfilename_string = outfilename.str();
|
98
|
|
- const char* outfilename2_c_str = outfilename_string.c_str();
|
99
|
|
-
|
100
|
84
|
ofstream outfile2;
|
101
|
|
- outfile2.open(outfilename2_c_str);
|
|
85
|
+ outfile2.open(outfilename + "_srt");
|
102
|
86
|
outfile2.precision(16);
|
103
|
87
|
|
104
|
88
|
for (int i = 0; i < Ndata; i++) {
|
|
@@ -133,7 +117,8 @@ int main(int argc, char* argv[])
|
133
|
117
|
ABACUSerror("");
|
134
|
118
|
}
|
135
|
119
|
|
136
|
|
- const char* rawfilename = argv[1];
|
|
120
|
+ // const char* rawfilename = argv[1];
|
|
121
|
+ string rawfilename = argv[1];
|
137
|
122
|
char whichDSF = *argv[2];
|
138
|
123
|
|
139
|
124
|
Benchmark_RAW_File (rawfilename, whichDSF);
|