changed reading hint
[gromacs/adressmacs.git] / src / gmxlib / copyrite.c
bloba9dee311acc8610bf1b90b94e659860f58ba3024
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_copyrite_c = "$Id$";
31 #include <string.h>
32 #include <ctype.h>
33 #include "sysstuff.h"
34 #include "smalloc.h"
35 #include "string2.h"
36 #include "macros.h"
37 #include "time.h"
38 #include "random.h"
39 #include "copyrite.h"
40 #include "strdb.h"
41 #include "futil.h"
43 static void pr_two(FILE *out,int c,int i)
45 if (i < 10)
46 fprintf(out,"%c0%1d",c,i);
47 else
48 fprintf(out,"%c%2d",c,i);
51 void pr_difftime(FILE *out,double dt)
53 int ndays,nhours,nmins,nsecs;
54 bool bPrint,bPrinted;
56 ndays = dt/(24*3600);
57 dt = dt-24*3600*ndays;
58 nhours= dt/3600;
59 dt = dt-3600*nhours;
60 nmins = dt/60;
61 dt = dt-nmins*60;
62 nsecs = dt;
63 bPrint= (ndays > 0);
64 bPrinted=bPrint;
65 if (bPrint)
66 fprintf(out,"%d",ndays);
67 bPrint=bPrint || (nhours > 0);
68 if (bPrint) {
69 if (bPrinted)
70 pr_two(out,'d',nhours);
71 else
72 fprintf(out,"%d",nhours);
74 bPrinted=bPrinted || bPrint;
75 bPrint=bPrint || (nmins > 0);
76 if (bPrint) {
77 if (bPrinted)
78 pr_two(out,'h',nmins);
79 else
80 fprintf(out,"%d",nmins);
82 bPrinted=bPrinted || bPrint;
83 if (bPrinted)
84 pr_two(out,':',nsecs);
85 else
86 fprintf(out,"%ds",nsecs);
87 fprintf(out,"\n");
90 bool be_cool(void)
92 static int cool=-1;
94 if (cool == -1) {
95 if ((getenv("IAMCOOL")) == NULL)
96 cool=0;
97 else
98 cool=1;
100 return cool;
103 void space(FILE *out, int n)
105 fprintf(out,"%*s",n,"");
108 void f(char *a){int i;for(i=0;i<(int)strlen(a);i++)a[i]=~a[i]; }
110 static void sp_print(FILE *out,char *s)
112 int slen;
114 slen=strlen(s);
115 space(out,(80-slen)/2);
116 fprintf(out,"%s\n",s);
119 static void ster_print(FILE *out,char *s)
121 int slen;
122 char buf[128];
124 sprintf(buf,":-) %s (-:",s);
125 slen=strlen(buf);
126 space(out,(80-slen)/2);
127 fprintf(out,"%s\n",buf);
130 /* char *GromacsVersion() */
131 /* { */
132 /* return ver; */
133 /* } */
135 static int nran=0;
137 static char *pukeit(char *db,char *defstring)
139 static char hulp[STRLEN];
140 FILE *fp;
141 char **help;
142 int i,nhlp;
143 int seed;
145 if (!be_cool())
146 return defstring;
147 else if ((fp = low_libopen(db,FALSE)) != NULL) {
148 nhlp=fget_lines(fp,&help);
149 fclose(fp);
150 seed=time(NULL);
151 nran=nhlp*rando(&seed);
152 if (strlen(help[nran]) >= STRLEN)
153 help[nran][STRLEN-1] = '\0';
154 strcpy(hulp,help[nran]);
155 f(hulp);
156 for(i=0; (i<nhlp); i++)
157 sfree(help[i]);
158 sfree(help);
160 return hulp;
162 else
163 return defstring;
166 char *bromacs(void)
168 return pukeit("bromacs.dat",
169 "Groningen Machine for Chemical Simulation");
172 char *cool_quote(void)
174 static char buf[1024];
175 char *s,*ptr;
177 /* protect audience from explicit lyrics */
178 s = pukeit("gurgle.dat","Thanx for Using GROMACS - Have a Nice Day");
180 if (be_cool() && ((ptr=strchr(s,'_')) != NULL)) {
181 *ptr='\0';
182 ptr++;
183 sprintf(buf,"\"%s\" %s",s,ptr);
185 else {
186 strcpy(buf,s);
189 return buf;
192 void CopyRight(FILE *out,char *szProgram)
194 #define NCR asize(CopyrightText)
195 char buf[256];
196 char *ptr;
198 int i;
200 ster_print(out,"G R O M A C S");
201 fprintf(out,"\n");
203 ptr=bromacs();
204 sp_print(out,ptr);
205 fprintf(out,"\n");
207 ster_print(out,GromacsVersion());
208 fprintf(out,"\n");
210 for(i=0; (i<NCR); i++)
211 sp_print(out,CopyrightText[i]);
213 sprintf(buf,"%s",szProgram);
214 #ifdef DOUBLE
215 strcat(buf," (double precision)");
216 #endif
217 ster_print(out,buf);
218 fprintf(out,"\n");
221 void thanx(FILE *fp)
223 char *cq,*c;
225 /* protect the audience from suggestive discussions */
226 cq=cool_quote();
228 if (be_cool()) {
229 snew(c,strlen(cq)+20);
230 sprintf(c,"gcq#%d: %s\n",nran,cq);
231 fprintf(fp,"\n%s\n",c);
232 sfree(c);
234 else
235 fprintf(fp,"\n%s\n",cq);
238 void please_cite(FILE *fp,char *key)
240 static char *citedb[] = {
241 "Berendsen95a",
242 "H. J. C. Berendsen, D. van der Spoel and R. van Drunen",
243 "GROMACS: A message-passing parallel molecular dynamics implementation",
244 "Comp. Phys. Comm.",
245 "91 1995 43 56",
247 "Berendsen84a",
248 "H. J. C. Berendsen, J. P. M. Postma, A. DiNola and J. R. Haak",
249 "Molecular dynamics with coupling to an external bath",
250 "J. Chem. Phys.",
251 "81 1984 3684 3690",
253 "Ryckaert77a",
254 "J. P. Ryckaert and G. Ciccotti and H. J. C. Berendsen",
255 "Numerical Integration of the Cartesian Equations of Motion of a "
256 "System with Constraints; Molecular Dynamics of n-Alkanes",
257 "J. Comp. Phys.",
258 "23 1977 327 341",
260 "Miyamoto92a",
261 "S. Miyamoto and P. A. Kollman",
262 "SETTLE: An Analytical Version of the SHAKE and RATTLE Algorithms "
263 "for Rigid Water Models",
264 "J. Comp. Chem.",
265 "13 1992 952 962",
267 "Barth95a",
268 "E. Barth and K. Kuczera and B. Leimkuhler and R. D. Skeel",
269 "Algorithms for Constrained Molecular Dynamics",
270 "J. Comp. Chem.",
271 "16 1995 1192 1209",
273 "Torda89a",
274 "A. E. Torda and R. M. Scheek and W. F. van Gunsteren",
275 "Time-dependent distance restraints in molecular dynamics simulations",
276 "Chem. Phys. Lett.",
277 "157 1989 289 294",
279 "Tironi95a",
280 "I. G. Tironi and R. Sperb and P. E. Smith and W. F. van Gunsteren",
281 "Generalized reaction field method for molecular dynamics simulations",
282 "J. Chem. Phys",
283 "102 1995 5451 5459",
285 "Hess97a",
286 "B. Hess and H. Bekker and H. J. C. Berendsen and J. G. E. M. Fraaije",
287 "LINCS: A Linear Constraint Solver for molecular simulations",
288 "J. Comp. Chem.",
289 "18 1997 1463 1472",
291 "DeGroot97a",
292 "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",
293 "Prediction of Protein Conformational Freedom From Distance Constrains",
294 "Proteins",
295 "29 1997 240 251"
297 #define NSTR asize(citedb)
299 int j,index,year,vol,p1,p2;
300 char *ptr[3];
301 #define LINE_WIDTH 79
303 index = search_str(NSTR,citedb,key);
305 fprintf(fp,"\n++++++++ PLEASE CITE THE FOLLOWING REFERENCE ++++++++\n");
306 if ((index != -1) && (index+4 < NSTR)) {
307 if (sscanf(citedb[index+4],"%d%d%d%d",&vol,&year,&p1,&p2) != 4) {
308 vol=year=p1=p2=0;
310 /* Insert newlines */
311 for(j=1; (j<=3); j++)
312 ptr[j-1] = wrap_lines(citedb[index+j],LINE_WIDTH,0);
313 fprintf(fp,"%s\n%s\n%s %d (%d) pp. %d-%d\n",
314 ptr[0],ptr[1],ptr[2],
315 vol,year,p1,p2);
316 for(j=0; (j<3); j++)
317 sfree(ptr[j]);
319 else {
320 fprintf(fp,"Entry %s not found in citation database\n",key);
322 fprintf(fp,"-------- -------- --- Thank You --- -------- --------\n\n");
323 fflush(fp);