Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / mdlib / qm_gamess.cpp
index 1720aea264fb8461088f4420db5ef4046ef6dbd1..697cea34344cd0cd716c2bd91ebbca737a47c39b 100644 (file)
 /* mopac interface routines */
 
 
-static void
-    F77_FUNC(inigms, IMIGMS) ();
+static void F77_FUNC(inigms, IMIGMS)();
 
-static void
-    F77_FUNC(grads, GRADS) (const int *nrqmat, real *qmcrd, const int *nrmmat, const real *mmchrg,
-                            real *mmcrd, real *qmgrad, real *mmgrad, real *energy);
+static void F77_FUNC(grads, GRADS)(const int*  nrqmat,
+                                   real*       qmcrd,
+                                   const int*  nrmmat,
+                                   const real* mmchrg,
+                                   real*       mmcrd,
+                                   real*       qmgrad,
+                                   real*       mmgrad,
+                                   real*       energy);
 
 #if !GMX_QMMM_GAMESS
 // Stub definitions to make compilation succeed when not configured
@@ -81,18 +85,12 @@ static void
 // issue fatal errors here, because that introduces problems with
 // tools suggesting and prohibiting noreturn attributes.
 
-void F77_FUNC(inigms, IMIGMS) ()
-{
-};
+void F77_FUNC(inigms, IMIGMS)(){};
 // NOLINTNEXTLINE(readability-named-parameter)
-void F77_FUNC(grads, GRADS) (const int *, real *, const int *,
-                             const real *, real *, real *,
-                             real *, real *)
-{
-};
+void F77_FUNC(grads, GRADS)(const int*, real*, const int*, const real*, real*, real*, real*, real*){};
 #endif
 
-void init_gamess(const t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
+void init_gamess(const t_commrec* cr, t_QMrec* qm, t_MMrec* mm)
 {
     /* it works hopelessly complicated :-)
      * first a file is written. Then the standard gamess input/output
@@ -102,21 +100,17 @@ void init_gamess(const t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
      * and energy evaluations are called. This setup works fine for
      * dynamics simulations. 7-6-2002 (London)
      */
-    int
-        i, j;
-    FILE
-       *out;
-    char
-        periodic_system[37][3] = {
-        "XX", "H ", "He", "Li", "Be", "B ", "C ", "N ",
-        "O ", "F ", "Ne", "Na", "Mg", "Al", "Si", "P ",
-        "S ", "Cl", "Ar", "K ", "Ca", "Sc", "Ti", "V ",
-        "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga",
-        "Ge", "As", "Se", "Br", "Kr"
-    };
+    int   i, j;
+    FILE* out;
+    char  periodic_system[37][3] = { "XX", "H ", "He", "Li", "Be", "B ", "C ", "N ", "O ", "F ",
+                                    "Ne", "Na", "Mg", "Al", "Si", "P ", "S ", "Cl", "Ar", "K ",
+                                    "Ca", "Sc", "Ti", "V ", "Cr", "Mn", "Fe", "Co", "Ni", "Cu",
+                                    "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr" };
     if (!GMX_QMMM_GAMESS)
     {
-        gmx_fatal(FARGS, "Cannot call GAMESS unless linked against it. Use cmake -DGMX_QMMM_PROGRAM=GAMESS, and ensure that linking will work correctly.");
+        gmx_fatal(FARGS,
+                  "Cannot call GAMESS unless linked against it. Use cmake "
+                  "-DGMX_QMMM_PROGRAM=GAMESS, and ensure that linking will work correctly.");
     }
 
     if (PAR(cr))
@@ -129,52 +123,35 @@ void init_gamess(const t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
              * preformance on more than 4 cpu's is rather poor at the moment.
              */
             fprintf(out, "memory 48000000\nPARALLEL IOMODE SCREENED\n");
-            fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
-                    qm->nelectrons, qm->multiplicity);
+            fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n", qm->nelectrons,
+                    qm->multiplicity);
             for (i = 0; i < qm->nrQMatoms; i++)
             {
 #ifdef DOUBLE
-                fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  %2s\n",
-                        i/2.,
-                        i/3.,
-                        i/4.,
-                        qm->atomicnumberQM[i]*1.0,
-                        periodic_system[qm->atomicnumberQM[i]]);
+                fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  %2s\n", i / 2., i / 3., i / 4.,
+                        qm->atomicnumberQM[i] * 1.0, periodic_system[qm->atomicnumberQM[i]]);
 #else
