2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 #include "gromacs/legacyheaders/xvgr.h"
40 #include "gromacs/legacyheaders/mdrun.h"
41 #include "gromacs/legacyheaders/smalloc.h"
43 gmx_mdoutf_t *init_mdoutf(int nfile, const t_filenm fnm[], int mdrun_flags,
44 const t_commrec *cr, const t_inputrec *ir,
45 const output_env_t oenv)
49 gmx_bool bAppendFiles;
59 of->eIntegrator = ir->eI;
60 of->bExpanded = ir->bExpanded;
61 of->elamstats = ir->expandedvals->elamstats;
62 of->simulation_part = ir->simulation_part;
66 bAppendFiles = (mdrun_flags & MD_APPENDFILES);
68 of->bKeepAndNumCPT = (mdrun_flags & MD_KEEPANDNUMCPT);
70 sprintf(filemode, bAppendFiles ? "a+" : "w+");
72 if ((EI_DYNAMICS(ir->eI) || EI_ENERGY_MINIMIZATION(ir->eI))
75 !(EI_DYNAMICS(ir->eI) &&
82 of->fp_trn = open_trn(ftp2fn(efTRN, nfile, fnm), filemode);
84 if (EI_DYNAMICS(ir->eI) &&
87 of->fp_xtc = open_xtc(ftp2fn(efXTC, nfile, fnm), filemode);
88 of->xtc_prec = ir->xtcprec;
90 if (EI_DYNAMICS(ir->eI) || EI_ENERGY_MINIMIZATION(ir->eI))
92 of->fp_ene = open_enx(ftp2fn(efEDR, nfile, fnm), filemode);
94 of->fn_cpt = opt2fn("-cpo", nfile, fnm);
96 if ((ir->efep != efepNO || ir->bSimTemp) && ir->fepvals->nstdhdl > 0 &&
97 (ir->fepvals->separate_dhdl_file == esepdhdlfileYES ) &&
102 of->fp_dhdl = gmx_fio_fopen(opt2fn("-dhdl", nfile, fnm), filemode);
106 of->fp_dhdl = open_dhdl(opt2fn("-dhdl", nfile, fnm), ir, oenv);
110 if (opt2bSet("-field", nfile, fnm) &&
111 (ir->ex[XX].n || ir->ex[YY].n || ir->ex[ZZ].n))
115 of->fp_dhdl = gmx_fio_fopen(opt2fn("-field", nfile, fnm),
120 of->fp_field = xvgropen(opt2fn("-field", nfile, fnm),
121 "Applied electric field", "Time (ps)",
130 void done_mdoutf(gmx_mdoutf_t *of)
132 if (of->fp_ene != NULL)
134 close_enx(of->fp_ene);
138 close_xtc(of->fp_xtc);
142 close_trn(of->fp_trn);
144 if (of->fp_dhdl != NULL)
146 gmx_fio_fclose(of->fp_dhdl);
148 if (of->fp_field != NULL)
150 gmx_fio_fclose(of->fp_field);