Add TNG writing and reading support
[alexxy/gromacs.git] / src / gromacs / gmxlib / txtdump.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  * Copyright (c) 2013, 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 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40
41 /* This file is completely threadsafe - please keep it that way! */
42
43 #include <stdio.h>
44 #include "smalloc.h"
45 #include "typedefs.h"
46 #include "names.h"
47 #include "txtdump.h"
48 #include "string2.h"
49 #include "vec.h"
50 #include "macros.h"
51
52
53 int pr_indent(FILE *fp, int n)
54 {
55     int i;
56
57     for (i = 0; i < n; i++)
58     {
59         (void) fprintf(fp, " ");
60     }
61     return n;
62 }
63
64 int available(FILE *fp, void *p, int indent, const char *title)
65 {
66     if (!p)
67     {
68         if (indent > 0)
69         {
70             pr_indent(fp, indent);
71         }
72         (void) fprintf(fp, "%s: not available\n", title);
73     }
74     return (p != NULL);
75 }
76
77 int pr_title(FILE *fp, int indent, const char *title)
78 {
79     (void) pr_indent(fp, indent);
80     (void) fprintf(fp, "%s:\n", title);
81     return (indent+INDENT);
82 }
83
84 int pr_title_n(FILE *fp, int indent, const char *title, int n)
85 {
86     (void) pr_indent(fp, indent);
87     (void) fprintf(fp, "%s (%d):\n", title, n);
88     return (indent+INDENT);
89 }
90
91 int pr_title_nxn(FILE *fp, int indent, const char *title, int n1, int n2)
92 {
93     (void) pr_indent(fp, indent);
94     (void) fprintf(fp, "%s (%dx%d):\n", title, n1, n2);
95     return (indent+INDENT);
96 }
97
98 void pr_ivec(FILE *fp, int indent, const char *title, int vec[], int n, gmx_bool bShowNumbers)
99 {
100     int i;
101
102     if (available(fp, vec, indent, title))
103     {
104         indent = pr_title_n(fp, indent, title, n);
105         for (i = 0; i < n; i++)
106         {
107             (void) pr_indent(fp, indent);
108             (void) fprintf(fp, "%s[%d]=%d\n", title, bShowNumbers ? i : -1, vec[i]);
109         }
110     }
111 }
112
113 void pr_ivec_block(FILE *fp, int indent, const char *title, int vec[], int n, gmx_bool bShowNumbers)
114 {
115     int i, j;
116
117     if (available(fp, vec, indent, title))
118     {
119         indent = pr_title_n(fp, indent, title, n);
120         i      = 0;
121         while (i < n)
122         {
123             j = i+1;
124             while (j < n && vec[j] == vec[j-1]+1)
125             {
126                 j++;
127             }
128             /* Print consecutive groups of 3 or more as blocks */
129             if (j - i < 3)
130             {
131                 while (i < j)
132                 {
133                     (void) pr_indent(fp, indent);
134                     (void) fprintf(fp, "%s[%d]=%d\n",
135                                    title, bShowNumbers ? i : -1, vec[i]);
136                     i++;
137                 }
138             }
139             else
140             {
141                 (void) pr_indent(fp, indent);
142                 (void) fprintf(fp, "%s[%d,...,%d] = {%d,...,%d}\n",
143                                title,
144                                bShowNumbers ? i : -1,
145                                bShowNumbers ? j-1 : -1,
146                                vec[i], vec[j-1]);
147                 i = j;
148             }
149         }
150     }
151 }
152
153 void pr_bvec(FILE *fp, int indent, const char *title, gmx_bool vec[], int n, gmx_bool bShowNumbers)
154 {
155     int i;
156
157     if (available(fp, vec, indent, title))
158     {
159         indent = pr_title_n(fp, indent, title, n);
160         for (i = 0; i < n; i++)
161         {
162             (void) pr_indent(fp, indent);
163             (void) fprintf(fp, "%s[%d]=%s\n", title, bShowNumbers ? i : -1,
164                            EBOOL(vec[i]));
165         }
166     }
167 }
168
169 void pr_ivecs(FILE *fp, int indent, const char *title, ivec vec[], int n, gmx_bool bShowNumbers)
170 {
171     int i, j;
172
173     if (available(fp, vec, indent, title))
174     {
175         indent = pr_title_nxn(fp, indent, title, n, DIM);
176         for (i = 0; i < n; i++)
177         {
178             (void) pr_indent(fp, indent);
179             (void) fprintf(fp, "%s[%d]={", title, bShowNumbers ? i : -1);
180             for (j = 0; j < DIM; j++)
181             {
182                 if (j != 0)
183                 {
184                     (void) fprintf(fp, ", ");
185                 }
186                 fprintf(fp, "%d", vec[i][j]);
187             }
188             (void) fprintf(fp, "}\n");
189         }
190     }
191 }
192
193 void pr_rvec(FILE *fp, int indent, const char *title, real vec[], int n, gmx_bool bShowNumbers)
194 {
195     int i;
196
197     if (available(fp, vec, indent, title))
198     {
199         indent = pr_title_n(fp, indent, title, n);
200         for (i = 0; i < n; i++)
201         {
202             pr_indent(fp, indent);
203             fprintf(fp, "%s[%d]=%12.5e\n", title, bShowNumbers ? i : -1, vec[i]);
204         }
205     }
206 }
207
208 void pr_dvec(FILE *fp, int indent, const char *title, double vec[], int n, gmx_bool bShowNumbers)
209 {
210     int i;
211
212     if (available(fp, vec, indent, title))
213     {
214         indent = pr_title_n(fp, indent, title, n);
215         for (i = 0; i < n; i++)
216         {
217             pr_indent(fp, indent);
218             fprintf(fp, "%s[%d]=%12.5e\n", title, bShowNumbers ? i : -1, vec[i]);
219         }
220     }
221 }
222
223
224 /*
225    void pr_mat(FILE *fp,int indent,char *title,matrix m)
226    {
227    int i,j;
228
229    if (available(fp,m,indent,title)) {
230     indent=pr_title_n(fp,indent,title,n);
231     for(i=0; i<n; i++) {
232       pr_indent(fp,indent);
233       fprintf(fp,"%s[%d]=%12.5e %12.5e %12.5e\n",
234           title,bShowNumbers?i:-1,m[i][XX],m[i][YY],m[i][ZZ]);
235     }
236    }
237    }
238  */
239
240 void pr_rvecs_len(FILE *fp, int indent, const char *title, rvec vec[], int n)
241 {
242     int i, j;
243
244     if (available(fp, vec, indent, title))
245     {
246         indent = pr_title_nxn(fp, indent, title, n, DIM);
247         for (i = 0; i < n; i++)
248         {
249             (void) pr_indent(fp, indent);
250             (void) fprintf(fp, "%s[%5d]={", title, i);
251             for (j = 0; j < DIM; j++)
252             {
253                 if (j != 0)
254                 {
255                     (void) fprintf(fp, ", ");
256                 }
257                 (void) fprintf(fp, "%12.5e", vec[i][j]);
258             }
259             (void) fprintf(fp, "} len=%12.5e\n", norm(vec[i]));
260         }
261     }
262 }
263
264 void pr_rvecs(FILE *fp, int indent, const char *title, rvec vec[], int n)
265 {
266     const char *fshort = "%12.5e";
267     const char *flong  = "%15.8e";
268     const char *format;
269     int         i, j;
270
271     if (getenv("LONGFORMAT") != NULL)
272     {
273         format = flong;
274     }
275     else
276     {
277         format = fshort;
278     }
279
280     if (available(fp, vec, indent, title))
281     {
282         indent = pr_title_nxn(fp, indent, title, n, DIM);
283         for (i = 0; i < n; i++)
284         {
285             (void) pr_indent(fp, indent);
286             (void) fprintf(fp, "%s[%5d]={", title, i);
287             for (j = 0; j < DIM; j++)
288             {
289                 if (j != 0)
290                 {
291                     (void) fprintf(fp, ", ");
292                 }
293                 (void) fprintf(fp, format, vec[i][j]);
294             }
295             (void) fprintf(fp, "}\n");
296         }
297     }
298 }
299
300
301 void pr_rvecs_of_dim(FILE *fp, int indent, const char *title, rvec vec[], int n, int dim)
302 {
303     const char *fshort = "%12.5e";
304     const char *flong  = "%15.8e";
305     const char *format;
306     int         i, j;
307
308     if (getenv("LONGFORMAT") != NULL)
309     {
310         format = flong;
311     }
312     else
313     {
314         format = fshort;
315     }
316
317     if (available(fp, vec, indent, title))
318     {
319         indent = pr_title_nxn(fp, indent, title, n, dim);
320         for (i = 0; i < n; i++)
321         {
322             (void) pr_indent(fp, indent);
323             (void) fprintf(fp, "%s[%5d]={", title, i);
324             for (j = 0; j < dim; j++)
325             {
326                 if (j != 0)
327                 {
328                     (void) fprintf(fp, ", ");
329                 }
330                 (void) fprintf(fp, format, vec[i][j]);
331             }
332             (void) fprintf(fp, "}\n");
333         }
334     }
335 }
336
337 void pr_reals(FILE *fp, int indent, const char *title, real *vec, int n)
338 {
339     int i;
340
341     if (available(fp, vec, indent, title))
342     {
343         (void) pr_indent(fp, indent);
344         (void) fprintf(fp, "%s:\t", title);
345         for (i = 0; i < n; i++)
346         {
347             fprintf(fp, "  %10g", vec[i]);
348         }
349         (void) fprintf(fp, "\n");
350     }
351 }
352
353 void pr_doubles(FILE *fp, int indent, const char *title, double *vec, int n)
354 {
355     int i;
356
357     if (available(fp, vec, indent, title))
358     {
359         (void) pr_indent(fp, indent);
360         (void) fprintf(fp, "%s:\t", title);
361         for (i = 0; i < n; i++)
362         {
363             fprintf(fp, "  %10g", vec[i]);
364         }
365         (void) fprintf(fp, "\n");
366     }
367 }
368
369 void pr_reals_of_dim(FILE *fp, int indent, const char *title, real *vec, int n, int dim)
370 {
371     int         i, j;
372     const char *fshort = "%12.5e";
373     const char *flong  = "%15.8e";
374     const char *format;
375
376     if (getenv("LONGFORMAT") != NULL)
377     {
378         format = flong;
379     }
380     else
381     {
382         format = fshort;
383     }
384
385     if (available(fp, vec, indent, title))
386     {
387         indent = pr_title_nxn(fp, indent, title, n, dim);
388         for (i = 0; i < n; i++)
389         {
390             (void) pr_indent(fp, indent);
391             (void) fprintf(fp, "%s[%5d]={", title, i);
392             for (j = 0; j < dim; j++)
393             {
394                 if (j != 0)
395                 {
396                     (void) fprintf(fp, ", ");
397                 }
398                 (void) fprintf(fp, format, vec[i * dim  + j]);
399             }
400             (void) fprintf(fp, "}\n");
401         }
402     }
403 }
404
405 static void pr_int(FILE *fp, int indent, const char *title, int i)
406 {
407     pr_indent(fp, indent);
408     fprintf(fp, "%-20s = %d\n", title, i);
409 }
410
411 static void pr_int64(FILE *fp, int indent, const char *title, gmx_int64_t i)
412 {
413     char buf[STEPSTRSIZE];
414
415     pr_indent(fp, indent);
416     fprintf(fp, "%-20s = %s\n", title, gmx_step_str(i, buf));
417 }
418
419 static void pr_real(FILE *fp, int indent, const char *title, real r)
420 {
421     pr_indent(fp, indent);
422     fprintf(fp, "%-20s = %g\n", title, r);
423 }
424
425 static void pr_double(FILE *fp, int indent, const char *title, double d)
426 {
427     pr_indent(fp, indent);
428     fprintf(fp, "%-20s = %g\n", title, d);
429 }
430
431 static void pr_str(FILE *fp, int indent, const char *title, const char *s)
432 {
433     pr_indent(fp, indent);
434     fprintf(fp, "%-20s = %s\n", title, s);
435 }
436
437 void pr_qm_opts(FILE *fp, int indent, const char *title, t_grpopts *opts)
438 {
439     int i, m, j;
440
441     fprintf(fp, "%s:\n", title);
442
443     pr_int(fp, indent, "ngQM", opts->ngQM);
444     if (opts->ngQM > 0)
445     {
446         pr_ivec(fp, indent, "QMmethod", opts->QMmethod, opts->ngQM, FALSE);
447         pr_ivec(fp, indent, "QMbasis", opts->QMbasis, opts->ngQM, FALSE);
448         pr_ivec(fp, indent, "QMcharge", opts->QMcharge, opts->ngQM, FALSE);
449         pr_ivec(fp, indent, "QMmult", opts->QMmult, opts->ngQM, FALSE);
450         pr_bvec(fp, indent, "bSH", opts->bSH, opts->ngQM, FALSE);
451         pr_ivec(fp, indent, "CASorbitals", opts->CASorbitals, opts->ngQM, FALSE);
452         pr_ivec(fp, indent, "CASelectrons", opts->CASelectrons, opts->ngQM, FALSE);
453         pr_rvec(fp, indent, "SAon", opts->SAon, opts->ngQM, FALSE);
454         pr_rvec(fp, indent, "SAon", opts->SAon, opts->ngQM, FALSE);
455         pr_ivec(fp, indent, "SAsteps", opts->SAsteps, opts->ngQM, FALSE);
456         pr_bvec(fp, indent, "bOPT", opts->bOPT, opts->ngQM, FALSE);
457         pr_bvec(fp, indent, "bTS", opts->bTS, opts->ngQM, FALSE);
458     }
459 }
460
461 static void pr_grp_opts(FILE *out, int indent, const char *title, t_grpopts *opts,
462                         gmx_bool bMDPformat)
463 {
464     int i, m, j;
465
466     if (!bMDPformat)
467     {
468         fprintf(out, "%s:\n", title);
469     }
470
471     pr_indent(out, indent);
472     fprintf(out, "nrdf%s", bMDPformat ? " = " : ":");
473     for (i = 0; (i < opts->ngtc); i++)
474     {
475         fprintf(out, "  %10g", opts->nrdf[i]);
476     }
477     fprintf(out, "\n");
478
479     pr_indent(out, indent);
480     fprintf(out, "ref-t%s", bMDPformat ? " = " : ":");
481     for (i = 0; (i < opts->ngtc); i++)
482     {
483         fprintf(out, "  %10g", opts->ref_t[i]);
484     }
485     fprintf(out, "\n");
486
487     pr_indent(out, indent);
488     fprintf(out, "tau-t%s", bMDPformat ? " = " : ":");
489     for (i = 0; (i < opts->ngtc); i++)
490     {
491         fprintf(out, "  %10g", opts->tau_t[i]);
492     }
493     fprintf(out, "\n");
494
495     /* Pretty-print the simulated annealing info */
496     fprintf(out, "anneal%s", bMDPformat ? " = " : ":");
497     for (i = 0; (i < opts->ngtc); i++)
498     {
499         fprintf(out, "  %10s", EANNEAL(opts->annealing[i]));
500     }
501     fprintf(out, "\n");
502
503     fprintf(out, "ann-npoints%s", bMDPformat ? " = " : ":");
504     for (i = 0; (i < opts->ngtc); i++)
505     {
506         fprintf(out, "  %10d", opts->anneal_npoints[i]);
507     }
508     fprintf(out, "\n");
509
510     for (i = 0; (i < opts->ngtc); i++)
511     {
512         if (opts->anneal_npoints[i] > 0)
513         {
514             fprintf(out, "ann. times [%d]:\t", i);
515             for (j = 0; (j < opts->anneal_npoints[i]); j++)
516             {
517                 fprintf(out, "  %10.1f", opts->anneal_time[i][j]);
518             }
519             fprintf(out, "\n");
520             fprintf(out, "ann. temps [%d]:\t", i);
521             for (j = 0; (j < opts->anneal_npoints[i]); j++)
522             {
523                 fprintf(out, "  %10.1f", opts->anneal_temp[i][j]);
524             }
525             fprintf(out, "\n");
526         }
527     }
528
529     pr_indent(out, indent);
530     fprintf(out, "acc:\t");
531     for (i = 0; (i < opts->ngacc); i++)
532     {
533         for (m = 0; (m < DIM); m++)
534         {
535             fprintf(out, "  %10g", opts->acc[i][m]);
536         }
537     }
538     fprintf(out, "\n");
539
540     pr_indent(out, indent);
541     fprintf(out, "nfreeze:");
542     for (i = 0; (i < opts->ngfrz); i++)
543     {
544         for (m = 0; (m < DIM); m++)
545         {
546             fprintf(out, "  %10s", opts->nFreeze[i][m] ? "Y" : "N");
547         }
548     }
549     fprintf(out, "\n");
550
551
552     for (i = 0; (i < opts->ngener); i++)
553     {
554         pr_indent(out, indent);
555         fprintf(out, "energygrp-flags[%3d]:", i);
556         for (m = 0; (m < opts->ngener); m++)
557         {
558             fprintf(out, " %d", opts->egp_flags[opts->ngener*i+m]);
559         }
560         fprintf(out, "\n");
561     }
562
563     fflush(out);
564 }
565
566 static void pr_matrix(FILE *fp, int indent, const char *title, rvec *m,
567                       gmx_bool bMDPformat)
568 {
569     if (bMDPformat)
570     {
571         fprintf(fp, "%-10s    = %g %g %g %g %g %g\n", title,
572                 m[XX][XX], m[YY][YY], m[ZZ][ZZ], m[XX][YY], m[XX][ZZ], m[YY][ZZ]);
573     }
574     else
575     {
576         pr_rvecs(fp, indent, title, m, DIM);
577     }
578 }
579
580 static void pr_cosine(FILE *fp, int indent, const char *title, t_cosines *cos,
581                       gmx_bool bMDPformat)
582 {
583     int j;
584
585     if (bMDPformat)
586     {
587         fprintf(fp, "%s = %d\n", title, cos->n);
588     }
589     else
590     {
591         indent = pr_title(fp, indent, title);
592         (void) pr_indent(fp, indent);
593         fprintf(fp, "n = %d\n", cos->n);
594         if (cos->n > 0)
595         {
596             (void) pr_indent(fp, indent+2);
597             fprintf(fp, "a =");
598             for (j = 0; (j < cos->n); j++)
599             {
600                 fprintf(fp, " %e", cos->a[j]);
601             }
602             fprintf(fp, "\n");
603             (void) pr_indent(fp, indent+2);
604             fprintf(fp, "phi =");
605             for (j = 0; (j < cos->n); j++)
606             {
607                 fprintf(fp, " %e", cos->phi[j]);
608             }
609             fprintf(fp, "\n");
610         }
611     }
612 }
613
614 #define PS(t, s) pr_str(fp, indent, t, s)
615 #define PI(t, s) pr_int(fp, indent, t, s)
616 #define PSTEP(t, s) pr_int64(fp, indent, t, s)
617 #define PR(t, s) pr_real(fp, indent, t, s)
618 #define PD(t, s) pr_double(fp, indent, t, s)
619
620 static void pr_pull_group(FILE *fp, int indent, int g, t_pull_group *pgrp)
621 {
622     pr_indent(fp, indent);
623     fprintf(fp, "pull-group %d:\n", g);
624     indent += 2;
625     pr_ivec_block(fp, indent, "atom", pgrp->ind, pgrp->nat, TRUE);
626     pr_rvec(fp, indent, "weight", pgrp->weight, pgrp->nweight, TRUE);
627     PI("pbcatom", pgrp->pbcatom);
628 }
629
630 static void pr_pull_coord(FILE *fp, int indent, int c, t_pull_coord *pcrd)
631 {
632     pr_indent(fp, indent);
633     fprintf(fp, "pull-coord %d:\n", c);
634     PI("group[0]", pcrd->group[0]);
635     PI("group[1]", pcrd->group[1]);
636     pr_rvec(fp, indent, "origin", pcrd->origin, DIM, TRUE);
637     pr_rvec(fp, indent, "vec", pcrd->vec, DIM, TRUE);
638     PR("init", pcrd->init);
639     PR("rate", pcrd->rate);
640     PR("k", pcrd->k);
641     PR("kB", pcrd->kB);
642 }
643
644 static void pr_simtempvals(FILE *fp, int indent, t_simtemp *simtemp, int n_lambda)
645 {
646     PR("simtemp_low", simtemp->simtemp_low);
647     PR("simtemp_high", simtemp->simtemp_high);
648     PS("simulated-tempering-scaling", ESIMTEMP(simtemp->eSimTempScale));
649     pr_rvec(fp, indent, "simulated tempering temperatures", simtemp->temperatures, n_lambda, TRUE);
650 }
651
652 static void pr_expandedvals(FILE *fp, int indent, t_expanded *expand, int n_lambda)
653 {
654
655     PI("nstexpanded", expand->nstexpanded);
656     PS("lambda-stats", elamstats_names[expand->elamstats]);
657     PS("lambda-mc-move", elmcmove_names[expand->elmcmove]);
658     PI("lmc-repeats", expand->lmc_repeats);
659     PI("lmc-gibbsdelta", expand->gibbsdeltalam);
660     PI("lmc-nstart", expand->lmc_forced_nstart);
661     PS("symmetrized-transition-matrix", EBOOL(expand->bSymmetrizedTMatrix));
662     PI("nst-transition-matrix", expand->nstTij);
663     PI("mininum-var-min", expand->minvarmin); /*default is reasonable */
664     PI("weight-c-range", expand->c_range);    /* default is just C=0 */
665     PR("wl-scale", expand->wl_scale);
666     PR("init-wl-delta", expand->init_wl_delta);
667     PR("wl-ratio", expand->wl_ratio);
668     PS("bWLoneovert", EBOOL(expand->bWLoneovert));
669     PI("lmc-seed", expand->lmc_seed);
670     PR("mc-temperature", expand->mc_temp);
671     PS("lmc-weights-equil", elmceq_names[expand->elmceq]);
672     if (expand->elmceq == elmceqNUMATLAM)
673     {
674         PI("weight-equil-number-all-lambda", expand->equil_n_at_lam);
675     }
676     if (expand->elmceq == elmceqSAMPLES)
677     {
678         PI("weight-equil-number-samples", expand->equil_samples);
679     }
680     if (expand->elmceq == elmceqSTEPS)
681     {
682         PI("weight-equil-number-steps", expand->equil_steps);
683     }
684     if (expand->elmceq == elmceqWLDELTA)
685     {
686         PR("weight-equil-wl-delta", expand->equil_wl_delta);
687     }
688     if (expand->elmceq == elmceqRATIO)
689     {
690         PR("weight-equil-count-ratio", expand->equil_ratio);
691     }
692
693     pr_indent(fp, indent);
694     pr_rvec(fp, indent, "init-lambda-weights", expand->init_lambda_weights, n_lambda, TRUE);
695     PS("init-weights", EBOOL(expand->bInit_weights));
696 }
697
698 static void pr_fepvals(FILE *fp, int indent, t_lambda *fep, gmx_bool bMDPformat)
699 {
700     int i, j;
701
702     PI("nstdhdl", fep->nstdhdl);
703     PI("init-lambda-state", fep->init_fep_state);
704     PR("init-lambda", fep->init_lambda);
705     PR("delta-lambda", fep->delta_lambda);
706     if (!bMDPformat)
707     {
708         PI("n-lambdas", fep->n_lambda);
709     }
710     if (fep->n_lambda > 0)
711     {
712         pr_indent(fp, indent);
713         fprintf(fp, "separate-dvdl%s\n", bMDPformat ? " = " : ":");
714         for (i = 0; i < efptNR; i++)
715         {
716             fprintf(fp, "%18s = ", efpt_names[i]);
717             if (fep->separate_dvdl[i])
718             {
719                 fprintf(fp, "  TRUE");
720             }
721             else
722             {
723                 fprintf(fp, "  FALSE");
724             }
725             fprintf(fp, "\n");
726         }
727         fprintf(fp, "all-lambdas%s\n", bMDPformat ? " = " : ":");
728         for (i = 0; i < efptNR; i++)
729         {
730             fprintf(fp, "%18s = ", efpt_names[i]);
731             for (j = 0; j < fep->n_lambda; j++)
732             {
733                 fprintf(fp, "  %10g", fep->all_lambda[i][j]);
734             }
735             fprintf(fp, "\n");
736         }
737     }
738     PI("calc-lambda-neighbors", fep->lambda_neighbors);
739
740     PR("sc-alpha", fep->sc_alpha);
741     PS("bScCoul", EBOOL(fep->bScCoul));
742     PS("bScPrintEnergy", EBOOL(fep->bPrintEnergy));
743     PI("sc-power", fep->sc_power);
744     PR("sc-r-power", fep->sc_r_power);
745     PR("sc-sigma", fep->sc_sigma);
746     PR("sc-sigma-min", fep->sc_sigma_min);
747     PS("separate-dhdl-file", SEPDHDLFILETYPE(fep->separate_dhdl_file));
748     PS("dhdl-derivatives", DHDLDERIVATIVESTYPE(fep->dhdl_derivatives));
749     PI("dh-hist-size", fep->dh_hist_size);
750     PD("dh-hist-spacing", fep->dh_hist_spacing);
751 };
752
753 static void pr_pull(FILE *fp, int indent, t_pull *pull)
754 {
755     int g;
756
757     PS("pull-geometry", EPULLGEOM(pull->eGeom));
758     pr_ivec(fp, indent, "pull-dim", pull->dim, DIM, TRUE);
759     PR("pull-r1", pull->cyl_r1);
760     PR("pull-r0", pull->cyl_r0);
761     PR("pull-constr-tol", pull->constr_tol);
762     PS("pull-bPrintRef", EBOOL(pull->bPrintRef));
763     PI("pull-nstxout", pull->nstxout);
764     PI("pull-nstfout", pull->nstfout);
765     PI("pull-ngroup", pull->ngroup);
766     for (g = 0; g < pull->ngroup; g++)
767     {
768         pr_pull_group(fp, indent, g, &pull->group[g]);
769     }
770     PI("pull-ncoord", pull->ncoord);
771     for (g = 0; g < pull->ncoord; g++)
772     {
773         pr_pull_coord(fp, indent, g, &pull->coord[g]);
774     }
775 }
776
777 static void pr_rotgrp(FILE *fp, int indent, int g, t_rotgrp *rotg)
778 {
779     pr_indent(fp, indent);
780     fprintf(fp, "rotation_group %d:\n", g);
781     indent += 2;
782     PS("type", EROTGEOM(rotg->eType));
783     PS("massw", EBOOL(rotg->bMassW));
784     pr_ivec_block(fp, indent, "atom", rotg->ind, rotg->nat, TRUE);
785     pr_rvecs(fp, indent, "x_ref", rotg->x_ref, rotg->nat);
786     pr_rvec(fp, indent, "vec", rotg->vec, DIM, TRUE);
787     pr_rvec(fp, indent, "pivot", rotg->pivot, DIM, TRUE);
788     PR("rate", rotg->rate);
789     PR("k", rotg->k);
790     PR("slab_dist", rotg->slab_dist);
791     PR("min_gaussian", rotg->min_gaussian);
792     PR("epsilon", rotg->eps);
793     PS("fit_method", EROTFIT(rotg->eFittype));
794     PI("potfitangle_nstep", rotg->PotAngle_nstep);
795     PR("potfitangle_step", rotg->PotAngle_step);
796 }
797
798 static void pr_rot(FILE *fp, int indent, t_rot *rot)
799 {
800     int g;
801
802     PI("rot_nstrout", rot->nstrout);
803     PI("rot_nstsout", rot->nstsout);
804     PI("rot_ngrp", rot->ngrp);
805     for (g = 0; g < rot->ngrp; g++)
806     {
807         pr_rotgrp(fp, indent, g, &rot->grp[g]);
808     }
809 }
810
811 void pr_inputrec(FILE *fp, int indent, const char *title, t_inputrec *ir,
812                  gmx_bool bMDPformat)
813 {
814     const char *infbuf = "inf";
815     int         i;
816
817     if (available(fp, ir, indent, title))
818     {
819         if (!bMDPformat)
820         {
821             indent = pr_title(fp, indent, title);
822         }
823         PS("integrator", EI(ir->eI));
824         PSTEP("nsteps", ir->nsteps);
825         PSTEP("init-step", ir->init_step);
826         PS("cutoff-scheme", ECUTSCHEME(ir->cutoff_scheme));
827         PS("ns_type", ENS(ir->ns_type));
828         PI("nstlist", ir->nstlist);
829         PI("ndelta", ir->ndelta);
830         PI("nstcomm", ir->nstcomm);
831         PS("comm-mode", ECOM(ir->comm_mode));
832         PI("nstlog", ir->nstlog);
833         PI("nstxout", ir->nstxout);
834         PI("nstvout", ir->nstvout);
835         PI("nstfout", ir->nstfout);
836         PI("nstcalcenergy", ir->nstcalcenergy);
837         PI("nstenergy", ir->nstenergy);
838         PI("nstxout_compressed", ir->nstxout_compressed);
839         PR("init-t", ir->init_t);
840         PR("delta-t", ir->delta_t);
841
842         PR("x_compression_precision", ir->x_compression_precision);
843         PR("fourierspacing", ir->fourier_spacing);
844         PI("nkx", ir->nkx);
845         PI("nky", ir->nky);
846         PI("nkz", ir->nkz);
847         PI("pme-order", ir->pme_order);
848         PR("ewald-rtol", ir->ewald_rtol);
849         PR("ewald-rtol-lj", ir->ewald_rtol_lj);
850         PR("ewald-geometry", ir->ewald_geometry);
851         PR("epsilon-surface", ir->epsilon_surface);
852         PS("optimize-fft", EBOOL(ir->bOptFFT));
853         PS("lj-pme-comb-rule", ELJPMECOMBNAMES(ir->ljpme_combination_rule));
854         PS("ePBC", EPBC(ir->ePBC));
855         PS("bPeriodicMols", EBOOL(ir->bPeriodicMols));
856         PS("bContinuation", EBOOL(ir->bContinuation));
857         PS("bShakeSOR", EBOOL(ir->bShakeSOR));
858         PS("etc", ETCOUPLTYPE(ir->etc));
859         PS("bPrintNHChains", EBOOL(ir->bPrintNHChains));
860         PI("nsttcouple", ir->nsttcouple);
861         PS("epc", EPCOUPLTYPE(ir->epc));
862         PS("epctype", EPCOUPLTYPETYPE(ir->epct));
863         PI("nstpcouple", ir->nstpcouple);
864         PR("tau-p", ir->tau_p);
865         pr_matrix(fp, indent, "ref-p", ir->ref_p, bMDPformat);
866         pr_matrix(fp, indent, "compress", ir->compress, bMDPformat);
867         PS("refcoord-scaling", EREFSCALINGTYPE(ir->refcoord_scaling));
868         if (bMDPformat)
869         {
870             fprintf(fp, "posres-com  = %g %g %g\n", ir->posres_com[XX],
871                     ir->posres_com[YY], ir->posres_com[ZZ]);
872         }
873         else
874         {
875             pr_rvec(fp, indent, "posres-com", ir->posres_com, DIM, TRUE);
876         }
877         if (bMDPformat)
878         {
879             fprintf(fp, "posres-comB = %g %g %g\n", ir->posres_comB[XX],
880                     ir->posres_comB[YY], ir->posres_comB[ZZ]);
881         }
882         else
883         {
884             pr_rvec(fp, indent, "posres-comB", ir->posres_comB, DIM, TRUE);
885         }
886         PR("verlet-buffer-tolerance", ir->verletbuf_tol);
887         PR("rlist", ir->rlist);
888         PR("rlistlong", ir->rlistlong);
889         PR("nstcalclr", ir->nstcalclr);
890         PR("rtpi", ir->rtpi);
891         PS("coulombtype", EELTYPE(ir->coulombtype));
892         PS("coulomb-modifier", INTMODIFIER(ir->coulomb_modifier));
893         PR("rcoulomb-switch", ir->rcoulomb_switch);
894         PR("rcoulomb", ir->rcoulomb);
895         PS("vdwtype", EVDWTYPE(ir->vdwtype));
896         PS("vdw-modifier", INTMODIFIER(ir->vdw_modifier));
897         PR("rvdw-switch", ir->rvdw_switch);
898         PR("rvdw", ir->rvdw);
899         if (ir->epsilon_r != 0)
900         {
901             PR("epsilon-r", ir->epsilon_r);
902         }
903         else
904         {
905             PS("epsilon-r", infbuf);
906         }
907         if (ir->epsilon_rf != 0)
908         {
909             PR("epsilon-rf", ir->epsilon_rf);
910         }
911         else
912         {
913             PS("epsilon-rf", infbuf);
914         }
915         PR("tabext", ir->tabext);
916         PS("implicit-solvent", EIMPLICITSOL(ir->implicit_solvent));
917         PS("gb-algorithm", EGBALGORITHM(ir->gb_algorithm));
918         PR("gb-epsilon-solvent", ir->gb_epsilon_solvent);
919         PI("nstgbradii", ir->nstgbradii);
920         PR("rgbradii", ir->rgbradii);
921         PR("gb-saltconc", ir->gb_saltconc);
922         PR("gb-obc-alpha", ir->gb_obc_alpha);
923         PR("gb-obc-beta", ir->gb_obc_beta);
924         PR("gb-obc-gamma", ir->gb_obc_gamma);
925         PR("gb-dielectric-offset", ir->gb_dielectric_offset);
926         PS("sa-algorithm", ESAALGORITHM(ir->gb_algorithm));
927         PR("sa-surface-tension", ir->sa_surface_tension);
928         PS("DispCorr", EDISPCORR(ir->eDispCorr));
929         PS("bSimTemp", EBOOL(ir->bSimTemp));
930         if (ir->bSimTemp)
931         {
932             pr_simtempvals(fp, indent, ir->simtempvals, ir->fepvals->n_lambda);
933         }
934         PS("free-energy", EFEPTYPE(ir->efep));
935         if (ir->efep != efepNO || ir->bSimTemp)
936         {
937             pr_fepvals(fp, indent, ir->fepvals, bMDPformat);
938         }
939         if (ir->bExpanded)
940         {
941             pr_expandedvals(fp, indent, ir->expandedvals, ir->fepvals->n_lambda);
942         }
943
944         PI("nwall", ir->nwall);
945         PS("wall-type", EWALLTYPE(ir->wall_type));
946         PI("wall-atomtype[0]", ir->wall_atomtype[0]);
947         PI("wall-atomtype[1]", ir->wall_atomtype[1]);
948         PR("wall-density[0]", ir->wall_density[0]);
949         PR("wall-density[1]", ir->wall_density[1]);
950         PR("wall-ewald-zfac", ir->wall_ewald_zfac);
951
952         PS("pull", EPULLTYPE(ir->ePull));
953         if (ir->ePull != epullNO)
954         {
955             pr_pull(fp, indent, ir->pull);
956         }
957
958         PS("rotation", EBOOL(ir->bRot));
959         if (ir->bRot)
960         {
961             pr_rot(fp, indent, ir->rot);
962         }
963
964         PS("disre", EDISRETYPE(ir->eDisre));
965         PS("disre-weighting", EDISREWEIGHTING(ir->eDisreWeighting));
966         PS("disre-mixed", EBOOL(ir->bDisreMixed));
967         PR("dr-fc", ir->dr_fc);
968         PR("dr-tau", ir->dr_tau);
969         PR("nstdisreout", ir->nstdisreout);
970         PR("orires-fc", ir->orires_fc);
971         PR("orires-tau", ir->orires_tau);
972         PR("nstorireout", ir->nstorireout);
973
974         PR("dihre-fc", ir->dihre_fc);
975
976         PR("em-stepsize", ir->em_stepsize);
977         PR("em-tol", ir->em_tol);
978         PI("niter", ir->niter);
979         PR("fc-stepsize", ir->fc_stepsize);
980         PI("nstcgsteep", ir->nstcgsteep);
981         PI("nbfgscorr", ir->nbfgscorr);
982
983         PS("ConstAlg", ECONSTRTYPE(ir->eConstrAlg));
984         PR("shake-tol", ir->shake_tol);
985         PI("lincs-order", ir->nProjOrder);
986         PR("lincs-warnangle", ir->LincsWarnAngle);
987         PI("lincs-iter", ir->nLincsIter);
988         PR("bd-fric", ir->bd_fric);
989         PI("ld-seed", ir->ld_seed);
990         PR("cos-accel", ir->cos_accel);
991         pr_matrix(fp, indent, "deform", ir->deform, bMDPformat);
992
993         PS("adress", EBOOL(ir->bAdress));
994         if (ir->bAdress)
995         {
996             PS("adress_type", EADRESSTYPE(ir->adress->type));
997             PR("adress_const_wf", ir->adress->const_wf);
998             PR("adress_ex_width", ir->adress->ex_width);
999             PR("adress_hy_width", ir->adress->hy_width);
1000             PS("adress_interface_correction", EADRESSICTYPE(ir->adress->icor));
1001             PS("adress_site", EADRESSSITETYPE(ir->adress->site));
1002             PR("adress_ex_force_cap", ir->adress->ex_forcecap);
1003             PS("adress_do_hybridpairs", EBOOL(ir->adress->do_hybridpairs));
1004
1005             pr_rvec(fp, indent, "adress_reference_coords", ir->adress->refs, DIM, TRUE);
1006         }
1007         PI("userint1", ir->userint1);
1008         PI("userint2", ir->userint2);
1009         PI("userint3", ir->userint3);
1010         PI("userint4", ir->userint4);
1011         PR("userreal1", ir->userreal1);
1012         PR("userreal2", ir->userreal2);
1013         PR("userreal3", ir->userreal3);
1014         PR("userreal4", ir->userreal4);
1015         pr_grp_opts(fp, indent, "grpopts", &(ir->opts), bMDPformat);
1016         pr_cosine(fp, indent, "efield-x", &(ir->ex[XX]), bMDPformat);
1017         pr_cosine(fp, indent, "efield-xt", &(ir->et[XX]), bMDPformat);
1018         pr_cosine(fp, indent, "efield-y", &(ir->ex[YY]), bMDPformat);
1019         pr_cosine(fp, indent, "efield-yt", &(ir->et[YY]), bMDPformat);
1020         pr_cosine(fp, indent, "efield-z", &(ir->ex[ZZ]), bMDPformat);
1021         pr_cosine(fp, indent, "efield-zt", &(ir->et[ZZ]), bMDPformat);
1022         PS("bQMMM", EBOOL(ir->bQMMM));
1023         PI("QMconstraints", ir->QMconstraints);
1024         PI("QMMMscheme", ir->QMMMscheme);
1025         PR("scalefactor", ir->scalefactor);
1026         pr_qm_opts(fp, indent, "qm-opts", &(ir->opts));
1027     }
1028 }
1029 #undef PS
1030 #undef PR
1031 #undef PI
1032
1033 static void pr_harm(FILE *fp, t_iparams *iparams, const char *r, const char *kr)
1034 {
1035     fprintf(fp, "%sA=%12.5e, %sA=%12.5e, %sB=%12.5e, %sB=%12.5e\n",
1036             r, iparams->harmonic.rA, kr, iparams->harmonic.krA,
1037             r, iparams->harmonic.rB, kr, iparams->harmonic.krB);
1038 }
1039
1040 void pr_iparams(FILE *fp, t_functype ftype, t_iparams *iparams)
1041 {
1042     int  i;
1043     real VA[4], VB[4], *rbcA, *rbcB;
1044
1045     switch (ftype)
1046     {
1047         case F_ANGLES:
1048         case F_G96ANGLES:
1049             pr_harm(fp, iparams, "th", "ct");
1050             break;
1051         case F_CROSS_BOND_BONDS:
1052             fprintf(fp, "r1e=%15.8e, r2e=%15.8e, krr=%15.8e\n",
1053                     iparams->cross_bb.r1e, iparams->cross_bb.r2e,
1054                     iparams->cross_bb.krr);
1055             break;
1056         case F_CROSS_BOND_ANGLES:
1057             fprintf(fp, "r1e=%15.8e, r1e=%15.8e, r3e=%15.8e, krt=%15.8e\n",
1058                     iparams->cross_ba.r1e, iparams->cross_ba.r2e,
1059                     iparams->cross_ba.r3e, iparams->cross_ba.krt);
1060             break;
1061         case F_LINEAR_ANGLES:
1062             fprintf(fp, "klinA=%15.8e, aA=%15.8e, klinB=%15.8e, aB=%15.8e\n",
1063                     iparams->linangle.klinA, iparams->linangle.aA,
1064                     iparams->linangle.klinB, iparams->linangle.aB);
1065             break;
1066         case F_UREY_BRADLEY:
1067             fprintf(fp, "thetaA=%15.8e, kthetaA=%15.8e, r13A=%15.8e, kUBA=%15.8e, thetaB=%15.8e, kthetaB=%15.8e, r13B=%15.8e, kUBB=%15.8e\n", iparams->u_b.thetaA, iparams->u_b.kthetaA, iparams->u_b.r13A, iparams->u_b.kUBA, iparams->u_b.thetaB, iparams->u_b.kthetaB, iparams->u_b.r13B, iparams->u_b.kUBB);
1068             break;
1069         case F_QUARTIC_ANGLES:
1070             fprintf(fp, "theta=%15.8e", iparams->qangle.theta);
1071             for (i = 0; i < 5; i++)
1072             {
1073                 fprintf(fp, ", c%c=%15.8e", '0'+i, iparams->qangle.c[i]);
1074             }
1075             fprintf(fp, "\n");
1076             break;
1077         case F_BHAM:
1078             fprintf(fp, "a=%15.8e, b=%15.8e, c=%15.8e\n",
1079                     iparams->bham.a, iparams->bham.b, iparams->bham.c);
1080             break;
1081         case F_BONDS:
1082         case F_G96BONDS:
1083         case F_HARMONIC:
1084             pr_harm(fp, iparams, "b0", "cb");
1085             break;
1086         case F_IDIHS:
1087             pr_harm(fp, iparams, "xi", "cx");
1088             break;
1089         case F_MORSE:
1090             fprintf(fp, "b0A=%15.8e, cbA=%15.8e, betaA=%15.8e, b0B=%15.8e, cbB=%15.8e, betaB=%15.8e\n",
1091                     iparams->morse.b0A, iparams->morse.cbA, iparams->morse.betaA,
1092                     iparams->morse.b0B, iparams->morse.cbB, iparams->morse.betaB);
1093             break;
1094         case F_CUBICBONDS:
1095             fprintf(fp, "b0=%15.8e, kb=%15.8e, kcub=%15.8e\n",
1096                     iparams->cubic.b0, iparams->cubic.kb, iparams->cubic.kcub);
1097             break;
1098         case F_CONNBONDS:
1099             fprintf(fp, "\n");
1100             break;
1101         case F_FENEBONDS:
1102             fprintf(fp, "bm=%15.8e, kb=%15.8e\n", iparams->fene.bm, iparams->fene.kb);
1103             break;
1104         case F_RESTRBONDS:
1105             fprintf(fp, "lowA=%15.8e, up1A=%15.8e, up2A=%15.8e, kA=%15.8e, lowB=%15.8e, up1B=%15.8e, up2B=%15.8e, kB=%15.8e,\n",
1106                     iparams->restraint.lowA, iparams->restraint.up1A,
1107                     iparams->restraint.up2A, iparams->restraint.kA,
1108                     iparams->restraint.lowB, iparams->restraint.up1B,
1109                     iparams->restraint.up2B, iparams->restraint.kB);
1110             break;
1111         case F_TABBONDS:
1112         case F_TABBONDSNC:
1113         case F_TABANGLES:
1114         case F_TABDIHS:
1115             fprintf(fp, "tab=%d, kA=%15.8e, kB=%15.8e\n",
1116                     iparams->tab.table, iparams->tab.kA, iparams->tab.kB);
1117             break;
1118         case F_POLARIZATION:
1119             fprintf(fp, "alpha=%15.8e\n", iparams->polarize.alpha);
1120             break;
1121         case F_ANHARM_POL:
1122             fprintf(fp, "alpha=%15.8e drcut=%15.8e khyp=%15.8e\n",
1123                     iparams->anharm_polarize.alpha,
1124                     iparams->anharm_polarize.drcut,
1125                     iparams->anharm_polarize.khyp);
1126             break;
1127         case F_THOLE_POL:
1128             fprintf(fp, "a=%15.8e, alpha1=%15.8e, alpha2=%15.8e, rfac=%15.8e\n",
1129                     iparams->thole.a, iparams->thole.alpha1, iparams->thole.alpha2,
1130                     iparams->thole.rfac);
1131             break;
1132         case F_WATER_POL:
1133             fprintf(fp, "al_x=%15.8e, al_y=%15.8e, al_z=%15.8e, rOH=%9.6f, rHH=%9.6f, rOD=%9.6f\n",
1134                     iparams->wpol.al_x, iparams->wpol.al_y, iparams->wpol.al_z,
1135                     iparams->wpol.rOH, iparams->wpol.rHH, iparams->wpol.rOD);
1136             break;
1137         case F_LJ:
1138             fprintf(fp, "c6=%15.8e, c12=%15.8e\n", iparams->lj.c6, iparams->lj.c12);
1139             break;
1140         case F_LJ14:
1141             fprintf(fp, "c6A=%15.8e, c12A=%15.8e, c6B=%15.8e, c12B=%15.8e\n",
1142                     iparams->lj14.c6A, iparams->lj14.c12A,
1143                     iparams->lj14.c6B, iparams->lj14.c12B);
1144             break;
1145         case F_LJC14_Q:
1146             fprintf(fp, "fqq=%15.8e, qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n",
1147                     iparams->ljc14.fqq,
1148                     iparams->ljc14.qi, iparams->ljc14.qj,
1149                     iparams->ljc14.c6, iparams->ljc14.c12);
1150             break;
1151         case F_LJC_PAIRS_NB:
1152             fprintf(fp, "qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n",
1153                     iparams->ljcnb.qi, iparams->ljcnb.qj,
1154                     iparams->ljcnb.c6, iparams->ljcnb.c12);
1155             break;
1156         case F_PDIHS:
1157         case F_PIDIHS:
1158         case F_ANGRES:
1159         case F_ANGRESZ:
1160             fprintf(fp, "phiA=%15.8e, cpA=%15.8e, phiB=%15.8e, cpB=%15.8e, mult=%d\n",
1161                     iparams->pdihs.phiA, iparams->pdihs.cpA,
1162                     iparams->pdihs.phiB, iparams->pdihs.cpB,
1163                     iparams->pdihs.mult);
1164             break;
1165         case F_DISRES:
1166             fprintf(fp, "label=%4d, type=%1d, low=%15.8e, up1=%15.8e, up2=%15.8e, fac=%15.8e)\n",
1167                     iparams->disres.label, iparams->disres.type,
1168                     iparams->disres.low, iparams->disres.up1,
1169                     iparams->disres.up2, iparams->disres.kfac);
1170             break;
1171         case F_ORIRES:
1172             fprintf(fp, "ex=%4d, label=%d, power=%4d, c=%15.8e, obs=%15.8e, kfac=%15.8e)\n",
1173                     iparams->orires.ex, iparams->orires.label, iparams->orires.power,
1174                     iparams->orires.c, iparams->orires.obs, iparams->orires.kfac);
1175             break;
1176         case F_DIHRES:
1177             fprintf(fp, "phiA=%15.8e, dphiA=%15.8e, kfacA=%15.8e, phiB=%15.8e, dphiB=%15.8e, kfacB=%15.8e\n",
1178                     iparams->dihres.phiA, iparams->dihres.dphiA, iparams->dihres.kfacA,
1179                     iparams->dihres.phiB, iparams->dihres.dphiB, iparams->dihres.kfacB);
1180             break;
1181         case F_POSRES:
1182             fprintf(fp, "pos0A=(%15.8e,%15.8e,%15.8e), fcA=(%15.8e,%15.8e,%15.8e), pos0B=(%15.8e,%15.8e,%15.8e), fcB=(%15.8e,%15.8e,%15.8e)\n",
1183                     iparams->posres.pos0A[XX], iparams->posres.pos0A[YY],
1184                     iparams->posres.pos0A[ZZ], iparams->posres.fcA[XX],
1185                     iparams->posres.fcA[YY], iparams->posres.fcA[ZZ],
1186                     iparams->posres.pos0B[XX], iparams->posres.pos0B[YY],
1187                     iparams->posres.pos0B[ZZ], iparams->posres.fcB[XX],
1188                     iparams->posres.fcB[YY], iparams->posres.fcB[ZZ]);
1189             break;
1190         case F_FBPOSRES:
1191             fprintf(fp, "pos0=(%15.8e,%15.8e,%15.8e), geometry=%d, r=%15.8e, k=%15.8e\n",
1192                     iparams->fbposres.pos0[XX], iparams->fbposres.pos0[YY],
1193                     iparams->fbposres.pos0[ZZ], iparams->fbposres.geom,
1194                     iparams->fbposres.r,        iparams->fbposres.k);
1195             break;
1196         case F_RBDIHS:
1197             for (i = 0; i < NR_RBDIHS; i++)
1198             {
1199                 fprintf(fp, "%srbcA[%d]=%15.8e", i == 0 ? "" : ", ", i, iparams->rbdihs.rbcA[i]);
1200             }
1201             fprintf(fp, "\n");
1202             for (i = 0; i < NR_RBDIHS; i++)
1203             {
1204                 fprintf(fp, "%srbcB[%d]=%15.8e", i == 0 ? "" : ", ", i, iparams->rbdihs.rbcB[i]);
1205             }
1206             fprintf(fp, "\n");
1207             break;
1208         case F_FOURDIHS:
1209             /* Use the OPLS -> Ryckaert-Bellemans formula backwards to get the
1210              * OPLS potential constants back.
1211              */
1212             rbcA = iparams->rbdihs.rbcA;
1213             rbcB = iparams->rbdihs.rbcB;
1214
1215             VA[3] = -0.25*rbcA[4];
1216             VA[2] = -0.5*rbcA[3];
1217             VA[1] = 4.0*VA[3]-rbcA[2];
1218             VA[0] = 3.0*VA[2]-2.0*rbcA[1];
1219
1220             VB[3] = -0.25*rbcB[4];
1221             VB[2] = -0.5*rbcB[3];
1222             VB[1] = 4.0*VB[3]-rbcB[2];
1223             VB[0] = 3.0*VB[2]-2.0*rbcB[1];
1224
1225             for (i = 0; i < NR_FOURDIHS; i++)
1226             {
1227                 fprintf(fp, "%sFourA[%d]=%15.8e", i == 0 ? "" : ", ", i, VA[i]);
1228             }
1229             fprintf(fp, "\n");
1230             for (i = 0; i < NR_FOURDIHS; i++)
1231             {
1232                 fprintf(fp, "%sFourB[%d]=%15.8e", i == 0 ? "" : ", ", i, VB[i]);
1233             }
1234             fprintf(fp, "\n");
1235             break;
1236
1237         case F_CONSTR:
1238         case F_CONSTRNC:
1239             fprintf(fp, "dA=%15.8e, dB=%15.8e\n", iparams->constr.dA, iparams->constr.dB);
1240             break;
1241         case F_SETTLE:
1242             fprintf(fp, "doh=%15.8e, dhh=%15.8e\n", iparams->settle.doh,
1243                     iparams->settle.dhh);
1244             break;
1245         case F_VSITE2:
1246             fprintf(fp, "a=%15.8e\n", iparams->vsite.a);
1247             break;
1248         case F_VSITE3:
1249         case F_VSITE3FD:
1250         case F_VSITE3FAD:
1251             fprintf(fp, "a=%15.8e, b=%15.8e\n", iparams->vsite.a, iparams->vsite.b);
1252             break;
1253         case F_VSITE3OUT:
1254         case F_VSITE4FD:
1255         case F_VSITE4FDN:
1256             fprintf(fp, "a=%15.8e, b=%15.8e, c=%15.8e\n",
1257                     iparams->vsite.a, iparams->vsite.b, iparams->vsite.c);
1258             break;
1259         case F_VSITEN:
1260             fprintf(fp, "n=%2d, a=%15.8e\n", iparams->vsiten.n, iparams->vsiten.a);
1261             break;
1262         case F_GB12:
1263         case F_GB13:
1264         case F_GB14:
1265             fprintf(fp, "sar=%15.8e, st=%15.8e, pi=%15.8e, gbr=%15.8e, bmlt=%15.8e\n", iparams->gb.sar, iparams->gb.st, iparams->gb.pi, iparams->gb.gbr, iparams->gb.bmlt);
1266             break;
1267         case F_CMAP:
1268             fprintf(fp, "cmapA=%1d, cmapB=%1d\n", iparams->cmap.cmapA, iparams->cmap.cmapB);
1269             break;
1270         default:
1271             gmx_fatal(FARGS, "unknown function type %d (%s) in %s line %d",
1272                       ftype, interaction_function[ftype].name, __FILE__, __LINE__);
1273     }
1274 }
1275
1276 void pr_ilist(FILE *fp, int indent, const char *title,
1277               t_functype *functype, t_ilist *ilist, gmx_bool bShowNumbers)
1278 {
1279     int      i, j, k, type, ftype;
1280     t_iatom *iatoms;
1281
1282     if (available(fp, ilist, indent, title) && ilist->nr > 0)
1283     {
1284         indent = pr_title(fp, indent, title);
1285         (void) pr_indent(fp, indent);
1286         fprintf(fp, "nr: %d\n", ilist->nr);
1287         if (ilist->nr > 0)
1288         {
1289             (void) pr_indent(fp, indent);
1290             fprintf(fp, "iatoms:\n");
1291             iatoms = ilist->iatoms;
1292             for (i = j = 0; i < ilist->nr; )
1293             {
1294 #ifndef DEBUG
1295                 (void) pr_indent(fp, indent+INDENT);
1296                 type  = *(iatoms++);
1297                 ftype = functype[type];
1298                 (void) fprintf(fp, "%d type=%d (%s)",
1299                                bShowNumbers ? j : -1, bShowNumbers ? type : -1,
1300                                interaction_function[ftype].name);
1301                 j++;
1302                 for (k = 0; k < interaction_function[ftype].nratoms; k++)
1303                 {
1304                     (void) fprintf(fp, " %u", *(iatoms++));
1305                 }
1306                 (void) fprintf(fp, "\n");
1307                 i += 1+interaction_function[ftype].nratoms;
1308 #else
1309                 fprintf(fp, "%5d%5d\n", i, iatoms[i]);
1310                 i++;
1311 #endif
1312             }
1313         }
1314     }
1315 }
1316
1317 static void pr_cmap(FILE *fp, int indent, const char *title,
1318                     gmx_cmap_t *cmap_grid, gmx_bool bShowNumbers)
1319 {
1320     int  i, j, nelem;
1321     real dx, idx;
1322
1323     dx    = 360.0 / cmap_grid->grid_spacing;
1324     nelem = cmap_grid->grid_spacing*cmap_grid->grid_spacing;
1325
1326     if (available(fp, cmap_grid, indent, title))
1327     {
1328         fprintf(fp, "%s\n", title);
1329
1330         for (i = 0; i < cmap_grid->ngrid; i++)
1331         {
1332             idx = -180.0;
1333             fprintf(fp, "%8s %8s %8s %8s\n", "V", "dVdx", "dVdy", "d2dV");
1334
1335             fprintf(fp, "grid[%3d]={\n", bShowNumbers ? i : -1);
1336
1337             for (j = 0; j < nelem; j++)
1338             {
1339                 if ( (j%cmap_grid->grid_spacing) == 0)
1340                 {
1341                     fprintf(fp, "%8.1f\n", idx);
1342                     idx += dx;
1343                 }
1344
1345                 fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4]);
1346                 fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+1]);
1347                 fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+2]);
1348                 fprintf(fp, "%8.3f\n", cmap_grid->cmapdata[i].cmap[j*4+3]);
1349             }
1350             fprintf(fp, "\n");
1351         }
1352     }
1353
1354 }
1355
1356 void pr_ffparams(FILE *fp, int indent, const char *title,
1357                  gmx_ffparams_t *ffparams,
1358                  gmx_bool bShowNumbers)
1359 {
1360     int i, j;
1361
1362     indent = pr_title(fp, indent, title);
1363     (void) pr_indent(fp, indent);
1364     (void) fprintf(fp, "atnr=%d\n", ffparams->atnr);
1365     (void) pr_indent(fp, indent);
1366     (void) fprintf(fp, "ntypes=%d\n", ffparams->ntypes);
1367     for (i = 0; i < ffparams->ntypes; i++)
1368     {
1369         (void) pr_indent(fp, indent+INDENT);
1370         (void) fprintf(fp, "functype[%d]=%s, ",
1371                        bShowNumbers ? i : -1,
1372                        interaction_function[ffparams->functype[i]].name);
1373         pr_iparams(fp, ffparams->functype[i], &ffparams->iparams[i]);
1374     }
1375     (void) pr_double(fp, indent, "reppow", ffparams->reppow);
1376     (void) pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ);
1377     pr_cmap(fp, indent, "cmap", &ffparams->cmap_grid, bShowNumbers);
1378 }
1379
1380 void pr_idef(FILE *fp, int indent, const char *title, t_idef *idef, gmx_bool bShowNumbers)
1381 {
1382     int i, j;
1383
1384     if (available(fp, idef, indent, title))
1385     {
1386         indent = pr_title(fp, indent, title);
1387         (void) pr_indent(fp, indent);
1388         (void) fprintf(fp, "atnr=%d\n", idef->atnr);
1389         (void) pr_indent(fp, indent);
1390         (void) fprintf(fp, "ntypes=%d\n", idef->ntypes);
1391         for (i = 0; i < idef->ntypes; i++)
1392         {
1393             (void) pr_indent(fp, indent+INDENT);
1394             (void) fprintf(fp, "functype[%d]=%s, ",
1395                            bShowNumbers ? i : -1,
1396                            interaction_function[idef->functype[i]].name);
1397             pr_iparams(fp, idef->functype[i], &idef->iparams[i]);
1398         }
1399         (void) pr_real(fp, indent, "fudgeQQ", idef->fudgeQQ);
1400
1401         for (j = 0; (j < F_NRE); j++)
1402         {
1403             pr_ilist(fp, indent, interaction_function[j].longname,
1404                      idef->functype, &idef->il[j], bShowNumbers);
1405         }
1406     }
1407 }
1408
1409 static int pr_block_title(FILE *fp, int indent, const char *title, t_block *block)
1410 {
1411     int i;
1412
1413     if (available(fp, block, indent, title))
1414     {
1415         indent = pr_title(fp, indent, title);
1416         (void) pr_indent(fp, indent);
1417         (void) fprintf(fp, "nr=%d\n", block->nr);
1418     }
1419     return indent;
1420 }
1421
1422 static int pr_blocka_title(FILE *fp, int indent, const char *title, t_blocka *block)
1423 {
1424     int i;
1425
1426     if (available(fp, block, indent, title))
1427     {
1428         indent = pr_title(fp, indent, title);
1429         (void) pr_indent(fp, indent);
1430         (void) fprintf(fp, "nr=%d\n", block->nr);
1431         (void) pr_indent(fp, indent);
1432         (void) fprintf(fp, "nra=%d\n", block->nra);
1433     }
1434     return indent;
1435 }
1436
1437 static void low_pr_blocka(FILE *fp, int indent, const char *title, t_blocka *block, gmx_bool bShowNumbers)
1438 {
1439     int i;
1440
1441     if (available(fp, block, indent, title))
1442     {
1443         indent = pr_blocka_title(fp, indent, title, block);
1444         for (i = 0; i <= block->nr; i++)
1445         {
1446             (void) pr_indent(fp, indent+INDENT);
1447             (void) fprintf(fp, "%s->index[%d]=%u\n",
1448                            title, bShowNumbers ? i : -1, block->index[i]);
1449         }
1450         for (i = 0; i < block->nra; i++)
1451         {
1452             (void) pr_indent(fp, indent+INDENT);
1453             (void) fprintf(fp, "%s->a[%d]=%u\n",
1454                            title, bShowNumbers ? i : -1, block->a[i]);
1455         }
1456     }
1457 }
1458
1459 void pr_block(FILE *fp, int indent, const char *title, t_block *block, gmx_bool bShowNumbers)
1460 {
1461     int i, j, ok, size, start, end;
1462
1463     if (available(fp, block, indent, title))
1464     {
1465         indent = pr_block_title(fp, indent, title, block);
1466         start  = 0;
1467         end    = start;
1468         if ((ok = (block->index[start] == 0)) == 0)
1469         {
1470             (void) fprintf(fp, "block->index[%d] should be 0\n", start);
1471         }
1472         else
1473         {
1474             for (i = 0; i < block->nr; i++)
1475             {
1476                 end  = block->index[i+1];
1477                 size = pr_indent(fp, indent);
1478                 if (end <= start)
1479                 {
1480                     size += fprintf(fp, "%s[%d]={}\n", title, i);
1481                 }
1482                 else
1483                 {
1484                     size += fprintf(fp, "%s[%d]={%d..%d}\n",
1485                                     title, bShowNumbers ? i : -1,
1486                                     bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1);
1487                 }
1488                 start = end;
1489             }
1490         }
1491     }
1492 }
1493
1494 void pr_blocka(FILE *fp, int indent, const char *title, t_blocka *block, gmx_bool bShowNumbers)
1495 {
1496     int i, j, ok, size, start, end;
1497
1498     if (available(fp, block, indent, title))
1499     {
1500         indent = pr_blocka_title(fp, indent, title, block);
1501         start  = 0;
1502         end    = start;
1503         if ((ok = (block->index[start] == 0)) == 0)
1504         {
1505             (void) fprintf(fp, "block->index[%d] should be 0\n", start);
1506         }
1507         else
1508         {
1509             for (i = 0; i < block->nr; i++)
1510             {
1511                 end  = block->index[i+1];
1512                 size = pr_indent(fp, indent);
1513                 if (end <= start)
1514                 {
1515                     size += fprintf(fp, "%s[%d]={", title, i);
1516                 }
1517                 else
1518                 {
1519                     size += fprintf(fp, "%s[%d][%d..%d]={",
1520                                     title, bShowNumbers ? i : -1,
1521                                     bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1);
1522                 }
1523                 for (j = start; j < end; j++)
1524                 {
1525                     if (j > start)
1526                     {
1527                         size += fprintf(fp, ", ");
1528                     }
1529                     if ((size) > (USE_WIDTH))
1530                     {
1531                         (void) fprintf(fp, "\n");
1532                         size = pr_indent(fp, indent+INDENT);
1533                     }
1534                     size += fprintf(fp, "%u", block->a[j]);
1535                 }
1536                 (void) fprintf(fp, "}\n");
1537                 start = end;
1538             }
1539         }
1540         if ((end != block->nra) || (!ok))
1541         {
1542             (void) pr_indent(fp, indent);
1543             (void) fprintf(fp, "tables inconsistent, dumping complete tables:\n");
1544             low_pr_blocka(fp, indent, title, block, bShowNumbers);
1545         }
1546     }
1547 }
1548
1549 static void pr_strings(FILE *fp, int indent, const char *title, char ***nm, int n, gmx_bool bShowNumbers)
1550 {
1551     int i;
1552
1553     if (available(fp, nm, indent, title))
1554     {
1555         indent = pr_title_n(fp, indent, title, n);
1556         for (i = 0; i < n; i++)
1557         {
1558             (void) pr_indent(fp, indent);
1559             (void) fprintf(fp, "%s[%d]={name=\"%s\"}\n",
1560                            title, bShowNumbers ? i : -1, *(nm[i]));
1561         }
1562     }
1563 }
1564
1565 static void pr_strings2(FILE *fp, int indent, const char *title,
1566                         char ***nm, char ***nmB, int n, gmx_bool bShowNumbers)
1567 {
1568     int i;
1569
1570     if (available(fp, nm, indent, title))
1571     {
1572         indent = pr_title_n(fp, indent, title, n);
1573         for (i = 0; i < n; i++)
1574         {
1575             (void) pr_indent(fp, indent);
1576             (void) fprintf(fp, "%s[%d]={name=\"%s\",nameB=\"%s\"}\n",
1577                            title, bShowNumbers ? i : -1, *(nm[i]), *(nmB[i]));
1578         }
1579     }
1580 }
1581
1582 static void pr_resinfo(FILE *fp, int indent, const char *title, t_resinfo *resinfo, int n, gmx_bool bShowNumbers)
1583 {
1584     int i;
1585
1586     if (available(fp, resinfo, indent, title))
1587     {
1588         indent = pr_title_n(fp, indent, title, n);
1589         for (i = 0; i < n; i++)
1590         {
1591             (void) pr_indent(fp, indent);
1592             (void) fprintf(fp, "%s[%d]={name=\"%s\", nr=%d, ic='%c'}\n",
1593                            title, bShowNumbers ? i : -1,
1594                            *(resinfo[i].name), resinfo[i].nr,
1595                            (resinfo[i].ic == '\0') ? ' ' : resinfo[i].ic);
1596         }
1597     }
1598 }
1599
1600 static void pr_atom(FILE *fp, int indent, const char *title, t_atom *atom, int n)
1601 {
1602     int i, j;
1603
1604     if (available(fp, atom, indent, title))
1605     {
1606         indent = pr_title_n(fp, indent, title, n);
1607         for (i = 0; i < n; i++)
1608         {
1609             (void) pr_indent(fp, indent);
1610             fprintf(fp, "%s[%6d]={type=%3d, typeB=%3d, ptype=%8s, m=%12.5e, "
1611                     "q=%12.5e, mB=%12.5e, qB=%12.5e, resind=%5d, atomnumber=%3d}\n",
1612                     title, i, atom[i].type, atom[i].typeB, ptype_str[atom[i].ptype],
1613                     atom[i].m, atom[i].q, atom[i].mB, atom[i].qB,
1614                     atom[i].resind, atom[i].atomnumber);
1615         }
1616     }
1617 }
1618
1619 static void pr_grps(FILE *fp, const char *title, t_grps grps[], char **grpname[])
1620 {
1621     int i, j;
1622
1623     for (i = 0; (i < egcNR); i++)
1624     {
1625         fprintf(fp, "%s[%-12s] nr=%d, name=[", title, gtypes[i], grps[i].nr);
1626         for (j = 0; (j < grps[i].nr); j++)
1627         {
1628             fprintf(fp, " %s", *(grpname[grps[i].nm_ind[j]]));
1629         }
1630         fprintf(fp, "]\n");
1631     }
1632 }
1633
1634 static void pr_groups(FILE *fp, int indent,
1635                       gmx_groups_t *groups,
1636                       gmx_bool bShowNumbers)
1637 {
1638     int grpnr[egcNR];
1639     int nat_max, i, g;
1640
1641     pr_grps(fp, "grp", groups->grps, groups->grpname);
1642     pr_strings(fp, indent, "grpname", groups->grpname, groups->ngrpname, bShowNumbers);
1643
1644     (void) pr_indent(fp, indent);
1645     fprintf(fp, "groups          ");
1646     for (g = 0; g < egcNR; g++)
1647     {
1648         printf(" %5.5s", gtypes[g]);
1649     }
1650     printf("\n");
1651
1652     (void) pr_indent(fp, indent);
1653     fprintf(fp, "allocated       ");
1654     nat_max = 0;
1655     for (g = 0; g < egcNR; g++)
1656     {
1657         printf(" %5d", groups->ngrpnr[g]);
1658         nat_max = max(nat_max, groups->ngrpnr[g]);
1659     }
1660     printf("\n");
1661
1662     if (nat_max == 0)
1663     {
1664         (void) pr_indent(fp, indent);
1665         fprintf(fp, "groupnr[%5s] =", "*");
1666         for (g = 0; g < egcNR; g++)
1667         {
1668             fprintf(fp, "  %3d ", 0);
1669         }
1670         fprintf(fp, "\n");
1671     }
1672     else
1673     {
1674         for (i = 0; i < nat_max; i++)
1675         {
1676             (void) pr_indent(fp, indent);
1677             fprintf(fp, "groupnr[%5d] =", i);
1678             for (g = 0; g < egcNR; g++)
1679             {
1680                 fprintf(fp, "  %3d ",
1681                         groups->grpnr[g] ? groups->grpnr[g][i] : 0);
1682             }
1683             fprintf(fp, "\n");
1684         }
1685     }
1686 }
1687
1688 void pr_atoms(FILE *fp, int indent, const char *title, t_atoms *atoms,
1689               gmx_bool bShownumbers)
1690 {
1691     if (available(fp, atoms, indent, title))
1692     {
1693         indent = pr_title(fp, indent, title);
1694         pr_atom(fp, indent, "atom", atoms->atom, atoms->nr);
1695         pr_strings(fp, indent, "atom", atoms->atomname, atoms->nr, bShownumbers);
1696         pr_strings2(fp, indent, "type", atoms->atomtype, atoms->atomtypeB, atoms->nr, bShownumbers);
1697         pr_resinfo(fp, indent, "residue", atoms->resinfo, atoms->nres, bShownumbers);
1698     }
1699 }
1700
1701
1702 void pr_atomtypes(FILE *fp, int indent, const char *title, t_atomtypes *atomtypes,
1703                   gmx_bool bShowNumbers)
1704 {
1705     int i;
1706     if (available(fp, atomtypes, indent, title))
1707     {
1708         indent = pr_title(fp, indent, title);
1709         for (i = 0; i < atomtypes->nr; i++)
1710         {
1711             pr_indent(fp, indent);
1712             fprintf(fp,
1713                     "atomtype[%3d]={radius=%12.5e, volume=%12.5e, gb_radius=%12.5e, surftens=%12.5e, atomnumber=%4d, S_hct=%12.5e)}\n",
1714                     bShowNumbers ? i : -1, atomtypes->radius[i], atomtypes->vol[i],
1715                     atomtypes->gb_radius[i],
1716                     atomtypes->surftens[i], atomtypes->atomnumber[i], atomtypes->S_hct[i]);
1717         }
1718     }
1719 }
1720
1721 static void pr_moltype(FILE *fp, int indent, const char *title,
1722                        gmx_moltype_t *molt, int n,
1723                        gmx_ffparams_t *ffparams,
1724                        gmx_bool bShowNumbers)
1725 {
1726     int j;
1727
1728     indent = pr_title_n(fp, indent, title, n);
1729     (void) pr_indent(fp, indent);
1730     (void) fprintf(fp, "name=\"%s\"\n", *(molt->name));
1731     pr_atoms(fp, indent, "atoms", &(molt->atoms), bShowNumbers);
1732     pr_block(fp, indent, "cgs", &molt->cgs, bShowNumbers);
1733     pr_blocka(fp, indent, "excls", &molt->excls, bShowNumbers);
1734     for (j = 0; (j < F_NRE); j++)
1735     {
1736         pr_ilist(fp, indent, interaction_function[j].longname,
1737                  ffparams->functype, &molt->ilist[j], bShowNumbers);
1738     }
1739 }
1740
1741 static void pr_molblock(FILE *fp, int indent, const char *title,
1742                         gmx_molblock_t *molb, int n,
1743                         gmx_moltype_t *molt)
1744 {
1745     indent = pr_title_n(fp, indent, title, n);
1746     (void) pr_indent(fp, indent);
1747     (void) fprintf(fp, "%-20s = %d \"%s\"\n",
1748                    "moltype", molb->type, *(molt[molb->type].name));
1749     pr_int(fp, indent, "#molecules", molb->nmol);
1750     pr_int(fp, indent, "#atoms_mol", molb->natoms_mol);
1751     pr_int(fp, indent, "#posres_xA", molb->nposres_xA);
1752     if (molb->nposres_xA > 0)
1753     {
1754         pr_rvecs(fp, indent, "posres_xA", molb->posres_xA, molb->nposres_xA);
1755     }
1756     pr_int(fp, indent, "#posres_xB", molb->nposres_xB);
1757     if (molb->nposres_xB > 0)
1758     {
1759         pr_rvecs(fp, indent, "posres_xB", molb->posres_xB, molb->nposres_xB);
1760     }
1761 }
1762
1763 void pr_mtop(FILE *fp, int indent, const char *title, gmx_mtop_t *mtop,
1764              gmx_bool bShowNumbers)
1765 {
1766     int mt, mb;
1767
1768     if (available(fp, mtop, indent, title))
1769     {
1770         indent = pr_title(fp, indent, title);
1771         (void) pr_indent(fp, indent);
1772         (void) fprintf(fp, "name=\"%s\"\n", *(mtop->name));
1773         pr_int(fp, indent, "#atoms", mtop->natoms);
1774         pr_int(fp, indent, "#molblock", mtop->nmolblock);
1775         for (mb = 0; mb < mtop->nmolblock; mb++)
1776         {
1777             pr_molblock(fp, indent, "molblock", &mtop->molblock[mb], mb, mtop->moltype);
1778         }
1779         pr_ffparams(fp, indent, "ffparams", &(mtop->ffparams), bShowNumbers);
1780         pr_atomtypes(fp, indent, "atomtypes", &(mtop->atomtypes), bShowNumbers);
1781         for (mt = 0; mt < mtop->nmoltype; mt++)
1782         {
1783             pr_moltype(fp, indent, "moltype", &mtop->moltype[mt], mt,
1784                        &mtop->ffparams, bShowNumbers);
1785         }
1786         pr_groups(fp, indent, &mtop->groups, bShowNumbers);
1787     }
1788 }
1789
1790 void pr_top(FILE *fp, int indent, const char *title, t_topology *top, gmx_bool bShowNumbers)
1791 {
1792     if (available(fp, top, indent, title))
1793     {
1794         indent = pr_title(fp, indent, title);
1795         (void) pr_indent(fp, indent);
1796         (void) fprintf(fp, "name=\"%s\"\n", *(top->name));
1797         pr_atoms(fp, indent, "atoms", &(top->atoms), bShowNumbers);
1798         pr_atomtypes(fp, indent, "atomtypes", &(top->atomtypes), bShowNumbers);
1799         pr_block(fp, indent, "cgs", &top->cgs, bShowNumbers);
1800         pr_block(fp, indent, "mols", &top->mols, bShowNumbers);
1801         pr_blocka(fp, indent, "excls", &top->excls, bShowNumbers);
1802         pr_idef(fp, indent, "idef", &top->idef, bShowNumbers);
1803     }
1804 }
1805
1806 void pr_header(FILE *fp, int indent, const char *title, t_tpxheader *sh)
1807 {
1808     char buf[22];
1809
1810     if (available(fp, sh, indent, title))
1811     {
1812         indent = pr_title(fp, indent, title);
1813         pr_indent(fp, indent);
1814         fprintf(fp, "bIr    = %spresent\n", sh->bIr ? "" : "not ");
1815         pr_indent(fp, indent);
1816         fprintf(fp, "bBox   = %spresent\n", sh->bBox ? "" : "not ");
1817         pr_indent(fp, indent);
1818         fprintf(fp, "bTop   = %spresent\n", sh->bTop ? "" : "not ");
1819         pr_indent(fp, indent);
1820         fprintf(fp, "bX     = %spresent\n", sh->bX ? "" : "not ");
1821         pr_indent(fp, indent);
1822         fprintf(fp, "bV     = %spresent\n", sh->bV ? "" : "not ");
1823         pr_indent(fp, indent);
1824         fprintf(fp, "bF     = %spresent\n", sh->bF ? "" : "not ");
1825
1826         pr_indent(fp, indent);
1827         fprintf(fp, "natoms = %d\n", sh->natoms);
1828         pr_indent(fp, indent);
1829         fprintf(fp, "lambda = %e\n", sh->lambda);
1830     }
1831 }
1832
1833 void pr_commrec(FILE *fp, int indent, t_commrec *cr)
1834 {
1835     pr_indent(fp, indent);
1836     fprintf(fp, "commrec:\n");
1837     indent += 2;
1838     pr_indent(fp, indent);
1839     fprintf(fp, "nodeid    = %d\n", cr->nodeid);
1840     pr_indent(fp, indent);
1841     fprintf(fp, "nnodes    = %d\n", cr->nnodes);
1842     pr_indent(fp, indent);
1843     fprintf(fp, "npmenodes = %d\n", cr->npmenodes);
1844     /*
1845        pr_indent(fp,indent);
1846        fprintf(fp,"threadid  = %d\n",cr->threadid);
1847        pr_indent(fp,indent);
1848        fprintf(fp,"nthreads  = %d\n",cr->nthreads);
1849      */
1850 }