Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / mdlib / qm_mopac.cpp
index e1ae3c3d7a122d036d89ce634849bdbfab93c4a9..1b1d9292e59797770b2b20aa138e5c1018b9fcb2 100644 (file)
 
 #if GMX_QMMM_MOPAC
 /* mopac interface routines */
-void
-    F77_FUNC(domldt, DOMLDT) (int *nrqmat, int labels[], char keywords[]);
+void F77_FUNC(domldt, DOMLDT)(int* nrqmat, int labels[], char keywords[]);
 
-void
-    F77_FUNC(domop, DOMOP) (int *nrqmat, double qmcrd[], int *nrmmat,
-                            double mmchrg[], double mmcrd[], double qmgrad[],
-                            double mmgrad[], double *energy, double qmcharges[]);
+void F77_FUNC(domop, DOMOP)(int*    nrqmat,
+                            double  qmcrd[],
+                            int*    nrmmat,
+                            double  mmchrg[],
+                            double  mmcrd[],
+                            double  qmgrad[],
+                            double  mmgrad[],
+                            double* energy,
+                            double  qmcharges[]);
 
 #else /* GMX_QMMM_MOPAC */
 // Stub definitions to make compilation succeed when not configured
@@ -79,20 +83,24 @@ void
 // issue fatal errors here, because that introduces problems with
 // tools suggesting and prohibiting noreturn attributes.
 
-static void F77_FUNC(domldt, DOMLDT) (int * /*unused*/, int  /*unused*/[], char  /*unused*/[])
-{
-}
+static void F77_FUNC(domldt, DOMLDT)(int* /*unused*/, int /*unused*/[], char /*unused*/[]) {}
 
-static void F77_FUNC(domop, DOMOP) (int * /*unused*/, double  /*unused*/[], int * /*unused*/,
-                                    double  /*unused*/[], double  /*unused*/[], double  /*unused*/[],
-                                    double  /*unused*/[], double * /*unused*/, double  /*unused*/[])
+static void F77_FUNC(domop, DOMOP)(int* /*unused*/,
+                                   double /*unused*/[],
+                                   int* /*unused*/,
+                                   double /*unused*/[],
+                                   double /*unused*/[],
+                                   double /*unused*/[],
+                                   double /*unused*/[],
+                                   double* /*unused*/,
+                                   double /*unused*/[])
 {
 }
 
 #endif
 
 
-void init_mopac(t_QMrec *qm)
+void init_mopac(t_QMrecqm)
 {
     /* initializes the mopac routines ans sets up the semiempirical
      * computation by calling moldat(). The inline mopac routines can
@@ -100,49 +108,46 @@ void init_mopac(t_QMrec *qm)
      * structure or find a transition state at PM3 level, gaussian is
      * used instead.
      */
-    char
-    *keywords;
+    char* keywords;
 
     if (!GMX_QMMM_MOPAC)
     {
-        gmx_fatal(FARGS, "Cannot call MOPAC unless linked against it. Use cmake -DGMX_QMMM_PROGRAM=MOPAC, and ensure that linking will work correctly.");
+        gmx_fatal(FARGS,
+                  "Cannot call MOPAC unless linked against it. Use cmake -DGMX_QMMM_PROGRAM=MOPAC, "
+                  "and ensure that linking will work correctly.");
     }
 
     snew(keywords, 240);
 
-    if (!qm->bSH)  /* if rerun then grad should not be done! */
+    if (!qm->bSH) /* if rerun then grad should not be done! */
     {
-        sprintf(keywords, "PRECISE GEO-OK CHARGE=%d GRAD MMOK ANALYT %s\n",
-                qm->QMcharge,
+        sprintf(keywords, "PRECISE GEO-OK CHARGE=%d GRAD MMOK ANALYT %s\n", qm->QMcharge,
                 eQMmethod_names[qm->QMmethod]);
     }
     else
     {
         sprintf(keywords, "PRECISE GEO-OK CHARGE=%d SINGLET GRAD %s C.I.=(%d,%d) root=2 MECI \n",
-                qm->QMcharge,
-                eQMmethod_names[qm->QMmethod],
-                qm->CASorbitals, qm->CASelectrons/2);
+                qm->QMcharge, eQMmethod_names[qm->QMmethod], qm->CASorbitals, qm->CASelectrons / 2);
     }
-    F77_FUNC(domldt, DOMLDT) (&qm->nrQMatoms, qm->atomicnumberQM, keywords);
+    F77_FUNC(domldt, DOMLDT)(&qm->nrQMatoms, qm->atomicnumberQM, keywords);
     fprintf(stderr, "keywords are: %s\n", keywords);
     free(keywords);
 
 } /* init_mopac */
 
