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