From 9a7f070d19151752ea2ed0cba1202420bbb3e4a0 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 13 Dec 2017 13:00:12 -0800 Subject: [PATCH] Simplify CMAP loop Fixes #2350 Change-Id: Id87a2105012d541f77d1c278029fe36b874328a9 --- src/gromacs/listed-forces/bonded.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/gromacs/listed-forces/bonded.cpp b/src/gromacs/listed-forces/bonded.cpp index 0c08d2f861..c9d7b45e02 100644 --- a/src/gromacs/listed-forces/bonded.cpp +++ b/src/gromacs/listed-forces/bonded.cpp @@ -3003,7 +3003,7 @@ cmap_dihs(int nbonds, const t_mdatoms gmx_unused *md, t_fcdata gmx_unused *fcd, int gmx_unused *global_atom_index) { - int i, j, k, n, idx; + int i, n; int ai, aj, ak, al, am; int a1i, a1j, a1k, a1l, a2i, a2j, a2k, a2l; int type, cmapA; @@ -3013,10 +3013,10 @@ cmap_dihs(int nbonds, int l1, l2, l3; int pos1, pos2, pos3, pos4; - real ty[4], ty1[4], ty2[4], ty12[4], tc[16], tx[16]; + real ty[4], ty1[4], ty2[4], ty12[4], tx[16]; real phi1, cos_phi1, sin_phi1, xphi1; real phi2, cos_phi2, sin_phi2, xphi2; - real dx, xx, tt, tu, e, df1, df2, vtot; + real dx, tt, tu, e, df1, df2, vtot; real ra21, rb21, rg21, rg1, rgr1, ra2r1, rb2r1, rabr1; real ra22, rb22, rg22, rg2, rgr2, ra2r2, rb2r2, rabr2; real fg1, hg1, fga1, hgb1, gaa1, gbb1; @@ -3248,19 +3248,12 @@ cmap_dihs(int nbonds, tx[i+12] = ty12[i]*dx*dx; } - idx = 0; - for (i = 0; i < 4; i++) /* 1056 */ + real tc[16] = {0}; + for (int idx = 0; idx < 16; idx++) /* 1056 */ { - for (j = 0; j < 4; j++) + for (int k = 0; k < 16; k++) { - xx = 0; - for (k = 0; k < 16; k++) - { - xx = xx + cmap_coeff_matrix[k*16+idx]*tx[k]; - } - - idx++; - tc[i*4+j] = xx; + tc[idx] += cmap_coeff_matrix[k*16+idx]*tx[k]; } } -- 2.11.4.GIT