Update MOPAC output 96/5196/2 master
authorMariano Spivak <mariano@moskva.ks.uiuc.edu>
Wed, 5 Jun 2019 22:38:39 +0000 (17:38 -0500)
committerMariano Spivak <mariano@moskva.ks.uiuc.edu>
Wed, 12 Jun 2019 23:09:12 +0000 (18:09 -0500)
Change-Id: I70f4f851aaff54abf282dd7065ab66641a8d6b90

src/ComputeQM.C

index 895fb60..676d46a 100644 (file)
@@ -3162,7 +3162,7 @@ void ComputeQMMgr::calcMOPAC(QMGrpCalcMsg *msg)
             break;
         }
         
-        char result[10] ;
+        char result[20] ;
         size_t strIndx = 0;
         
         if (chargeFields) {
@@ -3206,11 +3206,19 @@ void ComputeQMMgr::calcMOPAC(QMGrpCalcMsg *msg)
             
         }
         
+       int gradLength ; // Change for variable length MOPAC output
         if (gradFields) {
-            while ((strIndx < (strlen(line)-9)) && (strlen(line)-1 >=9 ) ) {
+            if (atmIndx == 0) {
+                double buf[10];
+                int numfirstline = sscanf(line,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
+                                          &buf[0],&buf[1],&buf[2],&buf[3],&buf[4],&buf[5],
+                                          &buf[6],&buf[7],&buf[8],&buf[9]);
+                gradLength = strlen(line)/numfirstline;
+            }
+            while ((strIndx < (strlen(line)-gradLength)) && (strlen(line)-1 >= gradLength ) ) {
                 
-                strncpy(result, line+strIndx,9) ;
-                result[9] = '\0';
+                strncpy(result, line+strIndx,gradLength) ;
+                result[gradLength] = '\0';
                 
                 gradient[gradCount] = atof(result);
                 if (gradCount == 2) {
@@ -3280,7 +3288,7 @@ void ComputeQMMgr::calcMOPAC(QMGrpCalcMsg *msg)
                     gradCount++;
                 }
                 
-                strIndx += 9;
+                strIndx += gradLength;
                 
                 // If we found all gradients for QM atoms, break the loop
                 // and keep the next gradient line from being read, if there