-real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
+real call_mopac(t_QMrec* qm, t_MMrec* mm, rvec f[], rvec fshift[])
 {
     /* do the actual QMMM calculation using directly linked mopac subroutines
      */
     double /* always double as the MOPAC routines are always compiled in
               double precission! */
-    *qmcrd = nullptr, *qmchrg = nullptr, *mmcrd = nullptr, *mmchrg = nullptr,
-    *qmgrad, *mmgrad = nullptr, energy = 0;
-    int
-        i, j;
-    real
-        QMener = 0.0;
-    snew(qmcrd, 3*(qm->nrQMatoms));
-    snew(qmgrad, 3*(qm->nrQMatoms));
+            *qmcrd  = nullptr,
+            *qmchrg = nullptr, *mmcrd = nullptr, *mmchrg = nullptr, *qmgrad, *mmgrad = nullptr,
+            energy = 0;
+    int  i, j;
+    real QMener = 0.0;
+    snew(qmcrd, 3 * (qm->nrQMatoms));
+    snew(qmgrad, 3 * (qm->nrQMatoms));
     /* copy the data from qr into the arrays that are going to be used
      * in the fortran routines of MOPAC
      */
@@ -150,7 +155,7 @@ real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
     {
         for (j = 0; j < DIM; j++)
         {
-            qmcrd[3*i+j] = static_cast<double>(qm->xQM[i][j])*10;
+            qmcrd[3 * i + j] = static_cast<double>(qm->xQM[i][j]) * 10;
         }
     }
     if (mm->nrMMatoms)
@@ -159,7 +164,8 @@ real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
          * conceptual problems with semi-empirical QM in combination with
          * point charges that we need to solve first....
          */
-        gmx_fatal(FARGS, "At present only ONIOM is allowed in combination"
+        gmx_fatal(FARGS,
+                  "At present only ONIOM is allowed in combination"
                   " with MOPAC QM subroutines\n");
     }
     else
@@ -168,8 +174,8 @@ real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
          */
 
         snew(qmchrg, qm->nrQMatoms);
-        F77_FUNC(domop, DOMOP) (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms,
-                                mmchrg, mmcrd, qmgrad, mmgrad, &energy, qmchrg);
+        F77_FUNC(domop, DOMOP)
+        (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms, mmchrg, mmcrd, qmgrad, mmgrad, &energy, qmchrg);
         /* add the gradients to the f[] array, and also to the fshift[].
          * the mopac gradients are in kCal/angstrom.
          */
@@ -177,11 +183,11 @@ real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
         {
             for (j = 0; j < DIM; j++)
             {
-                f[i][j]       = static_cast<real>(10)*CAL2JOULE*qmgrad[3*i+j];
-                fshift[i][j]  = static_cast<real>(10)*CAL2JOULE*qmgrad[3*i+j];
+                f[i][j]      = static_cast<real>(10) * CAL2JOULE * qmgrad[3 * i + j];
+                fshift[i][j] = static_cast<real>(10) * CAL2JOULE * qmgrad[3 * i + j];
             }
         }
-        QMener = static_cast<real>CAL2JOULE*energy;
+        QMener = static_cast<real> CAL2JOULE * energy;
         /* do we do something with the mulliken charges?? */
 
         free(qmchrg);
@@ -191,22 +197,21 @@ real call_mopac(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
     return (QMener);
 }
 
-real call_mopac_SH(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
+real call_mopac_SH(t_QMrec* qm, t_MMrec* mm, rvec f[], rvec fshift[])
 {
     /* do the actual SH QMMM calculation using directly linked mopac
        subroutines */
 
     double /* always double as the MOPAC routines are always compiled in
               double precission! */
-    *qmcrd = nullptr, *qmchrg = nullptr, *mmcrd = nullptr, *mmchrg = nullptr,
-    *qmgrad, *mmgrad = nullptr, energy = 0;
-    int
-        i, j;
-    real
-        QMener = 0.0;
-
-    snew(qmcrd, 3*(qm->nrQMatoms));
-    snew(qmgrad, 3*(qm->nrQMatoms));
+            *qmcrd  = nullptr,
+            *qmchrg = nullptr, *mmcrd = nullptr, *mmchrg = nullptr, *qmgrad, *mmgrad = nullptr,
+            energy = 0;
+    int  i, j;
+    real QMener = 0.0;
+
+    snew(qmcrd, 3 * (qm->nrQMatoms));
+    snew(qmgrad, 3 * (qm->nrQMatoms));
     /* copy the data from qr into the arrays that are going to be used
      * in the fortran routines of MOPAC
      */
@@ -214,7 +219,7 @@ real call_mopac_SH(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
     {
         for (j = 0; j < DIM; j++)
         {
-            qmcrd[3*i+j] = static_cast<double>(qm->xQM[i][j])*10;
+            qmcrd[3 * i + j] = static_cast<double>(qm->xQM[i][j]) * 10;
         }
     }
     if (mm->nrMMatoms)
@@ -231,8 +236,8 @@ real call_mopac_SH(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
          */
         snew(qmchrg, qm->nrQMatoms);
 
-        F77_FUNC(domop, DOMOP) (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms,
-                                mmchrg, mmcrd, qmgrad, mmgrad, &energy, qmchrg);
+        F77_FUNC(domop, DOMOP)
+        (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms, mmchrg, mmcrd, qmgrad, mmgrad, &energy, qmchrg);
         /* add the gradients to the f[] array, and also to the fshift[].
          * the mopac gradients are in kCal/angstrom.
          */
@@ -240,11 +245,11 @@ real call_mopac_SH(t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
         {
             for (j = 0; j < DIM; j++)
             {
-                f[i][j]      = static_cast<real>(10)*CAL2JOULE*qmgrad[3*i+j];
-                fshift[i][j] = static_cast<real>(10)*CAL2JOULE*qmgrad[3*i+j];
+                f[i][j]      = static_cast<real>(10) * CAL2JOULE * qmgrad[3 * i + j];
+                fshift[i][j] = static_cast<real>(10) * CAL2JOULE * qmgrad[3 * i + j];
             }
         }
-        QMener = static_cast<real>CAL2JOULE*energy;
+        QMener = static_cast<real> CAL2JOULE * energy;
     }
     free(qmgrad);
     free(qmcrd);