2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014, 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.
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.
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.
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.
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.
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.
38 #ifndef GMX_FILEIO_FILENM_H
39 #define GMX_FILEIO_FILENM_H
41 #include "../legacyheaders/types/simple.h"
42 #include "../legacyheaders/types/commrec.h"
48 /* this enum should correspond to the array deffile in gmxlib/filenm.c */
51 efTRX, efTRO, efTRN, efTRR, efTRJ, efCOMPRESSED, efXTC, efTNG,
53 efSTX, efSTO, efGRO, efG96, efPDB, efBRK, efENT, efESP, efPQR,
58 efTPX, efTPS, efTPR, efTPA, efTPB,
59 efTEX, efRTP, efATP, efHDB,
61 efMAP, efEPS, efMAT, efM2P,
71 int ftp; /* File type (see enum above) */
72 const char *opt; /* Command line option */
73 const char *fn; /* File name (as set in source code) */
74 unsigned long flag; /* Flag for all kinds of info (see defs)*/
75 int nfiles; /* number of files */
76 char **fns; /* File names */
85 #define ffRW (ffREAD | ffWRITE)
86 #define ffOPTRD (ffREAD | ffOPT)
87 #define ffOPTWR (ffWRITE| ffOPT)
88 #define ffOPTRW (ffRW | ffOPT)
89 #define ffLIBRD (ffREAD | ffLIB)
90 #define ffLIBOPTRD (ffOPTRD | ffLIB)
91 #define ffRDMULT (ffREAD | ffMULT)
92 #define ffOPTRDMULT (ffRDMULT | ffOPT)
93 #define ffWRMULT (ffWRITE | ffMULT)
94 #define ffOPTWRMULT (ffWRMULT | ffOPT)
96 const char *ftp2ext(int ftp);
97 /* Return extension for filetype */
99 const char *ftp2ext_generic(int ftp);
100 /* Return extension for filetype, and a generic name for generic types
103 const char *ftp2ext_with_dot(int ftp);
104 /* Return extension for filetype with a leading dot */
106 int ftp2generic_count(int ftp);
107 /* Return the number of filetypes for a generic filetype */
109 const int *ftp2generic_list(int ftp);
110 /* Return the list of filetypes for a generic filetype */
112 const char *ftp2desc(int ftp);
113 /* Return description for file type */
115 const char *ftp2defnm(int ftp);
116 /* Return default file name for file type */
118 const char *ftp2ftype(int ftp);
119 /* Return Binary or ASCII depending on file type */
121 void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[],
122 const char *deffnm, gmx_bool bReadNode);
123 /* Parse command line for file names. When bKeep is set args are
124 * not removed from argv. */
126 const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[]);
127 /* Return the filename belonging to cmd-line option opt, or NULL when
130 const char *opt2fn_master(const char *opt, int nfile,
131 const t_filenm fnm[], t_commrec *cr);
132 /* Return the filename belonging to cmd-line option opt, or NULL when
133 * no such option or not running on master */
136 int opt2fns(char **fns[], const char *opt, int nfile,
137 const t_filenm fnm[]);
138 /* Return the filenames belonging to cmd-line option opt, or NULL when
141 #define opt2FILE(opt, nfile, fnm, mode) gmx_ffopen(opt2fn(opt, nfile, fnm), mode)
142 /* Return a file pointer from the filename (see above) */
144 int fn2ftp(const char *fn);
145 /* Return the filetype corrsponding to filename */
147 const char *ftp2fn(int ftp, int nfile, const t_filenm fnm[]);
148 /* Return the first file name with type ftp, or NULL when none found. */
150 int ftp2fns(char **fns[], int ftp, int nfile, const t_filenm fnm[]);
151 /* Return the number of files for the first option with type ftp
152 and the files in **fns[] (will be allocated), or NULL when none found. */
154 #define ftp2FILE(ftp, nfile, fnm, mode) gmx_ffopen(ftp2fn(ftp, nfile, fnm), mode)
155 /* Return a file pointer from the filename (see above) */
157 gmx_bool ftp2bSet(int ftp, int nfile, const t_filenm fnm[]);
158 /* Return TRUE when this file type has been found on the cmd-line */
160 gmx_bool opt2bSet(const char *opt, int nfile, const t_filenm fnm[]);
161 /* Return TRUE when this option has been found on the cmd-line */
163 const char *opt2fn_null(const char *opt, int nfile, const t_filenm fnm[]);
164 /* Return the filenm belonging top cmd-line option opt, or NULL when
166 * Also return NULL when opt is optional and option is not set.
169 const char *ftp2fn_null(int ftp, int nfile, const t_filenm fnm[]);
170 /* Return the first file name with type ftp, or NULL when none found.
171 * Also return NULL when ftp is optional and option is not set.
174 gmx_bool is_optional(const t_filenm *fnm);
175 /* Return whether or not this filenm is optional */
177 gmx_bool is_output(const t_filenm *fnm);
178 /* Return whether or not this filenm is output */
180 gmx_bool is_set(const t_filenm *fnm);
181 /* Return whether or not this filenm is set */
183 /* When we do checkpointing, this routine is called to check for previous
184 * output files and append a '.partNNNN' suffix before the (output) file extensions.
186 int add_suffix_to_output_names(t_filenm *fnm, int nfile, const char *suffix);
188 /* duplicate the filename list (to make a private copy for each thread,
190 t_filenm *dup_tfn(int nf, const t_filenm tfn[]);
192 /* Free memory allocated for file names by parse_file_args(). */
193 void done_filenms(int nf, t_filenm fnm[]);
199 #endif /* GMX_FILEIO_FILENM_H */