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