-                fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  %2s\n",
-                        i/2.,
-                        i/3.,
-                        i/4.,
-                        qm->atomicnumberQM[i]*1.0,
-                        periodic_system[qm->atomicnumberQM[i]]);
+                fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  %2s\n", i / 2., i / 3., i / 4.,
+                        qm->atomicnumberQM[i] * 1.0, periodic_system[qm->atomicnumberQM[i]]);
 #endif
             }
             if (mm->nrMMatoms)
             {
-                for (j = i; j < i+2; j++)
+                for (j = i; j < i + 2; j++)
                 {
 #ifdef DOUBLE
-                    fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  BQ\n",
-                            j/5.,
-                            j/6.,
-                            j/7.,
-                            1.0);
+                    fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  BQ\n", j / 5., j / 6., j / 7., 1.0);
 #else
-                    fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  BQ\n",
-                            j/5.,
-                            j/6.,
-                            j/7.,
-                            2.0);
+                    fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  BQ\n", j / 5., j / 6., j / 7., 2.0);
 #endif
                 }
             }
             fprintf(out, "END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
-                    eQMbasis_names[qm->QMbasis],
-                    eQMmethod_names[qm->QMmethod]); /* see enum.h */
+                    eQMbasis_names[qm->QMbasis], eQMmethod_names[qm->QMmethod]); /* see enum.h */
             fclose(out);
         }
         gmx_barrier(cr);
-        F77_FUNC(inigms, IMIGMS) ();
+        F77_FUNC(inigms, IMIGMS)();
     }
     else /* normal serial run */
 
@@ -183,69 +160,49 @@ void init_gamess(const t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
         /* of these options I am not completely sure....  the overall
          * preformance on more than 4 cpu's is rather poor at the moment.
          */
-        fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
-                qm->nelectrons, qm->multiplicity);
+        fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n", qm->nelectrons,
+                qm->multiplicity);
         for (i = 0; i < qm->nrQMatoms; i++)
         {
 #ifdef DOUBLE
-            fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  %2s\n",
-                    i/2.,
-                    i/3.,
-                    i/4.,
-                    qm->atomicnumberQM[i]*1.0,
-                    periodic_system[qm->atomicnumberQM[i]]);
+            fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  %2s\n", i / 2., i / 3., i / 4.,
+                    qm->atomicnumberQM[i] * 1.0, periodic_system[qm->atomicnumberQM[i]]);
 #else
-            fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  %2s\n",
-                    i/2.,
-                    i/3.,
-                    i/4.,
-                    qm->atomicnumberQM[i]*1.0,
-                    periodic_system[qm->atomicnumberQM[i]]);
+            fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  %2s\n", i / 2., i / 3., i / 4.,
+                    qm->atomicnumberQM[i] * 1.0, periodic_system[qm->atomicnumberQM[i]]);
 #endif
         }
         if (mm->nrMMatoms)
         {
-            for (j = i; j < i+2; j++)
+            for (j = i; j < i + 2; j++)
             {
 #ifdef DOUBLE
-                fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  BQ\n",
-                        j/5.,
-                        j/6.,
-                        j/7.,
-                        1.0);
+                fprintf(out, "%10.7lf  %10.7lf  %10.7lf  %5.3lf  BQ\n", j / 5., j / 6., j / 7., 1.0);
 #else
-                fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  BQ\n",
-                        j/5.,
-                        j/6.,
-                        j/7.,
-                        2.0);
+                fprintf(out, "%10.7f  %10.7f  %10.7f  %5.3f  BQ\n", j / 5., j / 6., j / 7., 2.0);
 #endif
             }
         }
-        fprintf(out, "END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
-                eQMbasis_names[qm->QMbasis],
+        fprintf(out, "END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n", eQMbasis_names[qm->QMbasis],
                 eQMmethod_names[qm->QMmethod]); /* see enum.h */
-        F77_FUNC(inigms, IMIGMS) ();
+        F77_FUNC(inigms, IMIGMS)();
     }
 }
 
