Last change
on this file since ef87ee was ef87ee, checked in by Frederik Heber <heber@…>, 16 years ago |
Added versioning to each executable.
- credits to Ralf Wildenhues for writing the Makefile.am code
- version.c section added to Makefile.am (pcp, molecuilder and util)
- src/version.h to each pcp, molecuilder and util
- each of the executables includes version.h and prints version in main()
Signed-off-by: Frederik Heber <heber@…>
|
-
Property mode
set to
100644
|
File size:
2.0 KB
|
Line | |
---|
1 | using namespace std;
|
---|
2 | #include <iostream>
|
---|
3 | #include <iomanip>
|
---|
4 | #include <fstream>
|
---|
5 | #include <sstream>
|
---|
6 | #include <math.h>
|
---|
7 | #include <string>
|
---|
8 |
|
---|
9 | #include "version.h"
|
---|
10 |
|
---|
11 |
|
---|
12 | int main(int argc, char **argv) {
|
---|
13 |
|
---|
14 | double avg, dev;
|
---|
15 | double tmp;
|
---|
16 | int i, j, col, zaehler;
|
---|
17 | int ecut;
|
---|
18 | int flag;
|
---|
19 | string zeile;
|
---|
20 | stringstream line;
|
---|
21 |
|
---|
22 | cout << ESPACKVersion << endl;
|
---|
23 |
|
---|
24 | if (argc < 4) {
|
---|
25 | cout << "Usage: " << argv[0] << " <Spalte> <X> <File1> <File2> ...\n";
|
---|
26 | return(1);
|
---|
27 | }
|
---|
28 | line.str(argv[1]);
|
---|
29 | line >> col;
|
---|
30 | line.clear();
|
---|
31 | line.str(argv[2]);
|
---|
32 | line >> ecut;
|
---|
33 | cout << "Using " << col << " with Ecut of " << ecut << "." << endl;
|
---|
34 |
|
---|
35 | // get average
|
---|
36 | avg = 0.;
|
---|
37 | zaehler=0;
|
---|
38 | for (i=3;i<argc;i++) {
|
---|
39 | //cout << "Reading column " << col << " from file " << argv[i] << "\n";
|
---|
40 | ifstream test(argv[i]);
|
---|
41 | if (test == NULL) { cout << "Can't open File " << argv[i] << "\n"; return(255); }
|
---|
42 | flag=1;
|
---|
43 | //cout << "Looking for " << ecut << " \n";
|
---|
44 | while (getline(test, zeile, '\n')) {
|
---|
45 | //cout << zeile;
|
---|
46 | istringstream input(zeile);
|
---|
47 | input >> ws >> tmp;
|
---|
48 | if (tmp==(double)ecut) { // found correct line!
|
---|
49 | for (j=col;j>0;j--)
|
---|
50 | if (!input.eof())
|
---|
51 | input >> ws >> tmp;
|
---|
52 | else
|
---|
53 | flag=0;
|
---|
54 | //cout << tmp << "\n";
|
---|
55 | avg += tmp;
|
---|
56 | }
|
---|
57 | //else cout << " skipping\n";
|
---|
58 | }
|
---|
59 | zaehler+=flag;
|
---|
60 | test.close();
|
---|
61 | }
|
---|
62 | if (zaehler != 0) avg /= zaehler;
|
---|
63 |
|
---|
64 | // get deviation
|
---|
65 | dev = 0.;
|
---|
66 | zaehler=0;
|
---|
67 | for (i=3;i<argc;i++) {
|
---|
68 | //cout << "Reading column " << col << " from file " << argv[i] << "\n";
|
---|
69 | ifstream test(argv[i]);
|
---|
70 | if (test == NULL) { cout << "Can't open File " << argv[i] << "\n"; return(255); }
|
---|
71 | flag=1;
|
---|
72 | while (getline(test, zeile, '\n')) {
|
---|
73 | istringstream input(zeile);
|
---|
74 | input >> ws >> tmp;
|
---|
75 | if (tmp==(double)ecut) { // found correct line!
|
---|
76 | for (j=col;j>0;j--)
|
---|
77 | if (!input.eof())
|
---|
78 | input >> ws >> tmp;
|
---|
79 | else
|
---|
80 | flag=0;
|
---|
81 | //cout << tmp << "\n";
|
---|
82 | dev += pow(tmp - avg, 2);
|
---|
83 | }
|
---|
84 | }
|
---|
85 | zaehler+=flag;
|
---|
86 | test.close();
|
---|
87 | }
|
---|
88 | //dev = 1/(zaehler)*dev;
|
---|
89 | dev /= zaehler;
|
---|
90 |
|
---|
91 | cout << setprecision(8) << avg << "\t" << setprecision(8) << sqrt(dev) << "\n";
|
---|
92 | return(0);
|
---|
93 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.