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