Merge branch release-2019
[alexxy/gromacs.git] / src / gromacs / tools / dump.cpp
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-2013, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017,2018, 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 #include "gmxpre.h"
38
39 #include "dump.h"
40
41 #include "config.h"
42
43 #include <cassert>
44 #include <cmath>
45 #include <cstdio>
46 #include <cstring>
47
48 #include "gromacs/commandline/pargs.h"
49 #include "gromacs/fileio/checkpoint.h"
50 #include "gromacs/fileio/enxio.h"
51 #include "gromacs/fileio/gmxfio.h"
52 #include "gromacs/fileio/mtxio.h"
53 #include "gromacs/fileio/tngio.h"
54 #include "gromacs/fileio/tpxio.h"
55 #include "gromacs/fileio/trrio.h"
56 #include "gromacs/fileio/xtcio.h"
57 #include "gromacs/gmxpreprocess/gmxcpp.h"
58 #include "gromacs/linearalgebra/sparsematrix.h"
59 #include "gromacs/math/vecdump.h"
60 #include "gromacs/mdrunutility/mdmodules.h"
61 #include "gromacs/mdtypes/forcerec.h"
62 #include "gromacs/mdtypes/inputrec.h"
63 #include "gromacs/mdtypes/md_enums.h"
64 #include "gromacs/mdtypes/state.h"
65 #include "gromacs/topology/mtop_util.h"
66 #include "gromacs/topology/topology.h"
67 #include "gromacs/trajectory/energyframe.h"
68 #include "gromacs/trajectory/trajectoryframe.h"
69 #include "gromacs/utility/arraysize.h"
70 #include "gromacs/utility/basedefinitions.h"
71 #include "gromacs/utility/fatalerror.h"
72 #include "gromacs/utility/futil.h"
73 #include "gromacs/utility/smalloc.h"
74 #include "gromacs/utility/txtdump.h"
75
76 static void list_tpx(const char *fn,
77                      gmx_bool    bShowNumbers,
78                      gmx_bool    bShowParameters,
79                      const char *mdpfn,
80                      gmx_bool    bSysTop,
81                      gmx_bool    bOriginalInputrec)
82 {
83     FILE         *gp;
84     int           indent, i, j, **gcount, atot;
85     t_state       state;
86     t_tpxheader   tpx;
87     gmx_mtop_t    mtop;
88     t_topology    top;
89
90     read_tpxheader(fn, &tpx, TRUE);
91     t_inputrec     ir;
92     read_tpx_state(fn,
93                    tpx.bIr ? &ir : nullptr,
94                    &state,
95                    tpx.bTop ? &mtop : nullptr);
96     if (tpx.bIr && !bOriginalInputrec)
97     {
98         gmx::MDModules().adjustInputrecBasedOnModules(&ir);
99     }
100
101     if (mdpfn && tpx.bIr)
102     {
103         gp = gmx_fio_fopen(mdpfn, "w");
104         pr_inputrec(gp, 0, nullptr, &ir, TRUE);
105         gmx_fio_fclose(gp);
106     }
107
108     if (!mdpfn)
109     {
110         if (bSysTop)
111         {
112             top = gmx_mtop_t_to_t_topology(&mtop, false);
113         }
114
115         if (available(stdout, &tpx, 0, fn))
116         {
117             indent = 0;
118             pr_title(stdout, indent, fn);
119             pr_inputrec(stdout, 0, "inputrec", tpx.bIr ? &ir : nullptr, FALSE);
120
121             pr_tpxheader(stdout, indent, "header", &(tpx));
122
123             if (!bSysTop)
124             {
125                 pr_mtop(stdout, indent, "topology", &(mtop), bShowNumbers, bShowParameters);
126             }
127             else
128             {
129                 pr_top(stdout, indent, "topology", &(top), bShowNumbers, bShowParameters);
130             }
131
132             pr_rvecs(stdout, indent, "box", tpx.bBox ? state.box : nullptr, DIM);
133             pr_rvecs(stdout, indent, "box_rel", tpx.bBox ? state.box_rel : nullptr, DIM);
134             pr_rvecs(stdout, indent, "boxv", tpx.bBox ? state.boxv : nullptr, DIM);
135             pr_rvecs(stdout, indent, "pres_prev", tpx.bBox ? state.pres_prev : nullptr, DIM);
136             pr_rvecs(stdout, indent, "svir_prev", tpx.bBox ? state.svir_prev : nullptr, DIM);
137             pr_rvecs(stdout, indent, "fvir_prev", tpx.bBox ? state.fvir_prev : nullptr, DIM);
138             /* leave nosehoover_xi in for now to match the tpr version */
139             pr_doubles(stdout, indent, "nosehoover_xi", state.nosehoover_xi.data(), state.ngtc);
140             /*pr_doubles(stdout,indent,"nosehoover_vxi",state.nosehoover_vxi,state.ngtc);*/
141             /*pr_doubles(stdout,indent,"therm_integral",state.therm_integral,state.ngtc);*/
142             pr_rvecs(stdout, indent, "x", tpx.bX ? state.x.rvec_array() : nullptr, state.natoms);
143             pr_rvecs(stdout, indent, "v", tpx.bV ? state.v.rvec_array() : nullptr, state.natoms);
144         }
145
146         const gmx_groups_t &groups = mtop.groups;
147
148         snew(gcount, egcNR);
149         for (i = 0; (i < egcNR); i++)
150         {
151             snew(gcount[i], groups.grps[i].nr);
152         }
153
154         for (i = 0; (i < mtop.natoms); i++)
155         {
156             for (j = 0; (j < egcNR); j++)
157             {
158                 gcount[j][getGroupType(groups, j, i)]++;
159             }
160         }
161         printf("Group statistics\n");
162         for (i = 0; (i < egcNR); i++)
163         {
164             atot = 0;
165             printf("%-12s: ", gtypes[i]);
166             for (j = 0; (j < groups.grps[i].nr); j++)
167             {
168                 printf("  %5d", gcount[i][j]);
169                 atot += gcount[i][j];
170             }
171             printf("  (total %d atoms)\n", atot);
172             sfree(gcount[i]);
173         }
174         sfree(gcount);
175     }
176 }
177
178 static void list_top(const char *fn)
179 {
180     int       status, done;
181 #define BUFLEN 256
182     char      buf[BUFLEN];
183     gmx_cpp_t handle;
184     char     *cppopts[] = { nullptr };
185
186     status = cpp_open_file(fn, &handle, cppopts);
187     if (status != 0)
188     {
189         gmx_fatal(FARGS, "%s", cpp_error(&handle, status));
190     }
191     do
192     {
193         status = cpp_read_line(&handle, BUFLEN, buf);
194         done   = static_cast<int>(status == eCPP_EOF);
195         if (!done)
196         {
197             if (status != eCPP_OK)
198             {
199                 gmx_fatal(FARGS, "%s", cpp_error(&handle, status));
200             }
201             else
202             {
203                 printf("%s\n", buf);
204             }
205         }
206     }
207     while (done == 0);
208     status = cpp_close_file(&handle);
209     if (status != eCPP_OK)
210     {
211         gmx_fatal(FARGS, "%s", cpp_error(&handle, status));
212     }
213 }
214
215 static void list_trr(const char *fn)
216 {
217     t_fileio         *fpread;
218     int               nframe, indent;
219     char              buf[256];
220     rvec             *x, *v, *f;
221     matrix            box;
222     gmx_trr_header_t  trrheader;
223     gmx_bool          bOK;
224
225     fpread  = gmx_trr_open(fn, "r");
226
227     nframe = 0;
228     while (gmx_trr_read_frame_header(fpread, &trrheader, &bOK))
229     {
230         snew(x, trrheader.natoms);
231         snew(v, trrheader.natoms);
232         snew(f, trrheader.natoms);
233         if (gmx_trr_read_frame_data(fpread, &trrheader,
234                                     trrheader.box_size ? box : nullptr,
235                                     trrheader.x_size   ? x : nullptr,
236                                     trrheader.v_size   ? v : nullptr,
237                                     trrheader.f_size   ? f : nullptr))
238         {
239             sprintf(buf, "%s frame %d", fn, nframe);
240             indent = 0;
241             indent = pr_title(stdout, indent, buf);
242             pr_indent(stdout, indent);
243             fprintf(stdout, "natoms=%10d  step=%10" PRId64 "  time=%12.7e  lambda=%10g\n",
244                     trrheader.natoms, trrheader.step, trrheader.t, trrheader.lambda);
245             if (trrheader.box_size)
246             {
247                 pr_rvecs(stdout, indent, "box", box, DIM);
248             }
249             if (trrheader.x_size)
250             {
251                 pr_rvecs(stdout, indent, "x", x, trrheader.natoms);
252             }
253             if (trrheader.v_size)
254             {
255                 pr_rvecs(stdout, indent, "v", v, trrheader.natoms);
256             }
257             if (trrheader.f_size)
258             {
259                 pr_rvecs(stdout, indent, "f", f, trrheader.natoms);
260             }
261         }
262         else
263         {
264             fprintf(stderr, "\nWARNING: Incomplete frame: nr %d, t=%g\n",
265                     nframe, trrheader.t);
266         }
267
268         sfree(x);
269         sfree(v);
270         sfree(f);
271         nframe++;
272     }
273     if (!bOK)
274     {
275         fprintf(stderr, "\nWARNING: Incomplete frame header: nr %d, t=%g\n",
276                 nframe, trrheader.t);
277     }
278     gmx_trr_close(fpread);
279 }
280
281 static void list_xtc(const char *fn)
282 {
283     t_fileio   *xd;
284     int         indent;
285     char        buf[256];
286     rvec       *x;
287     matrix      box;
288     int         nframe, natoms;
289     int64_t     step;
290     real        prec, time;
291     gmx_bool    bOK;
292
293     xd = open_xtc(fn, "r");
294     read_first_xtc(xd, &natoms, &step, &time, box, &x, &prec, &bOK);
295
296     nframe = 0;
297     do
298     {
299         sprintf(buf, "%s frame %d", fn, nframe);
300         indent = 0;
301         indent = pr_title(stdout, indent, buf);
302         pr_indent(stdout, indent);
303         fprintf(stdout, "natoms=%10d  step=%10" PRId64 "  time=%12.7e  prec=%10g\n",
304                 natoms, step, time, prec);
305         pr_rvecs(stdout, indent, "box", box, DIM);
306         pr_rvecs(stdout, indent, "x", x, natoms);
307         nframe++;
308     }
309     while (read_next_xtc(xd, natoms, &step, &time, box, x, &prec, &bOK) != 0);
310     if (!bOK)
311     {
312         fprintf(stderr, "\nWARNING: Incomplete frame at time %g\n", time);
313     }
314     sfree(x);
315     close_xtc(xd);
316 }
317
318 #if GMX_USE_TNG
319
320 /*! \brief Callback used by list_tng_for_gmx_dump. */
321 static void list_tng_inner(const char *fn,
322                            gmx_bool    bFirstFrame,
323                            real       *values,
324                            int64_t     step,
325                            double      frame_time,
326                            int64_t     n_values_per_frame,
327                            int64_t     n_atoms,
328                            real        prec,
329                            int64_t     nframe,
330                            char       *block_name)
331 {
332     char                 buf[256];
333     int                  indent = 0;
334
335     if (bFirstFrame)
336     {
337         sprintf(buf, "%s frame %" PRId64, fn, nframe);
338         indent = 0;
339         indent = pr_title(stdout, indent, buf);
340         pr_indent(stdout, indent);
341         fprintf(stdout, "natoms=%10" PRId64 "  step=%10" PRId64 "  time=%12.7e",
342                 n_atoms, step, frame_time);
343         if (prec > 0)
344         {
345             fprintf(stdout, "  prec=%10g", prec);
346         }
347         fprintf(stdout, "\n");
348     }
349     pr_reals_of_dim(stdout, indent, block_name, values, n_atoms, n_values_per_frame);
350 }
351
352 #endif
353
354 static void list_tng(const char gmx_unused *fn)
355 {
356 #if GMX_USE_TNG
357     gmx_tng_trajectory_t tng;
358     int64_t              nframe = 0;
359     int64_t              i, *block_ids = nullptr, step, ndatablocks;
360     gmx_bool             bOK;
361     real                *values = nullptr;
362
363     gmx_tng_open(fn, 'r', &tng);
364     gmx_print_tng_molecule_system(tng, stdout);
365
366     bOK    = gmx_get_tng_data_block_types_of_next_frame(tng, -1,
367                                                         0,
368                                                         nullptr,
369                                                         &step, &ndatablocks,
370                                                         &block_ids);
371     do
372     {
373         for (i = 0; i < ndatablocks; i++)
374         {
375             double               frame_time;
376             real                 prec;
377             int64_t              n_values_per_frame, n_atoms;
378             char                 block_name[STRLEN];
379
380             gmx_get_tng_data_next_frame_of_block_type(tng, block_ids[i], &values,
381                                                       &step, &frame_time,
382                                                       &n_values_per_frame, &n_atoms,
383                                                       &prec,
384                                                       block_name, STRLEN, &bOK);
385             if (!bOK)
386             {
387                 /* Can't write any output because we don't know what
388                    arrays are valid. */
389                 fprintf(stderr, "\nWARNING: Incomplete frame at time %g, will not write output\n", frame_time);
390             }
391             else
392             {
393                 list_tng_inner(fn, (0 == i), values, step, frame_time,
394                                n_values_per_frame, n_atoms, prec, nframe, block_name);
395             }
396         }
397         nframe++;
398     }
399     while (gmx_get_tng_data_block_types_of_next_frame(tng, step,
400                                                       0,
401                                                       nullptr,
402                                                       &step,
403                                                       &ndatablocks,
404                                                       &block_ids));
405
406     if (block_ids)
407     {
408         sfree(block_ids);
409     }
410     sfree(values);
411     gmx_tng_close(&tng);
412 #endif
413 }
414
415 static void list_trx(const char *fn)
416 {
417     switch (fn2ftp(fn))
418     {
419         case efXTC:
420             list_xtc(fn);
421             break;
422         case efTRR:
423             list_trr(fn);
424             break;
425         case efTNG:
426             list_tng(fn);
427             break;
428         default:
429             fprintf(stderr, "File %s is of an unsupported type. Try using the command\n 'less %s'\n",
430                     fn, fn);
431     }
432 }
433
434 static void list_ene(const char *fn)
435 {
436     ener_file_t    in;
437     gmx_bool       bCont;
438     gmx_enxnm_t   *enm = nullptr;
439     t_enxframe    *fr;
440     int            i, j, nre, b;
441     char           buf[22];
442
443     printf("gmx dump: %s\n", fn);
444     in = open_enx(fn, "r");
445     do_enxnms(in, &nre, &enm);
446     assert(enm);
447
448     printf("energy components:\n");
449     for (i = 0; (i < nre); i++)
450     {
451         printf("%5d  %-24s (%s)\n", i, enm[i].name, enm[i].unit);
452     }
453
454     snew(fr, 1);
455     do
456     {
457         bCont = do_enx(in, fr);
458
459         if (bCont)
460         {
461             printf("\n%24s  %12.5e  %12s  %12s\n", "time:",
462                    fr->t, "step:", gmx_step_str(fr->step, buf));
463             printf("%24s  %12s  %12s  %12s\n",
464                    "", "", "nsteps:", gmx_step_str(fr->nsteps, buf));
465             printf("%24s  %12.5e  %12s  %12s\n",
466                    "delta_t:", fr->dt, "sum steps:", gmx_step_str(fr->nsum, buf));
467             if (fr->nre == nre)
468             {
469                 printf("%24s  %12s  %12s  %12s\n",
470                        "Component", "Energy", "Av. Energy", "Sum Energy");
471                 if (fr->nsum > 0)
472                 {
473                     for (i = 0; (i < nre); i++)
474                     {
475                         printf("%24s  %12.5e  %12.5e  %12.5e\n",
476                                enm[i].name, fr->ener[i].e, fr->ener[i].eav,
477                                fr->ener[i].esum);
478                     }
479                 }
480                 else
481                 {
482                     for (i = 0; (i < nre); i++)
483                     {
484                         printf("%24s  %12.5e\n",
485                                enm[i].name, fr->ener[i].e);
486                     }
487                 }
488             }
489             for (b = 0; b < fr->nblock; b++)
490             {
491                 const char *typestr = "";
492
493                 t_enxblock *eb = &(fr->block[b]);
494                 printf("Block data %2d (%3d subblocks, id=%d)\n",
495                        b, eb->nsub, eb->id);
496
497                 if (eb->id < enxNR)
498                 {
499                     typestr = enx_block_id_name[eb->id];
500                 }
501                 printf("  id='%s'\n", typestr);
502                 for (i = 0; i < eb->nsub; i++)
503                 {
504                     t_enxsubblock *sb = &(eb->sub[i]);
505                     printf("  Sub block %3d (%5d elems, type=%s) values:\n",
506                            i, sb->nr, xdr_datatype_names[sb->type]);
507
508                     switch (sb->type)
509                     {
510                         case xdr_datatype_float:
511                             for (j = 0; j < sb->nr; j++)
512                             {
513                                 printf("%14d   %8.4f\n", j, sb->fval[j]);
514                             }
515                             break;
516                         case xdr_datatype_double:
517                             for (j = 0; j < sb->nr; j++)
518                             {
519                                 printf("%14d   %10.6f\n", j, sb->dval[j]);
520                             }
521                             break;
522                         case xdr_datatype_int:
523                             for (j = 0; j < sb->nr; j++)
524                             {
525                                 printf("%14d %10d\n", j, sb->ival[j]);
526                             }
527                             break;
528                         case xdr_datatype_int64:
529                             for (j = 0; j < sb->nr; j++)
530                             {
531                                 printf("%14d %s\n",
532                                        j, gmx_step_str(sb->lval[j], buf));
533                             }
534                             break;
535                         case xdr_datatype_char:
536                             for (j = 0; j < sb->nr; j++)
537                             {
538                                 printf("%14d %1c\n", j, sb->cval[j]);
539                             }
540                             break;
541                         case xdr_datatype_string:
542                             for (j = 0; j < sb->nr; j++)
543                             {
544                                 printf("%14d %80s\n", j, sb->sval[j]);
545                             }
546                             break;
547                         default:
548                             gmx_incons("Unknown subblock type");
549                     }
550                 }
551             }
552         }
553     }
554     while (bCont);
555
556     close_enx(in);
557
558     free_enxframe(fr);
559     sfree(fr);
560     sfree(enm);
561 }
562
563 static void list_mtx(const char *fn)
564 {
565     int                  nrow, ncol, i, j, k;
566     real                *full   = nullptr, value;
567     gmx_sparsematrix_t * sparse = nullptr;
568
569     gmx_mtxio_read(fn, &nrow, &ncol, &full, &sparse);
570
571     if (full == nullptr)
572     {
573         snew(full, nrow*ncol);
574         for (i = 0; i < nrow*ncol; i++)
575         {
576             full[i] = 0;
577         }
578
579         for (i = 0; i < sparse->nrow; i++)
580         {
581             for (j = 0; j < sparse->ndata[i]; j++)
582             {
583                 k              = sparse->data[i][j].col;
584                 value          = sparse->data[i][j].value;
585                 full[i*ncol+k] = value;
586                 full[k*ncol+i] = value;
587             }
588         }
589         gmx_sparsematrix_destroy(sparse);
590     }
591
592     printf("%d %d\n", nrow, ncol);
593     for (i = 0; i < nrow; i++)
594     {
595         for (j = 0; j < ncol; j++)
596         {
597             printf(" %g", full[i*ncol+j]);
598         }
599         printf("\n");
600     }
601
602     sfree(full);
603 }
604
605 int gmx_dump(int argc, char *argv[])
606 {
607     const char *desc[] = {
608         "[THISMODULE] reads a run input file ([REF].tpr[ref]),",
609         "a trajectory ([REF].trr[ref]/[REF].xtc[ref]/[TT]/tng[tt]), an energy",
610         "file ([REF].edr[ref]) or a checkpoint file ([REF].cpt[ref])",
611         "and prints that to standard output in a readable format.",
612         "This program is essential for checking your run input file in case of",
613         "problems.[PAR]",
614         "The program can also preprocess a topology to help finding problems.",
615         "Note that currently setting [TT]GMXLIB[tt] is the only way to customize",
616         "directories used for searching include files.",
617     };
618     const char *bugs[] = {
619         "Position restraint output from -sys -s is broken"
620     };
621     t_filenm    fnm[] = {
622         { efTPR, "-s", nullptr, ffOPTRD },
623         { efTRX, "-f", nullptr, ffOPTRD },
624         { efEDR, "-e", nullptr, ffOPTRD },
625         { efCPT, nullptr, nullptr, ffOPTRD },
626         { efTOP, "-p", nullptr, ffOPTRD },
627         { efMTX, "-mtx", "hessian", ffOPTRD },
628         { efMDP, "-om", nullptr, ffOPTWR }
629     };
630 #define NFILE asize(fnm)
631
632     gmx_output_env_t *oenv;
633     /* Command line options */
634     gmx_bool          bShowNumbers      = TRUE;
635     gmx_bool          bShowParams       = FALSE;
636     gmx_bool          bSysTop           = FALSE;
637     gmx_bool          bOriginalInputrec = FALSE;
638     t_pargs           pa[]              = {
639         { "-nr", FALSE, etBOOL, {&bShowNumbers}, "Show index numbers in output (leaving them out makes comparison easier, but creates a useless topology)" },
640         { "-param", FALSE, etBOOL, {&bShowParams}, "Show parameters for each bonded interaction (for comparing dumps, it is useful to combine this with -nonr)" },
641         { "-sys", FALSE, etBOOL, {&bSysTop}, "List the atoms and bonded interactions for the whole system instead of for each molecule type" },
642         { "-orgir", FALSE, etBOOL, {&bOriginalInputrec}, "Show input parameters from tpr as they were written by the version that produced the file, instead of how the current version reads them" }
643     };
644
645     if (!parse_common_args(&argc, argv, 0, NFILE, fnm, asize(pa), pa,
646                            asize(desc), desc, asize(bugs), bugs, &oenv))
647     {
648         return 0;
649     }
650
651
652     if (ftp2bSet(efTPR, NFILE, fnm))
653     {
654         list_tpx(ftp2fn(efTPR, NFILE, fnm), bShowNumbers, bShowParams,
655                  ftp2fn_null(efMDP, NFILE, fnm), bSysTop, bOriginalInputrec);
656     }
657     else if (ftp2bSet(efTRX, NFILE, fnm))
658     {
659         list_trx(ftp2fn(efTRX, NFILE, fnm));
660     }
661     else if (ftp2bSet(efEDR, NFILE, fnm))
662     {
663         list_ene(ftp2fn(efEDR, NFILE, fnm));
664     }
665     else if (ftp2bSet(efCPT, NFILE, fnm))
666     {
667         list_checkpoint(ftp2fn(efCPT, NFILE, fnm), stdout);
668     }
669     else if (ftp2bSet(efTOP, NFILE, fnm))
670     {
671         list_top(ftp2fn(efTOP, NFILE, fnm));
672     }
673     else if (ftp2bSet(efMTX, NFILE, fnm))
674     {
675         list_mtx(ftp2fn(efMTX, NFILE, fnm));
676     }
677
678     return 0;
679 }