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