-real call_gamess(const t_QMrec *qm, const t_MMrec *mm,
-                 rvec f[], rvec fshift[])
+real call_gamess(const t_QMrec* qm, const t_MMrec* mm, rvec f[], rvec fshift[])
 {
     /* do the actual QMMM calculation using GAMESS-UK. In this
      * implementation (3-2001) a system call is made to the GAMESS-UK
      * binary. Now we are working to get the electron integral, SCF, and
      * gradient routines linked directly
      */
-    int
-        i, j;
-    real
-        QMener = 0.0, *qmgrad, *mmgrad, *mmcrd, *qmcrd, energy = 0;
+    int  i, j;
+    real QMener = 0.0, *qmgrad, *mmgrad, *mmcrd, *qmcrd, energy = 0;
 
-    snew(qmcrd, 3*(qm->nrQMatoms));
-    snew(mmcrd, 3*(mm->nrMMatoms));
-    snew(qmgrad, 3*(qm->nrQMatoms));
-    snew(mmgrad, 3*(mm->nrMMatoms));
+    snew(qmcrd, 3 * (qm->nrQMatoms));
+    snew(mmcrd, 3 * (mm->nrMMatoms));
+    snew(qmgrad, 3 * (qm->nrQMatoms));
+    snew(mmgrad, 3 * (mm->nrMMatoms));
 
     /* copy the data from qr into the arrays that are going to be used
      * in the fortran routines of gamess
@@ -254,46 +211,43 @@ real call_gamess(const t_QMrec *qm, const t_MMrec *mm,
     {
         for (j = 0; j < DIM; j++)
         {
-            qmcrd[DIM*i+j] = 1/BOHR2NM*qm->xQM[i][j];
+            qmcrd[DIM * i + j] = 1 / BOHR2NM * qm->xQM[i][j];
         }
     }
     for (i = 0; i < mm->nrMMatoms; i++)
     {
         for (j = 0; j < DIM; j++)
         {
-            mmcrd[DIM*i+j] = 1/BOHR2NM*mm->xMM[i][j];
+            mmcrd[DIM * i + j] = 1 / BOHR2NM * mm->xMM[i][j];
         }
     }
-    for (i = 0; i < 3*qm->nrQMatoms; i += 3)
+    for (i = 0; i < 3 * qm->nrQMatoms; i += 3)
     {
-        fprintf(stderr, "%8.5f, %8.5f, %8.5f\n",
-                qmcrd[i],
-                qmcrd[i+1],
-                qmcrd[i+2]);
+        fprintf(stderr, "%8.5f, %8.5f, %8.5f\n", qmcrd[i], qmcrd[i + 1], qmcrd[i + 2]);
     }
 
-    F77_FUNC(grads, GRADS) (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms, mm->MMcharges,
-                            mmcrd, qmgrad, mmgrad, &energy);
+    F77_FUNC(grads, GRADS)
+    (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms, mm->MMcharges, mmcrd, qmgrad, mmgrad, &energy);
 
     for (i = 0; i < qm->nrQMatoms; i++)
     {
         for (j = 0; j < DIM; j++)
         {
-            f[i][j]      = HARTREE_BOHR2MD*qmgrad[3*i+j];
-            fshift[i][j] = HARTREE_BOHR2MD*qmgrad[3*i+j];
+            f[i][j]      = HARTREE_BOHR2MD * qmgrad[3 * i + j];
+            fshift[i][j] = HARTREE_BOHR2MD * qmgrad[3 * i + j];
         }
     }
     for (i = 0; i < mm->nrMMatoms; i++)
     {
         for (j = 0; j < DIM; j++)
         {
-            f[i][j]      = HARTREE_BOHR2MD*mmgrad[3*i+j];
-            fshift[i][j] = HARTREE_BOHR2MD*mmgrad[3*i+j];
+            f[i][j]      = HARTREE_BOHR2MD * mmgrad[3 * i + j];
+            fshift[i][j] = HARTREE_BOHR2MD * mmgrad[3 * i + j];
         }
     }
     /* convert a.u to kJ/mol */
-    QMener = energy*HARTREE2KJ*AVOGADRO;
-    return(QMener);
+    QMener = energy * HARTREE2KJ * AVOGADRO;
+    return (QMener);
 }
 
 #pragma GCC diagnostic pop