fixed GPU particle gridding performance issue
[alexxy/gromacs.git] / src / gmxlib / copyrite.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #ifdef GMX_THREAD_MPI
43 #include <thread_mpi.h>
44 #endif
45
46 #ifdef HAVE_LIBMKL
47 #include <mkl.h>
48 #endif
49 #ifdef GMX_FFT_FFTW3
50 #include <fftw3.h>
51 #endif
52
53 /* This file is completely threadsafe - keep it that way! */
54
55 #include <string.h>
56 #include <ctype.h>
57 #include "sysstuff.h"
58 #include "smalloc.h"
59 #include "string2.h"
60 #include "macros.h"
61 #include <time.h>
62 #include "random.h"
63 #include "statutil.h"
64 #include "copyrite.h"
65 #include "strdb.h"
66 #include "futil.h"
67 #include "vec.h"
68 #include "buildinfo.h"
69 #include "gmx_cpuid.h"
70
71 static void pr_two(FILE *out, int c, int i)
72 {
73     if (i < 10)
74     {
75         fprintf(out, "%c0%1d", c, i);
76     }
77     else
78     {
79         fprintf(out, "%c%2d", c, i);
80     }
81 }
82
83 void pr_difftime(FILE *out, double dt)
84 {
85     int        ndays, nhours, nmins, nsecs;
86     gmx_bool   bPrint, bPrinted;
87
88     ndays    = dt/(24*3600);
89     dt       = dt-24*3600*ndays;
90     nhours   = dt/3600;
91     dt       = dt-3600*nhours;
92     nmins    = dt/60;
93     dt       = dt-nmins*60;
94     nsecs    = dt;
95     bPrint   = (ndays > 0);
96     bPrinted = bPrint;
97     if (bPrint)
98     {
99         fprintf(out, "%d", ndays);
100     }
101     bPrint = bPrint || (nhours > 0);
102     if (bPrint)
103     {
104         if (bPrinted)
105         {
106             pr_two(out, 'd', nhours);
107         }
108         else
109         {
110             fprintf(out, "%d", nhours);
111         }
112     }
113     bPrinted = bPrinted || bPrint;
114     bPrint   = bPrint || (nmins > 0);
115     if (bPrint)
116     {
117         if (bPrinted)
118         {
119             pr_two(out, 'h', nmins);
120         }
121         else
122         {
123             fprintf(out, "%d", nmins);
124         }
125     }
126     bPrinted = bPrinted || bPrint;
127     if (bPrinted)
128     {
129         pr_two(out, ':', nsecs);
130     }
131     else
132     {
133         fprintf(out, "%ds", nsecs);
134     }
135     fprintf(out, "\n");
136 }
137
138
139 gmx_bool be_cool(void)
140 {
141     /* Yes, it is bad to check the environment variable every call,
142      * but we dont call this routine often, and it avoids using
143      * a mutex for locking the variable...
144      */
145 #ifdef GMX_COOL_QUOTES
146     return (getenv("GMX_NO_QUOTES") == NULL);
147 #else
148     /*be uncool*/
149     return FALSE;
150 #endif
151 }
152
153 void space(FILE *out, int n)
154 {
155     fprintf(out, "%*s", n, "");
156 }
157
158 void f(char *a)
159 {
160     int i;
161     int len = strlen(a);
162
163     for (i = 0; i < len; i++)
164     {
165         a[i] = ~a[i];
166     }
167 }
168
169 static void sp_print(FILE *out, const char *s)
170 {
171     int slen;
172
173     slen = strlen(s);
174     space(out, (80-slen)/2);
175     fprintf(out, "%s\n", s);
176 }
177
178 static void ster_print(FILE *out, const char *s)
179 {
180     int  slen;
181     char buf[128];
182
183     snprintf(buf, 128, ":-)  %s  (-:", s);
184     slen = strlen(buf);
185     space(out, (80-slen)/2);
186     fprintf(out, "%s\n", buf);
187 }
188
189
190 static void pukeit(const char *db, const char *defstring, char *retstring,
191                    int retsize, int *cqnum)
192 {
193     FILE  *fp;
194     char **help;
195     int    i, nhlp;
196     int    seed;
197
198     if (be_cool() && ((fp = low_libopen(db, FALSE)) != NULL))
199     {
200         nhlp = fget_lines(fp, &help);
201         /* for libraries we can use the low-level close routines */
202         ffclose(fp);
203         seed   = time(NULL);
204         *cqnum = nhlp*rando(&seed);
205         if (strlen(help[*cqnum]) >= STRLEN)
206         {
207             help[*cqnum][STRLEN-1] = '\0';
208         }
209         strncpy(retstring, help[*cqnum], retsize);
210         f(retstring);
211         for (i = 0; (i < nhlp); i++)
212         {
213             sfree(help[i]);
214         }
215         sfree(help);
216     }
217     else
218     {
219         strncpy(retstring, defstring, retsize);
220     }
221 }
222
223 void bromacs(char *retstring, int retsize)
224 {
225     int dum;
226
227     pukeit("bromacs.dat",
228            "Groningen Machine for Chemical Simulation",
229            retstring, retsize, &dum);
230 }
231
232 void cool_quote(char *retstring, int retsize, int *cqnum)
233 {
234     char *tmpstr;
235     char *s, *ptr;
236     int   tmpcq, *p;
237
238     if (cqnum != NULL)
239     {
240         p = cqnum;
241     }
242     else
243     {
244         p = &tmpcq;
245     }
246
247     /* protect audience from explicit lyrics */
248     snew(tmpstr, retsize+1);
249     pukeit("gurgle.dat", "Thanx for Using GROMACS - Have a Nice Day",
250            tmpstr, retsize-2, p);
251
252     if ((ptr = strchr(tmpstr, '_')) != NULL)
253     {
254         *ptr = '\0';
255         ptr++;
256         sprintf(retstring, "\"%s\" %s", tmpstr, ptr);
257     }
258     else
259     {
260         strcpy(retstring, tmpstr);
261     }
262     sfree(tmpstr);
263 }
264
265 void CopyRight(FILE *out, const char *szProgram)
266 {
267     /* Dont change szProgram arbitrarily - it must be argv[0], i.e. the
268      * name of a file. Otherwise, we won't be able to find the library dir.
269      */
270 #define NCR (int)asize(CopyrightText)
271 /* TODO: Is this exception still needed? */
272 #ifdef GMX_FAHCORE
273 #define NLICENSE 0 /*FAH has an exception permission from GPL to allow digital signatures in Gromacs*/
274 #else
275 #define NLICENSE (int)asize(LicenseText)
276 #endif
277
278     char buf[256], tmpstr[1024];
279     int  i;
280
281 #ifdef GMX_FAHCORE
282     set_program_name("Gromacs");
283 #else
284     set_program_name(szProgram);
285 #endif
286
287     ster_print(out, "G  R  O  M  A  C  S");
288     fprintf(out, "\n");
289
290     bromacs(tmpstr, 1023);
291     sp_print(out, tmpstr);
292     fprintf(out, "\n");
293
294     ster_print(out, GromacsVersion());
295     fprintf(out, "\n");
296
297     /* fprintf(out,"\n");*/
298
299     /* sp_print(out,"PLEASE NOTE: THIS IS A BETA VERSION\n");
300
301        fprintf(out,"\n"); */
302
303     for (i = 0; (i < NCR); i++)
304     {
305         sp_print(out, CopyrightText[i]);
306     }
307     for (i = 0; (i < NLICENSE); i++)
308     {
309         sp_print(out, LicenseText[i]);
310     }
311
312     fprintf(out, "\n");
313
314     snprintf(buf, 256, "%s", Program());
315 #ifdef GMX_DOUBLE
316     strcat(buf, " (double precision)");
317 #endif
318     ster_print(out, buf);
319     fprintf(out, "\n");
320 }
321
322
323 void thanx(FILE *fp)
324 {
325     char cq[1024];
326     int  cqnum;
327
328     /* protect the audience from suggestive discussions */
329     cool_quote(cq, 1023, &cqnum);
330
331     if (be_cool())
332     {
333         fprintf(fp, "\ngcq#%d: %s\n\n", cqnum, cq);
334     }
335     else
336     {
337         fprintf(fp, "\n%s\n\n", cq);
338     }
339 }
340
341 typedef struct {
342     const char *key;
343     const char *author;
344     const char *title;
345     const char *journal;
346     int         volume, year;
347     const char *pages;
348 } t_citerec;
349
350 void please_cite(FILE *fp, const char *key)
351 {
352     static const t_citerec citedb[] = {
353         { "Allen1987a",
354           "M. P. Allen and D. J. Tildesley",
355           "Computer simulation of liquids",
356           "Oxford Science Publications",
357           1, 1987, "1" },
358         { "Berendsen95a",
359           "H. J. C. Berendsen, D. van der Spoel and R. van Drunen",
360           "GROMACS: A message-passing parallel molecular dynamics implementation",
361           "Comp. Phys. Comm.",
362           91, 1995, "43-56" },
363         { "Berendsen84a",
364           "H. J. C. Berendsen, J. P. M. Postma, A. DiNola and J. R. Haak",
365           "Molecular dynamics with coupling to an external bath",
366           "J. Chem. Phys.",
367           81, 1984, "3684-3690" },
368         { "Ryckaert77a",
369           "J. P. Ryckaert and G. Ciccotti and H. J. C. Berendsen",
370           "Numerical Integration of the Cartesian Equations of Motion of a System with Constraints; Molecular Dynamics of n-Alkanes",
371           "J. Comp. Phys.",
372           23, 1977, "327-341" },
373         { "Miyamoto92a",
374           "S. Miyamoto and P. A. Kollman",
375           "SETTLE: An Analytical Version of the SHAKE and RATTLE Algorithms for Rigid Water Models",
376           "J. Comp. Chem.",
377           13, 1992, "952-962" },
378         { "Cromer1968a",
379           "D. T. Cromer & J. B. Mann",
380           "X-ray scattering factors computed from numerical Hartree-Fock wave functions",
381           "Acta Cryst. A",
382           24, 1968, "321" },
383         { "Barth95a",
384           "E. Barth and K. Kuczera and B. Leimkuhler and R. D. Skeel",
385           "Algorithms for Constrained Molecular Dynamics",
386           "J. Comp. Chem.",
387           16, 1995, "1192-1209" },
388         { "Essmann95a",
389           "U. Essmann, L. Perera, M. L. Berkowitz, T. Darden, H. Lee and L. G. Pedersen ",
390           "A smooth particle mesh Ewald method",
391           "J. Chem. Phys.",
392           103, 1995, "8577-8592" },
393         { "Torda89a",
394           "A. E. Torda and R. M. Scheek and W. F. van Gunsteren",
395           "Time-dependent distance restraints in molecular dynamics simulations",
396           "Chem. Phys. Lett.",
397           157, 1989, "289-294" },
398         { "Tironi95a",
399           "I. G. Tironi and R. Sperb and P. E. Smith and W. F. van Gunsteren",
400           "Generalized reaction field method for molecular dynamics simulations",
401           "J. Chem. Phys",
402           102, 1995, "5451-5459" },
403         { "Hess97a",
404           "B. Hess and H. Bekker and H. J. C. Berendsen and J. G. E. M. Fraaije",
405           "LINCS: A Linear Constraint Solver for molecular simulations",
406           "J. Comp. Chem.",
407           18, 1997, "1463-1472" },
408         { "Hess2008a",
409           "B. Hess",
410           "P-LINCS: A Parallel Linear Constraint Solver for molecular simulation",
411           "J. Chem. Theory Comput.",
412           4, 2008, "116-122" },
413         { "Hess2008b",
414           "B. Hess and C. Kutzner and D. van der Spoel and E. Lindahl",
415           "GROMACS 4: Algorithms for highly efficient, load-balanced, and scalable molecular simulation",
416           "J. Chem. Theory Comput.",
417           4, 2008, "435-447" },
418         { "Hub2010",
419           "J. S. Hub, B. L. de Groot and D. van der Spoel",
420           "g_wham - A free weighted histogram analysis implementation including robust error and autocorrelation estimates",
421           "J. Chem. Theory Comput.",
422           6, 2010, "3713-3720"},
423         { "In-Chul99a",
424           "Y. In-Chul and M. L. Berkowitz",
425           "Ewald summation for systems with slab geometry",
426           "J. Chem. Phys.",
427           111, 1999, "3155-3162" },
428         { "DeGroot97a",
429           "B. L. de Groot and D. M. F. van Aalten and R. M. Scheek and A. Amadei and G. Vriend and H. J. C. Berendsen",
430           "Prediction of Protein Conformational Freedom From Distance Constrains",
431           "Proteins",
432           29, 1997, "240-251" },
433         { "Spoel98a",
434           "D. van der Spoel and P. J. van Maaren and H. J. C. Berendsen",
435           "A systematic study of water models for molecular simulation. Derivation of models optimized for use with a reaction-field.",
436           "J. Chem. Phys.",
437           108, 1998, "10220-10230" },
438         { "Wishart98a",
439           "D. S. Wishart and A. M. Nip",
440           "Protein Chemical Shift Analysis: A Practical Guide",
441           "Biochem. Cell Biol.",
442           76, 1998, "153-163" },
443         { "Maiorov95",
444           "V. N. Maiorov and G. M. Crippen",
445           "Size-Independent Comparison of Protein Three-Dimensional Structures",
446           "PROTEINS: Struct. Funct. Gen.",
447           22, 1995, "273-283" },
448         { "Feenstra99",
449           "K. A. Feenstra and B. Hess and H. J. C. Berendsen",
450           "Improving Efficiency of Large Time-scale Molecular Dynamics Simulations of Hydrogen-rich Systems",
451           "J. Comput. Chem.",
452           20, 1999, "786-798" },
453         { "Timneanu2004a",
454           "N. Timneanu and C. Caleman and J. Hajdu and D. van der Spoel",
455           "Auger Electron Cascades in Water and Ice",
456           "Chem. Phys.",
457           299, 2004, "277-283" },
458         { "Pascal2011a",
459           "T. A. Pascal and S. T. Lin and W. A. Goddard III",
460           "Thermodynamics of liquids: standard molar entropies and heat capacities of common solvents from 2PT molecular dynamics",
461           "Phys. Chem. Chem. Phys.",
462           13, 2011, "169-181" },
463         { "Caleman2011b",
464           "C. Caleman and P. J. van Maaren and M. Hong and J. S. Hub and L. T. da Costa and D. van der Spoel",
465           "Force Field Benchmark of Organic Liquids: Density, Enthalpy of Vaporization, Heat Capacities, Surface Tension, Isothermal Compressibility, Volumetric Expansion Coefficient, and Dielectric Constant",
466           "J. Chem. Theo. Comp.",
467           8, 2012, "61" },
468         { "Lindahl2001a",
469           "E. Lindahl and B. Hess and D. van der Spoel",
470           "GROMACS 3.0: A package for molecular simulation and trajectory analysis",
471           "J. Mol. Mod.",
472           7, 2001, "306-317" },
473         { "Wang2001a",
474           "J. Wang and W. Wang and S. Huo and M. Lee and P. A. Kollman",
475           "Solvation model based on weighted solvent accessible surface area",
476           "J. Phys. Chem. B",
477           105, 2001, "5055-5067" },
478         { "Eisenberg86a",
479           "D. Eisenberg and A. D. McLachlan",
480           "Solvation energy in protein folding and binding",
481           "Nature",
482           319, 1986, "199-203" },
483         { "Eisenhaber95",
484           "Frank Eisenhaber and Philip Lijnzaad and Patrick Argos and Chris Sander and Michael Scharf",
485           "The Double Cube Lattice Method: Efficient Approaches to Numerical Integration of Surface Area and Volume and to Dot Surface Contouring of Molecular Assemblies",
486           "J. Comp. Chem.",
487           16, 1995, "273-284" },
488         { "Hess2002",
489           "B. Hess, H. Saint-Martin and H.J.C. Berendsen",
490           "Flexible constraints: an adiabatic treatment of quantum degrees of freedom, with application to the flexible and polarizable MCDHO model for water",
491           "J. Chem. Phys.",
492           116, 2002, "9602-9610" },
493         { "Hetenyi2002b",
494           "Csaba Hetenyi and David van der Spoel",
495           "Efficient docking of peptides to proteins without prior knowledge of the binding site.",
496           "Prot. Sci.",
497           11, 2002, "1729-1737" },
498         { "Hess2003",
499           "B. Hess and R.M. Scheek",
500           "Orientation restraints in molecular dynamics simulations using time and ensemble averaging",
501           "J. Magn. Res.",
502           164, 2003, "19-27" },
503         { "Rappe1991a",
504           "A. K. Rappe and W. A. Goddard III",
505           "Charge Equillibration for Molecular Dynamics Simulations",
506           "J. Phys. Chem.",
507           95, 1991, "3358-3363" },
508         { "Mu2005a",
509           "Y. Mu, P. H. Nguyen and G. Stock",
510           "Energy landscape of a small peptide revelaed by dihedral angle principal component analysis",
511           "Prot. Struct. Funct. Bioinf.",
512           58, 2005, "45-52" },
513         { "Okabe2001a",
514           "T. Okabe and M. Kawata and Y. Okamoto and M. Mikami",
515           "Replica-exchange {M}onte {C}arlo method for the isobaric-isothermal ensemble",
516           "Chem. Phys. Lett.",
517           335, 2001, "435-439" },
518         { "Hukushima96a",
519           "K. Hukushima and K. Nemoto",
520           "Exchange Monte Carlo Method and Application to Spin Glass Simulations",
521           "J. Phys. Soc. Jpn.",
522           65, 1996, "1604-1608" },
523         { "Tropp80a",
524           "J. Tropp",
525           "Dipolar Relaxation and Nuclear Overhauser effects in nonrigid molecules: The effect of fluctuating internuclear distances",
526           "J. Chem. Phys.",
527           72, 1980, "6035-6043" },
528         { "Bultinck2002a",
529           "P. Bultinck and W. Langenaeker and P. Lahorte and F. De Proft and P. Geerlings and M. Waroquier and J. P. Tollenaere",
530           "The electronegativity equalization method I: Parametrization and validation for atomic charge calculations",
531           "J. Phys. Chem. A",
532           106, 2002, "7887-7894" },
533         { "Yang2006b",
534           "Q. Y. Yang and K. A. Sharp",
535           "Atomic charge parameters for the finite difference Poisson-Boltzmann method using electronegativity neutralization",
536           "J. Chem. Theory Comput.",
537           2, 2006, "1152-1167" },
538         { "Spoel2005a",
539           "D. van der Spoel, E. Lindahl, B. Hess, G. Groenhof, A. E. Mark and H. J. C. Berendsen",
540           "GROMACS: Fast, Flexible and Free",
541           "J. Comp. Chem.",
542           26, 2005, "1701-1719" },
543         { "Spoel2006b",
544           "D. van der Spoel, P. J. van Maaren, P. Larsson and N. Timneanu",
545           "Thermodynamics of hydrogen bonding in hydrophilic and hydrophobic media",
546           "J. Phys. Chem. B",
547           110, 2006, "4393-4398" },
548         { "Spoel2006d",
549           "D. van der Spoel and M. M. Seibert",
550           "Protein folding kinetics and thermodynamics from atomistic simulations",
551           "Phys. Rev. Letters",
552           96, 2006, "238102" },
553         { "Palmer94a",
554           "B. J. Palmer",
555           "Transverse-current autocorrelation-function calculations of the shear viscosity for molecular liquids",
556           "Phys. Rev. E",
557           49, 1994, "359-366" },
558         { "Bussi2007a",
559           "G. Bussi, D. Donadio and M. Parrinello",
560           "Canonical sampling through velocity rescaling",
561           "J. Chem. Phys.",
562           126, 2007, "014101" },
563         { "Hub2006",
564           "J. S. Hub and B. L. de Groot",
565           "Does CO2 permeate through Aquaporin-1?",
566           "Biophys. J.",
567           91, 2006, "842-848" },
568         { "Hub2008",
569           "J. S. Hub and B. L. de Groot",
570           "Mechanism of selectivity in aquaporins and aquaglyceroporins",
571           "PNAS",
572           105, 2008, "1198-1203" },
573         { "Friedrich2009",
574           "M. S. Friedrichs, P. Eastman, V. Vaidyanathan, M. Houston, S. LeGrand, A. L. Beberg, D. L. Ensign, C. M. Bruns, and V. S. Pande",
575           "Accelerating Molecular Dynamic Simulation on Graphics Processing Units",
576           "J. Comp. Chem.",
577           30, 2009, "864-872" },
578         { "Engin2010",
579           "O. Engin, A. Villa, M. Sayar and B. Hess",
580           "Driving Forces for Adsorption of Amphiphilic Peptides to Air-Water Interface",
581           "J. Phys. Chem. B",
582           114, 2010, "11093" },
583         { "Fritsch12",
584           "S. Fritsch, C. Junghans and K. Kremer",
585           "Adaptive molecular simulation study on structure formation of toluene around C60 using Gromacs",
586           "J. Chem. Theo. Comp.",
587           8, 2012, "398" },
588         { "Junghans10",
589           "C. Junghans and S. Poblete",
590           "A reference implementation of the adaptive resolution scheme in ESPResSo",
591           "Comp. Phys. Comm.",
592           181, 2010, "1449" },
593         { "Wang2010",
594           "H. Wang, F. Dommert, C.Holm",
595           "Optimizing working parameters of the smooth particle mesh Ewald algorithm in terms of accuracy and efficiency",
596           "J. Chem. Phys. B",
597           133, 2010, "034117" },
598         { "Sugita1999a",
599           "Y. Sugita, Y. Okamoto",
600           "Replica-exchange molecular dynamics method for protein folding",
601           "Chem. Phys. Lett.",
602           314, 1999, "141-151" },
603         { "Kutzner2011",
604           "C. Kutzner and J. Czub and H. Grubmuller",
605           "Keep it Flexible: Driving Macromolecular Rotary Motions in Atomistic Simulations with GROMACS",
606           "J. Chem. Theory Comput.",
607           7, 2011, "1381-1393" },
608         { "Hoefling2011",
609           "M. Hoefling, N. Lima, D. Haenni, C.A.M. Seidel, B. Schuler, H. Grubmuller",
610           "Structural Heterogeneity and Quantitative FRET Efficiency Distributions of Polyprolines through a Hybrid Atomistic Simulation and Monte Carlo Approach",
611           "PLoS ONE",
612           6, 2011, "e19791" },
613         { "Hockney1988",
614           "R. W. Hockney and J. W. Eastwood",
615           "Computer simulation using particles",
616           "IOP, Bristol",
617           1, 1988, "1" },
618         { "Ballenegger2012",
619           "V. Ballenegger, J.J. Cerda, and C. Holm",
620           "How to Convert SPME to P3M: Influence Functions and Error Estimates",
621           "J. Chem. Theory Comput.",
622           8, 2012, "936-947" },
623         { "Garmay2012",
624           "Garmay Yu, Shvetsov A, Karelov D, Lebedev D, Radulescu A, Petukhov M, Isaev-Ivanov V",
625           "Correlated motion of protein subdomains and large-scale conformational flexibility of RecA protein filament",
626           "Journal of Physics: Conference Series",
627           340, 2012, "012094" }
628     };
629 #define NSTR (int)asize(citedb)
630
631     int   j, index;
632     char *author;
633     char *title;
634 #define LINE_WIDTH 79
635
636     if (fp == NULL)
637     {
638         return;
639     }
640
641     for (index = 0; (index < NSTR) && (strcmp(citedb[index].key, key) != 0); index++)
642     {
643         ;
644     }
645
646     fprintf(fp, "\n++++ PLEASE READ AND CITE THE FOLLOWING REFERENCE ++++\n");
647     if (index < NSTR)
648     {
649         /* Insert newlines */
650         author = wrap_lines(citedb[index].author, LINE_WIDTH, 0, FALSE);
651         title  = wrap_lines(citedb[index].title, LINE_WIDTH, 0, FALSE);
652         fprintf(fp, "%s\n%s\n%s %d (%d) pp. %s\n",
653                 author, title, citedb[index].journal,
654                 citedb[index].volume, citedb[index].year,
655                 citedb[index].pages);
656         sfree(author);
657         sfree(title);
658     }
659     else
660     {
661         fprintf(fp, "Entry %s not found in citation database\n", key);
662     }
663     fprintf(fp, "-------- -------- --- Thank You --- -------- --------\n\n");
664     fflush(fp);
665 }
666
667 #ifdef USE_VERSION_H
668 /* Version information generated at compile time. */
669 #include "version.h"
670 #else
671 /* Fall back to statically defined version. */
672 static const char _gmx_ver_string[] = "VERSION " VERSION;
673 #endif
674
675 const char *GromacsVersion()
676 {
677     return _gmx_ver_string;
678 }
679
680 void gmx_print_version_info_gpu(FILE *fp);
681
682 void gmx_print_version_info(FILE *fp)
683 {
684     fprintf(fp, "Gromacs version:    %s\n", _gmx_ver_string);
685 #ifdef USE_VERSION_H
686     fprintf(fp, "GIT SHA1 hash:      %s\n", _gmx_full_git_hash);
687     /* Only print out the branch information if present.
688      * The generating script checks whether the branch point actually
689      * coincides with the hash reported above, and produces an empty string
690      * in such cases. */
691     if (_gmx_central_base_hash[0] != 0)
692     {
693         fprintf(fp, "Branched from:      %s\n", _gmx_central_base_hash);
694     }
695 #endif
696
697 #ifdef GMX_DOUBLE
698     fprintf(fp, "Precision:          double\n");
699 #else
700     fprintf(fp, "Precision:          single\n");
701 #endif
702     fprintf(fp, "Memory model:       %lu bit\n", 8*sizeof(void *));
703
704 #ifdef GMX_THREAD_MPI
705     fprintf(fp, "MPI library:        thread_mpi\n");
706 #elif defined(GMX_MPI)
707     fprintf(fp, "MPI library:        MPI\n");
708 #else
709     fprintf(fp, "MPI library:        none\n");
710 #endif
711 #ifdef GMX_OPENMP
712     fprintf(fp, "OpenMP support:     enabled\n");
713 #else
714     fprintf(fp, "OpenMP support:     disabled\n");
715 #endif
716 #ifdef GMX_GPU
717     fprintf(fp, "GPU support:        enabled\n");
718 #else
719     fprintf(fp, "GPU support:        disabled\n");
720 #endif
721     /* A preprocessor trick to avoid duplicating logic from vec.h */
722 #define gmx_stringify2(x) #x
723 #define gmx_stringify(x) gmx_stringify2(x)
724     fprintf(fp, "invsqrt routine:    %s\n", gmx_stringify(gmx_invsqrt(x)));
725     fprintf(fp, "CPU acceleration:   %s\n", GMX_CPU_ACCELERATION_STRING);
726
727     /* TODO: Would be nicer to wrap this in a gmx_fft_version() call, but
728      * since that is currently in mdlib, can wait for master. */
729 #ifdef GMX_FFT_FFTPACK
730     fprintf(fp, "FFT library:        fftpack (built-in)\n");
731 #elif defined(GMX_FFT_FFTW3) && defined(GMX_NATIVE_WINDOWS)
732     fprintf(fp, "FFT library:        %s\n", "fftw3");
733 #elif defined(GMX_FFT_FFTW3) && defined(GMX_DOUBLE)
734     fprintf(fp, "FFT library:        %s\n", fftw_version);
735 #elif defined(GMX_FFT_FFTW3)
736     fprintf(fp, "FFT library:        %s\n", fftwf_version);
737 #elif defined(GMX_FFT_MKL)
738     fprintf(fp, "FFT library:        MKL\n");
739 #else
740     fprintf(fp, "FFT library:        unknown\n");
741 #endif
742 #ifdef GMX_LARGEFILES
743     fprintf(fp, "Large file support: enabled\n");
744 #else
745     fprintf(fp, "Large file support: disabled\n");
746 #endif
747 #ifdef HAVE_RDTSCP
748     fprintf(fp, "RDTSCP usage:       enabled\n");
749 #else
750     fprintf(fp, "RDTSCP usage:       disabled\n");
751 #endif
752
753     fprintf(fp, "Built on:           %s\n", BUILD_TIME);
754     fprintf(fp, "Built by:           %s\n", BUILD_USER);
755     fprintf(fp, "Build OS/arch:      %s\n", BUILD_HOST);
756     fprintf(fp, "Build CPU vendor:   %s\n", BUILD_CPU_VENDOR);
757     fprintf(fp, "Build CPU brand:    %s\n", BUILD_CPU_BRAND);
758     fprintf(fp, "Build CPU family:   %d   Model: %d   Stepping: %d\n",
759             BUILD_CPU_FAMILY, BUILD_CPU_MODEL, BUILD_CPU_STEPPING);
760     /* TODO: The below strings can be quite long, so it would be nice to wrap
761      * them. Can wait for later, as the master branch has ready code to do all
762      * that. */
763     fprintf(fp, "Build CPU features: %s\n", BUILD_CPU_FEATURES);
764     fprintf(fp, "C compiler:         %s\n", BUILD_C_COMPILER);
765     fprintf(fp, "C compiler flags:   %s\n", BUILD_CFLAGS);
766     if (BUILD_CXX_COMPILER[0] != '\0')
767     {
768         fprintf(fp, "C++ compiler:       %s\n", BUILD_CXX_COMPILER);
769         fprintf(fp, "C++ compiler flags: %s\n", BUILD_CXXFLAGS);
770     }
771 #ifdef HAVE_LIBMKL
772     /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */
773     fprintf(fp, "Linked with Intel MKL version %s.%s.%s.\n",
774             __INTEL_MKL__, __INTEL_MKL_MINOR__, __INTEL_MKL_UPDATE__);
775 #endif
776 #ifdef GMX_GPU
777     gmx_print_version_info_gpu(fp);
778 #endif
779 }