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