1
1
#include < iostream>
2
2
#include < fstream>
3
+ #include < sys/stat.h>
3
4
4
5
#include " colvargrid.h"
5
6
#include " colvarproxy.h"
@@ -16,7 +17,30 @@ int main (int argc, char *argv[]) {
16
17
colvarmodule *colvars = new colvarmodule (proxy);
17
18
18
19
std::string gradfile (argv[1 ]);
19
- std::shared_ptr<colvar_grid_gradient> grad_ptr = std::make_shared<colvar_grid_gradient>(gradfile);
20
+ std::shared_ptr<colvar_grid_count> count_ptr;
21
+
22
+ std::string countfile;
23
+
24
+ // Look for matching count file
25
+ size_t pos = gradfile.rfind (std::string (" .czar.grad" ));
26
+ if (pos != std::string::npos) {
27
+ countfile = gradfile.substr (0 ,pos) + " .zcount" ;
28
+ } else {
29
+ pos = gradfile.rfind (std::string (" .grad" ));
30
+ if (pos != std::string::npos) {
31
+ countfile = gradfile.substr (0 ,pos) + " .count" ;
32
+ }
33
+ }
34
+ if (countfile.size ()) {
35
+ struct stat buffer;
36
+ if (stat (countfile.c_str (), &buffer) == 0 ) {
37
+ std::cout << " Found associated count file " << countfile << " , reading...\n " ;
38
+ count_ptr.reset (new colvar_grid_count (countfile));
39
+ }
40
+ }
41
+
42
+ std::cout << " Reading gradient file " << gradfile << std::endl;
43
+ std::shared_ptr<colvar_grid_gradient> grad_ptr = std::make_shared<colvar_grid_gradient>(gradfile, count_ptr);
20
44
21
45
int itmax = 1000 ;
22
46
cvm::real err;
@@ -27,8 +51,11 @@ int main (int argc, char *argv[]) {
27
51
potential.integrate (itmax, tol, err);
28
52
potential.set_zero_minimum ();
29
53
30
- potential.write_multicol (std::string (gradfile + " .int" ),
31
- " integrated potential" );
54
+ std::cout << " Writing integrated potential file " << gradfile + " .int" << std::endl;
55
+ potential.write_multicol (std::string (gradfile + " .int" ), " integrated potential" );
56
+
57
+ std::cout << " Writing internal gradient to file " << gradfile + " .out" << std::endl;
58
+ grad_ptr->write_multicol (std::string (gradfile + " .out" ), " integrated potential" );
32
59
33
60
delete colvars;
34
61
return 0 ;
0 commit comments