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