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