StatMech
Loading...
Searching...
No Matches
Combine.cpp File Reference

Functions

int main (int argc, char **argv)
 

Variables

namespace filesystem = std::experimental::filesystem
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
16 {
17 if(argc != 5) {
18 std::cerr << "Usage: 1.This 2.n 3.div_min 4.div_max 5.Directory" << std::endl;
19 std::exit(EX_USAGE);
20 }
21 Integer_t const n = std::atoll(argv[1]);
22 Integer_t const div_min = std::atoll(argv[2]);
23 Integer_t const div_max = std::atoll(argv[3]);
24
25 std::stringstream buff;
26
27 std::string const d_str(argv[4]);
28 std::cout << "Directory: " << d_str << "\n";
29 std::string OutDIR(d_str); OutDIR += "/Output";
30 filesystem::create_directory(OutDIR);
31
32 buff.str("");
33 buff.clear(std::stringstream::goodbit);
34 buff << "/MeasureOfETH_N" << n << ".txt";
35 std::string OutFName(OutDIR); OutFName += buff.str();
36 std::ofstream Outfs(OutFName); checkIsFileOpen(Outfs, OutFName);
37 Outfs.exceptions(std::ios::badbit | std::ios::failbit);
38 Outfs << "# 1.(Sample No.) 2.(Fluc_2) 3.(Fluc_infty) 4.(Pos_max_flux) 5.(ndata)\n" << std::endl;
39
40 for(Integer_t div = div_min;div <= div_max; ++div) {
41 buff.str(""); buff.clear(std::stringstream::goodbit);
42 buff << "/MeasureOfETHZ_N" << n << "_" << div << ".txt";
43 std::string InFName(d_str); InFName += buff.str();
44 std::ifstream Infs(InFName);
45 if( !Infs.is_open() ) {
46 buff.str(""); buff.clear(std::stringstream::goodbit);
47 buff << "/MeasureOfETHC_N" << n << "_" << div << ".txt";
48 InFName = d_str; InFName += buff.str();
49 Infs.open(InFName);
50 }
51 if( !Infs.is_open() ) {
52 buff.str(""); buff.clear(std::stringstream::goodbit);
53 buff << "/MeasureOfETH_N" << n << "_" << div << ".txt";
54 InFName = d_str; InFName += buff.str();
55 Infs.open(InFName);
56 }
57 checkIsFileOpen(Infs, InFName);
58 Infs.exceptions(std::ios::badbit | std::ios::eofbit | std::ios::failbit);
59 try { skip_header(Infs); }
60 catch(std::exception& e) {
61 std::cerr << "Error(skip_header): " << e.what() << std::endl;
62 std::cerr << "File: \"" << InFName << "\" is empty." << std::endl;
63 continue;
64 }
65
66
67
68 Outfs << Infs.rdbuf();
69 }
70 return 0;
71}
bool checkIsFileOpen(std::ifstream &file, std::string const &filename)
Definition file_util.hpp:22
MKL_INT Integer_t
Definition mytypes.hpp:359
Integer_t const div
Definition setVariablesForEnsemble.cpp:29
std::stringstream buff("")

Variable Documentation

◆ filesystem

namespace filesystem = std::experimental::filesystem