Separate job script files for gmxapi package versions.
[gromacs.git] / src / gromacs / fileio / warninp.h
blob7d21c03d5214725c8c4fe71d5d1f137ca01add28
1 /*
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) 2010,2014,2015,2016,2017 by the GROMACS development team.
7 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
8 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9 * and including many others, as listed in the AUTHORS file in the
10 * top-level source directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
38 #ifndef GMX_FILEIO_WARNINP_H
39 #define GMX_FILEIO_WARNINP_H
41 #include <string>
43 #include "gromacs/utility/basedefinitions.h"
45 /* Abstract type for warning bookkeeping */
46 typedef struct warninp* warninp_t;
49 warninp_t init_warning(gmx_bool bAllowWarnings, int maxwarning);
50 /* Initialize the warning data structure.
51 * If bAllowWarnings=FALSE, all warnings (calls to warning()) will be
52 * transformed into errors, calls to warning_note still produce notes.
53 * maxwarning determines the maximum number of warnings that are allowed
54 * for proceeding. When this number is exceeded check_warning_error
55 * and done_warning will generate a fatal error.
56 * bAllowWarnings=TRUE should only be used by programs that have
57 * a -maxwarn command line option.
60 void set_warning_line(warninp_t wi, const char* fn, int line);
61 /* Set filename and linenumber for the warning */
63 int get_warning_line(warninp_t wi);
64 /* Get linenumber for the warning */
67 const char* get_warning_file(warninp_t wi);
68 /* Get filename for the warning */
70 void warning(warninp_t wi, const char* s);
71 /* Issue a warning, with the string s. If s == NULL, then warn_buf
72 * will be printed instead. The file and line set by set_warning_line
73 * are printed, nwarn_warn (local) is incremented.
74 * A fatal error will be generated after processing the input
75 * when nwarn_warn is larger than maxwarning passed to init_warning.
76 * So warning should only be called for issues that should be resolved,
77 * otherwise warning_note should be called.
79 //! Convenience wrapper.
80 void warning(warninp_t wi, const std::string& s);
82 void warning_note(warninp_t wi, const char* s);
83 /* Issue a note, with the string s. If s == NULL, then warn_buf
84 * will be printed instead. The file and line set by set_warning_line
85 * are printed, nwarn_note (local) is incremented.
86 * This is for issues which could be a problem for some systems,
87 * but 100% ok for other systems.
90 //! Convenience wrapper.
91 void warning_note(warninp_t wi, const std::string& s);
93 void warning_error(warninp_t wi, const char* s);
94 /* Issue an error, with the string s. If s == NULL, then warn_buf
95 * will be printed instead. The file and line set by set_warning_line
96 * are printed, nwarn_error (local) is incremented.
99 //! Convenience wrapper.
100 void warning_error(warninp_t wi, const std::string& s);
102 /*! \brief Issue an error with warning_error() and prevent further
103 * processing by calling check_warning_error().
105 * This is intended for use where there is no way to produce a data
106 * structure that would prevent execution from segfaulting. */
107 [[noreturn]] void warning_error_and_exit(warninp_t wi, const char* s, int f_errno, const char* file, int line);
108 //! \copydoc warning_error_and_exit(warninp_t,const char *,int,const char *,int)
109 [[noreturn]] void
110 warning_error_and_exit(warninp_t wi, const std::string& s, int f_errno, const char* file, int line);
112 gmx_bool warning_errors_exist(warninp_t wi);
113 /* Return whether any error-level warnings were issued to wi. */
115 //! Resets the count for all kinds of warnings to zero.
116 void warning_reset(warninp_t wi);
118 void check_warning_error(warninp_t wi, int f_errno, const char* file, int line);
119 /* When warning_error has been called at least once gmx_fatal is called,
120 * otherwise does nothing.
123 void done_warning(warninp_t wi, int f_errno, const char* file, int line);
124 /* Should be called when finished processing the input file.
125 * Prints the number of notes and warnings
126 * and generates a fatal error when errors were found or too many
127 * warnings were generatesd.
128 * Frees the data structure pointed to by wi.
131 void free_warning(warninp_t wi);
132 /* Frees the data structure pointed to by wi. */
134 void _too_few(warninp_t wi, const char* fn, int line);
135 #define too_few(wi) _too_few(wi, __FILE__, __LINE__)
136 /* Issue a warning stating 'Too few parameters' */
138 void _incorrect_n_param(warninp_t wi, const char* fn, int line);
139 #define incorrect_n_param(wi) _incorrect_n_param(wi, __FILE__, __LINE__)
140 /* Issue a warning stating 'Incorrect number of parameters' */
142 #endif