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