- Remove unused functions and macros.
- Replace some one-use wonders with a direct call to gmx_fatal().
- Add basic Doxygen documentation.
- Clean up some (but not all) gmx_fatal.h includes, removing unnecessary
ones and adding some transitively covered ones. Didn't go through all
the files, and didn't do this very carefully, so some are still left.
but as long as vec.h includes gmx_fatal.h, it doesn't really matter...
Preparation for moving gmx_fatal.h away from legacyheaders/.
Change-Id: I96934ac6ce6bca1e4e8473bdee2b8fec036b0f76
#include "gromacs/fileio/confio.h"
#include "txtdump.h"
#include "vec.h"
-#include <time.h>
#include "nrnb.h"
#include "mshift.h"
#include "mdrun.h"
#include "gromacs/mdlib/groupcoord.h"
#include "gromacs/linearalgebra/nrjac.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
/* We use the same defines as in mvdata.c here */
#define block_bc(cr, d) gmx_bcast( sizeof(d), &(d), (cr))
{
if ((fgets2 (line, STRLEN, in)) == NULL)
{
- unexpected_eof(infile, i+2);
+ gmx_fatal(FARGS, "Unexpected end of file in file %s at line %d",
+ infile, i+2);
}
if (strlen(line) < 39)
{
#include <io.h>
#endif
-#include "gmx_fatal.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
#include "futil.h"
#include <io.h>
#endif
-#include "gmx_fatal.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
#include "futil.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include "xdrf.h"
#include "xdr_datatype.h"
#include "futil.h"
-#include "gmx_fatal.h"
-
/* This is just for clarity - it can never be anything but 4! */
#define XDR_INT_SIZE 4
#include "checkpoint.h"
#include "copyrite.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#include "gromacs/utility/smalloc.h"
struct gmx_mdoutf {
#include "pbc.h"
#include "gmxfio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
typedef struct {
int ai, aj;
} gmx_conection_t;
#include "xdrf.h"
#include "gromacs/fileio/timecontrol.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
/* defines for frame counter output */
#define SKIP1 10
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
void print_one(const output_env_t oenv, const char *base, const char *name,
const char *title, const char *ylabel, int nf, real time[],
real data[])
#include "vec.h"
#include "index.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
const int nfp_ffn[effnNR] = { 0, 1, 2, 3, 2, 5, 7, 9, 4, 3};
const char *s_ffn[effnNR+2] = {
#include "fitahx.h"
#include "vec.h"
-#include "gromacs/utility/smalloc.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+#include "gromacs/utility/smalloc.h"
static void my_calc_xcm(int nbb, atom_id bbind[], rvec x[], rvec xcm)
{
#include "vec.h"
#include "geminate.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#include "gromacs/utility/gmxomp.h"
static void missing_code_message()
#include "physics.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#define MAX_ENDS 3
#include "gromacs/linearalgebra/eigensolver.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
/* print to two file pointers at once (i.e. stderr and log) */
static gmx_inline
#include "mtop_util.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
static void clust_size(const char *ndx, const char *trx, const char *xpm,
const char *xpmw, const char *ncl, const char *acl,
#include "gromacs/linearalgebra/eigensolver.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
int gmx_covar(int argc, char *argv[])
{
#include "gmx_ana.h"
#include "macros.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
#define SQR(x) (pow(x, 2.0))
#define EPSI0 (EPSILON0*E_CHARGE*E_CHARGE*AVOGADRO/(KILO*NANO)) /* EPSILON0 in SI units */
-
static void index_atom2mol(int *n, int *index, t_block *mols)
{
int nat, i, nmol, mol, j;
#include "gmx_ana.h"
#include "macros.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
typedef struct {
char *atomname;
int nr_el;
#include "pbc.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
int gmx_densmap(int argc, char *argv[])
{
#include "copyrite.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#include "gromacs/utility/programcontext.h"
#ifdef GMX_DOUBLE
#include "gromacs/linearalgebra/nrjac.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#include "gromacs/utility/programcontext.h"
#define e2d(x) ENM2DEBYE*(x)
#include "gmx_ana.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
typedef struct {
int n;
#include "xvgr.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
int gmx_dyecoupl(int argc, char *argv[])
{
#include "rmpbc.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
typedef struct
{
char sanm[12];
#include "gstat.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
real calc_gyro(rvec x[], int gnx, atom_id index[], t_atom atom[], real tm,
rvec gvec, rvec d, gmx_bool bQ, gmx_bool bRot, gmx_bool bMOI, matrix trans)
#include "gmx_ana.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
/****************************************************************************/
/* This program calculates the ordering of water molecules across a box, as */
#include "binsearch.h"
#include "powerspect.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
/* Print name of first atom in all groups in index file */
static void print_types(atom_id index[], atom_id a[], int ngrps,
char *groups[], t_topology *top)
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
#include "macros.h"
-#include "gmx_fatal.h"
#include "vec.h"
#include "gromacs/fileio/futil.h"
#include "txtdump.h"
#include "gmx_ana.h"
#include "gromacs/fileio/trxio.h"
-
typedef struct {
int nlj, nqq;
int *lj;
#include "vec.h"
#include "index.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
#define MAXNAMES 30
#define NAME_LEN 30
#include "gromacs/fileio/confio.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#define FACTOR 1000.0 /* Convert nm^2/ps to 10e-5 cm^2/s */
/* NORMAL = total diffusion coefficient (default). X,Y,Z is diffusion
#include "cmat.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
/****************************************************************************/
/* This program calculates the order parameter per atom for an interface or */
#include "main.h"
#include "macros.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
/* We use the same defines as in mvdata.c here */
#define block_bc(cr, d) gmx_bcast( sizeof(d), &(d), (cr))
#define nblock_bc(cr, nr, d) gmx_bcast((nr)*sizeof((d)[0]), (d), (cr))
#include "vec.h"
#include "index.h"
#include "macros.h"
-#include "gmx_fatal.h"
#include "xvgr.h"
#include "rmpbc.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
#define EPS0 8.85419E-12
#define ELC 1.60219E-19
#include "gmx_ana.h"
#include "names.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
static void check_box_c(matrix box)
{
if (fabs(box[ZZ][XX]) > GMX_REAL_EPS*box[ZZ][ZZ] ||
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
#include "pbc.h"
-#include "gmx_fatal.h"
#include "gromacs/fileio/futil.h"
#include "princ.h"
#include "rmpbc.h"
#include "xvgr.h"
#include "gmx_ana.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
typedef struct {
char *label;
#include "gromacs/fileio/matio.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
#include "gromacs/utility/gmxomp.h"
int gmx_sans(int argc, char *argv[])
#include <stdio.h>
#include <math.h>
+
#include "typedefs.h"
#include "gromacs/commandline/pargs.h"
-#include "gmx_fatal.h"
#include "xvgr.h"
#include "gromacs/fileio/pdbio.h"
#include "macros.h"
#include "gromacs/fileio/trxio.h"
#include "gmx_ana.h"
+#include "gmx_fatal.h"
static void calc_com_pbc(int nrefat, t_topology *top, rvec x[], t_pbc *pbc,
atom_id index[], rvec xref, gmx_bool bPBC)
#include "physics.h"
#include "gmx_ana.h"
+#include "gmx_fatal.h"
static void calc_com_pbc(int nrefat, t_topology *top, rvec x[], t_pbc *pbc,
atom_id index[], rvec xref, int ePBC)
#include "gmx_ana.h"
#include "gromacs/linearalgebra/nrjac.h"
+#include "gmx_fatal.h"
static void low_print_data(FILE *fp, real time, rvec x[], int n, atom_id *index,
gmx_bool bDim[], const char *sffmt)
#include "xvgr.h"
#include "gmx_ana.h"
+#include "gmx_fatal.h"
+
#define TIME_EXPLICIT 0
#define TIME_CONTINUE 1
#define TIME_LAST 2
#include "gmx_ana.h"
#include "gromacs/math/do_fit.h"
+#include "gmx_fatal.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include "gromacs/fileio/trxio.h"
#include "gmx_ana.h"
+#include "gmx_fatal.h"
+
typedef struct {
atom_id i;
real d2;
#include <config.h>
#endif
-
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-
-
#include "gromacs/commandline/pargs.h"
#include "typedefs.h"
#include "types/commrec.h"
#include "gromacs/timing/walltime_accounting.h"
#include "gromacs/math/utilities.h"
+#include "gmx_fatal.h"
/* Enum for situations that can occur during log file parsing, the
* corresponding string entries can be found in do_the_tests() in
#include "gromacs/utility/cstringutil.h"
#include "xvgr.h"
+#include "gmx_fatal.h"
+
//! longest file names allowed in input files
#define WHAM_MAXFILELEN 2048
#include "gromacs/utility/smalloc.h"
#include "bondf.h"
+#include "gmx_fatal.h"
+
real ellipticity(int nres, t_bb bb[])
{
typedef struct {
#include "gromacs/fileio/futil.h"
#include "gromacs/fileio/strdb.h"
+#include "gmx_fatal.h"
#include "gromacs/utility/gmxomp.h"
void check_binwidth(real binwidth)
#include "vec.h"
#include "physics.h"
+#include "gmx_fatal.h"
+
#define xAI xa[0]
#define xAJ xa[1]
#define xAK xa[2]
#include "gromacs/fileio/xdrf.h"
#include "gromacs/fileio/xdr_datatype.h"
#include "gromacs/utility/baseversion.h"
+#include "gmx_fatal.h"
#include "buildinfo.h"
#include <math.h>
#include "macros.h"
#include "vec.h"
-#include "gmx_fatal.h"
#include "pbc.h"
static real dist2(t_pbc *pbc, rvec x, rvec y)
#include <stdlib.h>
-#include "gmx_fatal.h"
#include "gromacs/utility/smalloc.h"
#include "typedefs.h"
#include "cudautils.cuh"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <stdlib.h>
-#include "gmx_fatal.h"
-
#include "cudautils.cuh"
#include "pmalloc_cuda.h"
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#include "gmx_fatal.h"
+#include "gmx_fatal_collective.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "main.h"
#include "types/commrec.h"
#include "network.h"
-#include "gmx_fatal.h"
#include "copyrite.h"
#include "macros.h"
-#include "gromacs/utility/cstringutil.h"
-#include "gromacs/utility/smalloc.h"
#include "gromacs/fileio/futil.h"
#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/smalloc.h"
static gmx_bool bDebug = FALSE;
-static char *fatal_tmp_file = NULL;
static FILE *log_file = NULL;
static tMPI_Thread_mutex_t debug_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
static tMPI_Thread_mutex_t where_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-static tMPI_Thread_mutex_t fatal_tmp_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-
gmx_bool bDebugMode(void)
{
tMPI_Thread_mutex_unlock(&debug_mutex);
}
-void _set_fatal_tmp_file(const char *fn, const char *file, int line)
-{
- tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
- if (fatal_tmp_file == NULL)
- {
- fatal_tmp_file = strdup(fn);
- }
- else
- {
- fprintf(stderr, "BUGWARNING: fatal_tmp_file already set at %s:%d",
- file, line);
- }
- tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
-}
-
-void _unset_fatal_tmp_file(const char *fn, const char *file, int line)
-{
- tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
- if (strcmp(fn, fatal_tmp_file) == 0)
- {
- sfree(fatal_tmp_file);
- fatal_tmp_file = NULL;
- }
- else
- {
- fprintf(stderr, "BUGWARNING: file %s not set as fatal_tmp_file at %s:%d",
- fn, file, line);
- }
- tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
-}
-
-static void clean_fatal_tmp_file()
-{
- tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
- if (fatal_tmp_file)
- {
- fprintf(stderr, "Cleaning up temporary file %s\n", fatal_tmp_file);
- remove(fatal_tmp_file);
- sfree(fatal_tmp_file);
- fatal_tmp_file = NULL;
- }
- tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
-}
-
void gmx_fatal(int f_errno, const char *file, int line, const char *fmt, ...)
{
va_list ap;
char msg[STRLEN];
- clean_fatal_tmp_file();
-
va_start(ap, fmt);
vsprintf(msg, fmt, ap);
va_end(ap);
if ((cr != NULL && MASTER(cr) ) ||
(dd != NULL && DDMASTER(dd)))
{
- clean_fatal_tmp_file();
-
va_start(ap, fmt);
vsprintf(msg, fmt, ap);
va_end(ap);
exit(fatal_errno);
}
-void _invalid_case(const char *fn, int line)
-{
- gmx_fatal(FARGS, "Invalid case in switch statement, file %s, line %d",
- fn, line);
-}
-
-void _unexpected_eof(const char *fn, int line, const char *srcfn, int srcline)
-{
- gmx_fatal(FARGS, "Unexpected end of file in file %s at line %d\n"
- "(Source file %s, line %d)", fn, line, srcfn, srcline);
-}
-
/*
* These files are global variables in the gromacs preprocessor
* Every routine in a file that includes gmx_fatal.h can write to these
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <assert.h>
#include <stdio.h>
+#include "thread_mpi/threads.h"
+
#include "typedefs.h"
#include "types/commrec.h"
#include "types/hw_info.h"
#include "md_logging.h"
#include "gmx_thread_affinity.h"
-#include "thread_mpi/threads.h"
+#include "gmx_fatal.h"
#include "gromacs/utility/gmxomp.h"
static int
#include "gromacs/fileio/futil.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/strdb.h"
+#include "gmx_fatal.h"
const char gmx_residuetype_undefined[] = "Other";
#include "macros.h"
#include "nb_free_energy.h"
+#include "gmx_fatal.h"
+
void
gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist,
rvec * gmx_restrict xx,
#include "nb_generic.h"
#include "nrnb.h"
+#include "gmx_fatal.h"
+
#include "nonbonded.h"
#include "nb_kernel.h"
-
void
gmx_nb_generic_kernel(t_nblist * nlist,
rvec * xx,
#include "nb_generic_adress.h"
#include "nrnb.h"
+#include "gmx_fatal.h"
+
#include "nonbonded.h"
#include "nb_kernel.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "nb_kernel.h"
#include "nrnb.h"
+#include "gmx_fatal.h"
+
void
gmx_nb_generic_cg_kernel(t_nblist * nlist,
rvec * xx,
#include <string.h>
#include "types/commrec.h"
#include "sysstuff.h"
-#include "gmx_fatal.h"
#include "names.h"
#include "macros.h"
#include "nrnb.h"
#include "gromacs/linearalgebra/nrjac.h"
#include "gromacs/math/do_fit.h"
+#include "gmx_fatal.h"
void init_orires(FILE *fplog, const gmx_mtop_t *mtop,
rvec xref[],
#include "ns.h"
#include "macros.h"
#include "names.h"
-#include "gmx_fatal.h"
#include "mshift.h"
#include "main.h"
#include "disre.h"
#include "sysstuff.h"
#include "typedefs.h"
-#include "gromacs/utility/smalloc.h"
#include "mshift.h"
#include "pbc.h"
#include "rmpbc.h"
#include "vec.h"
#include "gromacs/fileio/futil.h"
+#include "gmx_fatal.h"
+#include "gromacs/utility/smalloc.h"
typedef struct {
int natoms;
/* This file is completely threadsafe - please keep it that way! */
#include <stdio.h>
-#include "gromacs/utility/smalloc.h"
#include "typedefs.h"
#include "types/commrec.h"
#include "names.h"
#include "vec.h"
#include "macros.h"
+#include "gmx_fatal.h"
+#include "gromacs/utility/smalloc.h"
int pr_indent(FILE *fp, int n)
{
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/utility/exceptions.h"
+#include "gmx_fatal.h"
#include "gromacs/utility/programcontext.h"
gmx_bool output_env_get_print_xvgr_codes(const output_env_t oenv)
#include <config.h>
#endif
-#include "gromacs/utility/cstringutil.h"
-#include <stdio.h>
#include <math.h>
+#include <stdio.h>
#include <string.h>
+
+#include "gromacs/utility/cstringutil.h"
#include "gen_vsite.h"
#include "gromacs/utility/smalloc.h"
#include "resall.h"
#include "fflibutil.h"
#include "macros.h"
+#include "gmx_fatal.h"
+
#define MAXNAME 32
#define OPENDIR '[' /* starting sign for directive */
#define CLOSEDIR ']' /* ending sign for directive */
#include "sortwater.h"
#include "gromacs/fileio/trxio.h"
+#include "gmx_fatal.h"
+
static void rand_rot(int natoms, rvec x[], rvec v[], vec4 xrot[], vec4 vrot[],
gmx_rng_t rng, rvec max_rot)
{
#include "gromacs/utility/cstringutil.h"
#include "macros.h"
+#include "gmx_fatal.h"
+
static int in_strings(char *key, int nstr, const char **str)
{
int j;
#include "nm2type.h"
+#include "gmx_fatal.h"
+
static void rd_nm2type_file(const char *fn, int *nnm, t_nm2type **nmp)
{
FILE *fp;
#include "vec.h"
#include "hackblock.h"
+#include "gmx_fatal.h"
+
int gmx_protonate(int argc, char *argv[])
{
const char *desc[] = {
#include "gromacs/fileio/trnio.h"
#include "txtdump.h"
+#include "gmx_fatal.h"
+
static char *RotStr = {"Enforced rotation:"};
}
default:
fprintf (stderr, "case: %d\n", d);
- invalid_case();
+ gmx_incons("unknown directive");
}
}
}
#include "vec.h"
#include "atomprop.h"
#include "hackblock.h"
-
#include "nm2type.h"
+#include "gmx_fatal.h"
+
char atp[7] = "HCNOSX";
#define NATP (asize(atp)-1)
#endif
+#include <string.h>
+
+#ifdef GMX_NATIVE_WINDOWS
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
#include "imd.h"
#include "imdsocket.h"
#include "gromacs/utility/smalloc.h"
#include "names.h"
#include "gromacs/timing/wallcycle.h"
-#include <string.h>
-
-#ifdef GMX_NATIVE_WINDOWS
-#include <Windows.h>
-#else
-#include <unistd.h>
-#endif
+#include "gmx_fatal.h"
/*! \brief How long shall we wait in seconds until we check for a connection again? */
#define IMDLOOPWAIT 1
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-
+/*! \file
+ * \brief
+ * Declares fatal error handling and debugging routines for C code.
+ *
+ * \inpublicapi
+ */
#ifndef _fatal_h
#define _fatal_h
#include <stdio.h>
-#include <stdarg.h>
-#include <errno.h>
+
#include "types/simple.h"
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef __has_feature // Optional.
-#define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#ifndef __has_feature
+/** For compatibility with non-clang compilers. */
+#define __has_feature(x) 0
#endif
-/* This documentation block seems to produce warnings with some Doxygen
- * versions, so it's disabled for now. Maybe because the file itself
- * is not documented. */
-/* \def GMX_ATTRIBUTE_NORETURN
+/*! \def GMX_ATTRIBUTE_NORETURN
* \brief
* Indicate that a function is not expected to return.
*
- * WARNING: In general this flag should not be used for compiler
- * optimizations, since set_gmx_error_handler can be set to a
- * handler which does not quit.
+ * \todo
+ * There are functions outside this header that need the same attribute.
+ * This could be moved to a generic header and made it affect also compiler
+ * code generation.
*/
#ifndef GMX_ATTRIBUTE_NORETURN
#if __has_feature(attribute_analyzer_noreturn)
#endif
#endif
+/** Implementation for where(). */
void
_where(const char *file, int line);
+/** Prints filename and line to stdlog. */
#define where() _where(__FILE__, __LINE__)
-/* Prints filename and line to stdlog and only on amba memvail */
-
-void
-_set_fatal_tmp_file(const char *fn, const char *file, int line);
-#define set_fatal_tmp_file(fn) _set_fatal_tmp_file(fn, __FILE__, __LINE__)
-/* set filename to be removed when fatal_error is called */
-
-void
-_unset_fatal_tmp_file(const char *fn, const char *file, int line);
-#define unset_fatal_tmp_file(fn) _unset_fatal_tmp_file(fn, __FILE__, __LINE__)
-/* unsets filename to be removed */
-void
-gmx_fatal(int fatal_errno, const char *file, int line, const char *fmt, ...) GMX_ATTRIBUTE_NORETURN;
-#define FARGS 0, __FILE__, __LINE__
-/*
- * Routine gmx_fatal prints
- *
- * "fatal error file %s line %s \n\t "
+/*! \brief
+ * Fatal error reporting routine for \Gromacs.
*
- * followed by the string specified by fmt and supplied parameters. If
- * errno is 0, only the message and arguments are printed. If errno is
- * a legal system errno or -1, a perror like message is printed after the
- * first message, if errno is -1, the last system errno will be used.
- * The format of fmt is that like printf etc, only %d, %x, %c, %f, %g and %s
- * are allowed as format specifiers.
+ * This function prints a fatal error message with a header that contains the
+ * source file and line number of the call, followed by the string specified by
+ * \p fmt and supplied parameters.
+ * If \p fatal_errno is 0, only the message and arguments are printed.
+ * If \p fatal_errno is a legal system errno or -1, a perror()-like message is
+ * printed after the first message; if fatal_errno is -1, the last system errno
+ * will be used.
+ * The format of \p fmt uses printf()-like formatting.
*
* In case all MPI processes want to stop with the same fatal error,
- * use gmx_fatal_collective, declared in gmx_fatal_collective.h,
+ * use gmx_fatal_collective(), declared in gmx_fatal_collective.h,
* to avoid having as many error messages as processes.
*
- * Tip of the week:
- * call this function using the FARGS macro:
- * gmx_fatal(FARGS,fmt,...)
- *
+ * The first three parameters can be provided through ::FARGS:
+ * \code
+ gmx_fatal(FARGS, fmt, ...);
+ \endcode
*/
-
void
-gmx_fatal_set_log_file(FILE *fp);
-/* Set the log file for printing error messages */
+gmx_fatal(int fatal_errno, const char *file, int line, const char *fmt, ...) GMX_ATTRIBUTE_NORETURN;
+/** Helper macro to pass first three parameters to gmx_fatal(). */
+#define FARGS 0, __FILE__, __LINE__
+/** Sets the log file for printing error messages. */
void
-_invalid_case(const char *fn, int line);
-#define invalid_case() _invalid_case(__FILE__, __LINE__)
-/* Issue a warning stating 'Invalid case in switch' */
-
-void _unexpected_eof(const char *fn, int line, const char *srcfn, int srcline);
-#define unexpected_eof(fn, line) _unexpected_eof(fn, line, __FILE__, __LINE__)
+gmx_fatal_set_log_file(FILE *fp);
-/*
- * Functions can write to this file for debug info
- * Before writing to it, it should be checked whether
- * the file is not NULL:
- * if (debug) fprintf(debug,"%s","Hallo");
+/*! \brief
+ * Debug log file.
+ *
+ * Functions can write to this file for debug info.
+ * Before writing to it, it should be checked whether the file is not NULL:
+ * \code
+ if (debug)
+ {
+ fprintf(debug, "%s", "Debug text");
+ }
+ \endcode
*/
extern FILE *debug;
+/** Whether extra debugging is enabled. */
extern gmx_bool gmx_debug_at;
-void init_debug (const int dbglevel, const char *dbgfile);
+/** Initializes debugging variables */
+void init_debug(const int dbglevel, const char *dbgfile);
+/** Returns TRUE when the program was started in debug mode */
gmx_bool bDebugMode(void);
-/* Return TRUE when the program was started in debug mode */
#if (defined __sgi && defined USE_SGI_FPE)
+/** Sets exception handlers for debugging */
void doexceptions(void);
-/* Set exception handlers for debugging */
#endif
-/* warn_str is allowed to be NULL.
+/*! \brief
+ * Implementation for range_check() and range_check_mesg().
+ *
+ * \p warn_str can be NULL.
*/
void _range_check(int n, int n_min, int n_max, const char *warn_str,
const char *var,
const char *file, int line);
-#define range_check_mesg(n, n_min, n_max, str) _range_check(n, n_min, n_max, str,#n, __FILE__, __LINE__)
-/* Range check will terminate with an error message if not
- * n E [ n_min, n_max >
- * That is n_min is inclusive but not n_max.
+/*! \brief
+ * Checks that a variable is within a range.
+ *
+ * If \p n is not in range [n_min, n_max), a fatal error is raised.
+ * \p n_min is inclusive, but \p n_max is not.
*/
+#define range_check_mesg(n, n_min, n_max, str) _range_check(n, n_min, n_max, str,#n, __FILE__, __LINE__)
-#define range_check(n, n_min, n_max) _range_check(n, n_min, n_max, NULL,#n, __FILE__, __LINE__)
-/* Range check will terminate with an error message if not
- * n E [ n_min, n_max >
- * That is n_min is inclusive but not n_max.
+/*! \brief
+ * Checks that a variable is within a range.
+ *
+ * This works as range_check_mesg(), but with a default error message.
*/
+#define range_check(n, n_min, n_max) _range_check(n, n_min, n_max, NULL,#n, __FILE__, __LINE__)
-char *gmx_strerror(const char *key);
-/* Return error message corresponding to the key.
- * Maybe a multi-line message.
- * The messages are stored in src/gmxlib/fatal.c
+/*! \brief
+ * Returns error message corresponding to a string key.
+ *
+ * This maps the strings used by gmx_error() to actual error messages.
+ * Caller is responsible of freeing the returned string.
*/
+char *gmx_strerror(const char *key);
+/** Implementation for gmx_error(). */
void _gmx_error(const char *key, const char *msg, const char *file, int line) GMX_ATTRIBUTE_NORETURN;
-#define gmx_error(key, msg) _gmx_error(key, msg, __FILE__, __LINE__)
-/* Error msg of type key is generated and the program is
- * terminated unless and error handle is set (see below)
+/*! \brief
+ * Alternative fatal error routine with canned messages.
+ *
+ * This works as gmx_fatal(), except that a generic error message is added
+ * based on a string key, and printf-style formatting is not supported.
+ * Should not typically be called directly, but through gmx_bug(), gmx_call()
+ * etc.
*/
+#define gmx_error(key, msg) _gmx_error(key, msg, __FILE__, __LINE__)
-/* Some common error types */
+/*! \name Fatal error routines for certain types of errors
+ *
+ * These wrap gmx_error() and provide the \p key parameter as one of the
+ * recognized strings.
+ */
+/*! \{ */
#define gmx_bug(msg) gmx_error("bug", msg)
#define gmx_call(msg) gmx_error("call", msg)
#define gmx_comm(msg) gmx_error("comm", msg)
#define gmx_input(msg) gmx_error("input", msg)
#define gmx_mem(msg) gmx_error("mem", msg)
#define gmx_open(fn) gmx_error("open", fn)
+/*! \} */
+/*! \brief
+ * Sets an error handler for gmx_fatal() and other fatal error routines.
+ *
+ * The default handler prints the message and aborts the program.
+ * If you set a custom handler, it must also abort the program, otherwise
+ * \Gromacs will behave unpredictably (most likely, it crashes shortly after
+ * the fatal error).
+ * The string passed to the handler may be a multi-line string.
+ *
+ * \see gmx_fatal()
+ */
void
set_gmx_error_handler(void (*func)(const char *msg));
-/* An error function will be called that terminates the program
- * with a fatal error, unless you override it with another function.
- * i.e.:
- * set_gmx_error_handler(my_func);
- * where my_func is a function that takes a string as an argument.
- * The string may be a multi-line string.
- */
-void gmx_warning(const char *fmt, ...);
-/* Print a warning message to stderr.
- * The format of fmt is that like printf etc, only %d, %x, %c, %f, %g and %s
- * are allowed as format specifiers.
+/*! \brief
+ * Prints a warning message to stderr.
+ *
+ * The format of \p fmt uses printf()-like formatting.
* The message string should NOT start with "WARNING"
* and should NOT end with a newline.
*/
-
+void gmx_warning(const char *fmt, ...);
#ifdef __cplusplus
}
#endif
-#endif /* _fatal_h */
+#endif
#include "pbc.h"
#include "vec.h"
+#include "gmx_fatal.h"
+
#define N 4
void m4_op(mat4 m, rvec x, vec4 v)
#include "typedefs.h"
#include "vec.h"
#include "txtdump.h"
-#include "gromacs/utility/smalloc.h"
#include "gromacs/linearalgebra/nrjac.h"
+#include "gmx_fatal.h"
+#include "gromacs/utility/smalloc.h"
real calc_similar_ind(gmx_bool bRho, int nind, atom_id *index, real mass[],
rvec x[], rvec xp[])
#include "typedefs.h"
#include "vec.h"
+#include "gmx_fatal.h"
+
real
adress_weight(rvec x,
int adresstype,
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <stdio.h>
#include <stdlib.h>
+
#include "typedefs.h"
#include "network.h"
#include "vec.h"
-#include "gmx_fatal.h"
#include "physics.h"
#include "main.h"
#include "calcmu.h"
#include "gmx_omp_nthreads.h"
#include "gromacs/fileio/gmxfio.h"
+#include "gmx_fatal.h"
#include "gromacs/utility/gmxomp.h"
typedef struct {
#include "gromacs/essentialdynamics/edsam.h"
#include "gromacs/pulling/pull.h"
+#include "gmx_fatal.h"
typedef struct gmx_constr {
int ncon_tot; /* The total number of constraints */
#include "nsgrid.h"
#include "network.h"
+#include "gmx_fatal.h"
+
static void calc_cgcm_av_stddev(t_block *cgs, int n, rvec *x, rvec av, rvec stddev,
t_commrec *cr_sum)
{
#include "gmx_omp_nthreads.h"
#include "macros.h"
+#include "gmx_fatal.h"
+
typedef struct {
int nsend;
int *a;
#include "force.h"
#include "gmx_omp_nthreads.h"
+#include "gmx_fatal.h"
+
/* for dd_init_local_state */
#define NITEM_DD_INIT_LOCAL_STATE 5
#include "gromacs/fileio/trnio.h"
#include "gromacs/fileio/xtcio.h"
#include "gromacs/timing/wallcycle.h"
+#include "gmx_fatal.h"
#include "gromacs/utility/gmxmpi.h"
static void init_df_history_weights(df_history_t *dfhist, t_expanded *expand, int nlim)
#include "gmx_omp_nthreads.h"
#include "gromacs/timing/wallcycle.h"
+#include "gmx_fatal.h"
void ns(FILE *fp,
t_forcerec *fr,
#include "gromacs/utility/smalloc.h"
#include "macros.h"
#include "gmx_fatal.h"
-#include "gmx_fatal_collective.h"
#include "physics.h"
#include "force.h"
#include "tables.h"
#include "gmx_detect_hardware.h"
#include "inputrec.h"
-#ifdef _MSC_VER
-/* MSVC definition for __cpuid() */
-#include <intrin.h>
-#endif
-
#include "types/nbnxn_cuda_types_ext.h"
#include "gpu_utils.h"
#include "nbnxn_cuda_data_mgmt.h"
#include <config.h>
#endif
+#include <assert.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
-#include <assert.h>
#include <cuda.h>
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gromacs/utility/smalloc.h"
#include "macros.h"
#include "xutil.h"
-#include "gmx_fatal.h"
#include "buttons.h"
#include "manager.h"
#include "nmol.h"