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