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