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