File: check_for_psio_purge.patch

package info (click to toggle)
mpqc3 0.0~git20170114-4.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 148,800 kB
  • sloc: cpp: 545,687; ansic: 13,220; perl: 5,065; fortran: 1,990; lisp: 1,269; python: 717; yacc: 392; sh: 304; f90: 238; lex: 184; xml: 182; makefile: 114
file content (107 lines) | stat: -rw-r--r-- 3,591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Index: mpqc3-20170114/external/Psi3
===================================================================
--- mpqc3-20170114.orig/external/Psi3
+++ mpqc3-20170114/external/Psi3
@@ -55,6 +55,18 @@ if (PSI3)
     if (NOT PSI3_COMPILES)
       message(FATAL_ERROR "Could not compile Psi3 test program")
     endif()
+
+    # check for psio::purge() function
+    CHECK_CXX_SOURCE_COMPILES(
+      "
+      #include <libpsio/psio.hpp>
+      extern \"C\" char *gprgid() { return \"test\"; }
+      int main(int argc, char** argv) {
+        psi::PSIO psio;
+        psio.purge(1);
+        return 0;
+      }
+      "  HAVE_PSIO_PURGE)
     
     set(HAVE_PSI3 TRUE)
     message(STATUS "Found PSI3:")
Index: mpqc3-20170114/src/lib/mpqc_config.h.in
===================================================================
--- mpqc3-20170114.orig/src/lib/mpqc_config.h.in
+++ mpqc3-20170114/src/lib/mpqc_config.h.in
@@ -214,6 +214,9 @@
 /* Define if Psi-MPQC interface can be compiled.  */
 #cmakedefine HAVE_PSI3
 
+/* Define if libPSI_psio has purge function.  */
+#cmakedefine HAVE_PSIO_PURGE
+
 /* The location of Psi3 root directory. */
 #cmakedefine PSI3ROOTDIR "@PSI3ROOTDIR@"
 
Index: mpqc3-20170114/src/lib/chemistry/qc/psi/psiexenv.cc
===================================================================
--- mpqc3-20170114.orig/src/lib/chemistry/qc/psi/psiexenv.cc
+++ mpqc3-20170114/src/lib/chemistry/qc/psi/psiexenv.cc
@@ -231,11 +231,13 @@ void PsiExEnv::run_psi(bool skip_input)
   if (skip_input)
     cmdline_args.push_back(std::string("--noinput"));
 
+#ifdef HAVE_PSIO_PURGE
   if(keep_output_) {
     cmdline_args.push_back(std::string("--keepoutput"));
     keep_output_ = false;
 
   }
+#endif
   run_psi_module("psi3", cmdline_args);
 }
 
@@ -255,15 +257,21 @@ void PsiExEnv::run_psi_module(const char
 #ifdef HAVE_POSIX_SPAWN
   {
     std::vector<std::string> allargs(7 + args.size());
-    allargs[0] = psiprefix_ + "/" + module;
-    allargs[1] = "-f";
-    allargs[2] = inputname_;
-    allargs[3] = "-o";
-    allargs[4] = outputname_;
-    allargs[5] = "-p";
-    allargs[6] = fileprefix_;
-    for(int i=0; i<args.size(); ++i)
-      allargs[7+i] = args[i];
+    if (strcmp(module,"psiclean")) {
+      allargs[0] = psiprefix_ + "/" + module;
+      allargs[1] = "-f";
+      allargs[2] = inputname_;
+      allargs[3] = "-o";
+      allargs[4] = outputname_;
+      allargs[5] = "-p";
+      allargs[6] = fileprefix_;
+      for(int i=0; i<args.size(); ++i)
+        allargs[7+i] = args[i];
+    } else {
+      allargs[0] = psiprefix_ + "/" + module;
+      allargs[1] = inputname_;
+      allargs.resize(2);
+    }
     const size_t n = allargs.size();
     char** spawnedArgs = new char*[n+1]; spawnedArgs[n] = NULL;
     for(int i=0; i<n; ++i)
@@ -288,7 +296,7 @@ void PsiExEnv::run_psi_module(const char
       // check the status of the completed call
       if (WIFEXITED(status)) { // module called exit()
         const int retval = WEXITSTATUS(status);
-        if (retval != 0) {
+        if (retval != 0 && strcmp(module,"psiclean")) {
           std::ostringstream oss; oss << "PsiExEnv::run_psi_module -- module " << module << " returned nonzero, check psi output";
           throw SystemException(oss.str().c_str(),__FILE__,__LINE__);
         }
@@ -338,7 +346,11 @@ void PsiExEnv::run_psiclean(bool fullcle
 
   // can't run unless input file has been created
   if (psiinput_)
+#ifdef HAVE_PSIO_PURGE
     psio_.purge(fullclean);
+#else
+    run_psi_module("psiclean", std::vector<std::string>());
+#endif
 }
 
 void PsiExEnv::print(std::ostream&o) const