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