1/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
2/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3/* { dg-require-effective-target powerpc_p8vector_ok } */
4/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
5/* { dg-options "-mcpu=power8 -O3 -m64 -funroll-loops" } */
6
7#include <stddef.h>
8#include <stdlib.h>
9#include <math.h>
10#include <string.h>
11
12typedef long unsigned int size_t;
13typedef struct _IO_FILE FILE;
14typedef float real;
15typedef real rvec[3];
16typedef real matrix[3][3];
17typedef real tensor[3][3];
18enum
19{
20  F_BONDS, F_G96BONDS, F_MORSE, F_CUBICBONDS, F_CONNBONDS, F_HARMONIC,
21    F_ANGLES, F_G96ANGLES, F_PDIHS, F_RBDIHS, F_IDIHS, F_LJ14, F_COUL14, F_LJ,
22    F_BHAM, F_LJLR, F_DISPCORR, F_SR, F_LR, F_WPOL, F_POSRES, F_DISRES,
23    F_DISRESVIOL, F_ORIRES, F_ORIRESDEV, F_ANGRES, F_ANGRESZ, F_SHAKE,
24    F_SHAKENC, F_SETTLE, F_DUMMY2, F_DUMMY3, F_DUMMY3FD, F_DUMMY3FAD,
25    F_DUMMY3OUT, F_DUMMY4FD, F_EQM, F_EPOT, F_EKIN, F_ETOT, F_TEMP, F_PRES,
26    F_DVDL, F_DVDLKIN, F_NRE
27};
28typedef union
29{
30  struct
31  {
32  }
33  bham;
34  struct
35  {
36    real rA, krA, rB, krB;
37  }
38  harmonic;
39}
40t_iparams;
41typedef struct
42{
43  t_iparams *iparams;
44}
45t_idef;
46typedef struct
47{
48}
49t_inputrec;
50typedef struct
51{
52}
53t_commrec;
54typedef struct
55{
56}
57t_forcerec;
58typedef struct
59{
60}
61t_mdatoms;
62typedef struct
63{
64}
65t_filenm;
66enum
67{
68  eoPres, eoEpot, eoVir, eoDist, eoMu, eoForce, eoFx, eoFy, eoFz, eoPx, eoPy,
69    eoPz, eoPolarizability, eoDipole, eoObsNR, eoMemory =
70    eoObsNR, eoInter, eoUseVirial, eoNR
71};
72extern char *eoNames[eoNR];
73typedef struct
74{
75  int bPrint;
76}
77t_coupl_LJ;
78typedef struct
79{
80  int eObs;
81  t_iparams xi;
82}
83t_coupl_iparams;
84typedef struct
85{
86  real act_value[eoObsNR];
87  real av_value[eoObsNR];
88  real ref_value[eoObsNR];
89  int bObsUsed[eoObsNR];
90  int nLJ, nBU, nQ, nIP;
91  t_coupl_LJ *tcLJ;
92}
93t_coupl_rec;
94void xvgr_legend ();
95real calc_deviation ();
96void pr_dev ();
97static void
98pr_ff (t_coupl_rec * tcr, real time, t_idef * idef, t_commrec * cr, int nfile,
99       t_filenm fnm[])
100{
101  static FILE *prop;
102  static FILE **out = ((void *) 0);
103  static FILE **qq = ((void *) 0);
104  static FILE **ip = ((void *) 0);
105  char buf[256];
106  char *leg[] = {
107    "C12", "C6"
108  };
109  char **raleg;
110  int i, j, index;
111  if ((prop == ((void *) 0)) && (out == ((void *) 0)) && (qq == ((void *) 0))
112      && (ip == ((void *) 0)))
113    {
114      for (i = j = 0; (i < eoObsNR); i++)
115	{
116	  if (tcr->bObsUsed[i])
117	    {
118	      raleg[j++] =
119		(__extension__
120		 (__builtin_constant_p (eoNames[i])
121		  && ((size_t) (const void *) ((eoNames[i]) + 1) -
122		      (size_t) (const void *) (eoNames[i]) ==
123		      1) ? (((const char *) (eoNames[i]))[0] ==
124			    '\0' ? (char *) calloc ((size_t) 1,
125						    (size_t) 1) : (
126									   {
127									   size_t
128									   __len
129									   =
130									   strlen
131									   (eoNames
132									    [i])
133									   +
134									   1;
135									   char
136									   *__retval
137									   =
138									   (char
139									    *)
140									   malloc
141									   (__len);
142									   __retval;}
143	    )):	    __strdup (eoNames[i])));
144	      raleg[j++] =
145		(__extension__
146		 (__builtin_constant_p (buf)
147		  && ((size_t) (const void *) ((buf) + 1) -
148		      (size_t) (const void *) (buf) ==
149		      1) ? (((const char *) (buf))[0] ==
150			    '\0' ? (char *) calloc ((size_t) 1,
151						    (size_t) 1) : (
152									   {
153									   size_t
154									   __len
155									   =
156									   strlen
157									   (buf)
158									   +
159									   1;
160									   char
161									   *__retval
162									   =
163									   (char
164									    *)
165									   malloc
166									   (__len);
167									   __retval;}
168	    )):	    __strdup (buf)));
169	    }
170	}
171      if (tcr->nLJ)
172	{
173	  for (i = 0; (i < tcr->nLJ); i++)
174	    {
175	      if (tcr->tcLJ[i].bPrint)
176		{
177		  xvgr_legend (out[i], (sizeof (leg) / sizeof ((leg)[0])),
178			       leg);
179		}
180	    }
181	}
182    }
183}
184
185void
186do_coupling (FILE * log, int nfile, t_filenm fnm[], t_coupl_rec * tcr, real t,
187	     int step, real ener[], t_forcerec * fr, t_inputrec * ir,
188	     int bMaster, t_mdatoms * md, t_idef * idef, real mu_aver,
189	     int nmols, t_commrec * cr, matrix box, tensor virial,
190	     tensor pres, rvec mu_tot, rvec x[], rvec f[], int bDoIt)
191{
192  int i, j, ati, atj, atnr2, type, ftype;
193  real deviation[eoObsNR], prdev[eoObsNR], epot0, dist, rmsf;
194  real ff6, ff12, ffa, ffb, ffc, ffq, factor, dt, mu_ind;
195  int bTest, bPrint;
196  t_coupl_iparams *tip;
197  if (bPrint)
198    {
199      pr_ff (tcr, t, idef, cr, nfile, fnm);
200    }
201  for (i = 0; (i < eoObsNR); i++)
202    {
203      deviation[i] =
204	calc_deviation (tcr->av_value[i], tcr->act_value[i],
205			tcr->ref_value[i]);
206      prdev[i] = tcr->ref_value[i] - tcr->act_value[i];
207    }
208  if (bPrint)
209    pr_dev (tcr, t, prdev, cr, nfile, fnm);
210  for (i = 0; (i < atnr2); i++)
211    {
212      factor = dt * deviation[tip->eObs];
213      switch (ftype)
214	{
215	case F_BONDS:
216	  if (fabs (tip->xi.harmonic.krA) > 1.2e-38)
217	    idef->iparams[type].harmonic.krA *=
218	      (1 + factor / tip->xi.harmonic.krA);
219	}
220    }
221}
222