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