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