Clean up gmx_fatal.*
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 4 Apr 2014 04:02:25 +0000 (07:02 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Fri, 4 Apr 2014 17:29:52 +0000 (20:29 +0300)
- 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

92 files changed:
src/gromacs/essentialdynamics/edsam.c
src/gromacs/fileio/confio.c
src/gromacs/fileio/gmxfio_bin.c
src/gromacs/fileio/gmxfio_rw.c
src/gromacs/fileio/libxdrf.c
src/gromacs/fileio/mdoutf.c
src/gromacs/fileio/pdbio.c
src/gromacs/fileio/trxio.c
src/gromacs/gmxana/anadih.c
src/gromacs/gmxana/expfit.c
src/gromacs/gmxana/fitahx.c
src/gromacs/gmxana/geminate.c
src/gromacs/gmxana/gmx_bundle.c
src/gromacs/gmxana/gmx_cluster.c
src/gromacs/gmxana/gmx_clustsize.c
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxana/gmx_current.c
src/gromacs/gmxana/gmx_density.c
src/gromacs/gmxana/gmx_densmap.c
src/gromacs/gmxana/gmx_densorder.cpp
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_disre.c
src/gromacs/gmxana/gmx_dyecoupl.c
src/gromacs/gmxana/gmx_editconf.c
src/gromacs/gmxana/gmx_gyrate.c
src/gromacs/gmxana/gmx_h2order.c
src/gromacs/gmxana/gmx_hydorder.c
src/gromacs/gmxana/gmx_lie.c
src/gromacs/gmxana/gmx_make_ndx.c
src/gromacs/gmxana/gmx_msd.c
src/gromacs/gmxana/gmx_order.c
src/gromacs/gmxana/gmx_pme_error.cpp
src/gromacs/gmxana/gmx_polystat.c
src/gromacs/gmxana/gmx_potential.c
src/gromacs/gmxana/gmx_rdf.c
src/gromacs/gmxana/gmx_rmsf.c
src/gromacs/gmxana/gmx_saltbr.c
src/gromacs/gmxana/gmx_sans.c
src/gromacs/gmxana/gmx_sigeps.c
src/gromacs/gmxana/gmx_sorient.c
src/gromacs/gmxana/gmx_spol.c
src/gromacs/gmxana/gmx_traj.c
src/gromacs/gmxana/gmx_trjcat.c
src/gromacs/gmxana/gmx_trjconv.c
src/gromacs/gmxana/gmx_trjorder.c
src/gromacs/gmxana/gmx_tune_pme.c
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/hxprops.c
src/gromacs/gmxana/nsfactor.c
src/gromacs/gmxlib/calch.c
src/gromacs/gmxlib/checkpoint.c
src/gromacs/gmxlib/conformation-utilities.c
src/gromacs/gmxlib/cuda_tools/cudautils.cu
src/gromacs/gmxlib/cuda_tools/pmalloc_cuda.cu
src/gromacs/gmxlib/gmx_fatal.c
src/gromacs/gmxlib/gmx_thread_affinity.c
src/gromacs/gmxlib/index.c
src/gromacs/gmxlib/nonbonded/nb_free_energy.c
src/gromacs/gmxlib/nonbonded/nb_generic.c
src/gromacs/gmxlib/nonbonded/nb_generic_adress.c
src/gromacs/gmxlib/nonbonded/nb_generic_cg.c
src/gromacs/gmxlib/nrnb.c
src/gromacs/gmxlib/orires.c
src/gromacs/gmxlib/restcbt.c
src/gromacs/gmxlib/rmpbc.c
src/gromacs/gmxlib/txtdump.c
src/gromacs/gmxlib/xvgr.cpp
src/gromacs/gmxpreprocess/gen_vsite.c
src/gromacs/gmxpreprocess/genconf.c
src/gromacs/gmxpreprocess/hizzie.c
src/gromacs/gmxpreprocess/nm2type.c
src/gromacs/gmxpreprocess/protonate.c
src/gromacs/gmxpreprocess/readrot.c
src/gromacs/gmxpreprocess/topio.c
src/gromacs/gmxpreprocess/x2top.c
src/gromacs/imd/imd.c
src/gromacs/legacyheaders/gmx_fatal.h
src/gromacs/math/3dview.c
src/gromacs/math/do_fit.c
src/gromacs/mdlib/adress.c
src/gromacs/mdlib/calcmu.c
src/gromacs/mdlib/clincs.c
src/gromacs/mdlib/constr.c
src/gromacs/mdlib/domdec_box.c
src/gromacs/mdlib/domdec_con.c
src/gromacs/mdlib/domdec_top.c
src/gromacs/mdlib/expanded.c
src/gromacs/mdlib/force.c
src/gromacs/mdlib/forcerec.c
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_data_mgmt.cu
src/gromacs/utility/smalloc.c
src/programs/view/molps.cpp

index 286969ef0c110181b12e15431dcafea120f5a40f..8c63fdf3514a7649aa0a61b471b0555a4681055c 100644 (file)
@@ -49,7 +49,6 @@
 #include "gromacs/fileio/confio.h"
 #include "txtdump.h"
 #include "vec.h"
-#include <time.h>
 #include "nrnb.h"
 #include "mshift.h"
 #include "mdrun.h"
@@ -62,6 +61,7 @@
 #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))
index 4b8ba54184e584a75d46312ffc25e183e6b8da3b..9033b326a8a0c51c1c1a662c82a9773078e64815 100644 (file)
@@ -957,7 +957,8 @@ static gmx_bool get_w_conf(FILE *in, const char *infile, char *title,
     {
         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)
         {
index 0cb819533effae6c8cc22cedb5140e908092d1e0..7cc1c559386046c3b9b4ef3d5067d56f6c41527b 100644 (file)
@@ -45,7 +45,6 @@
 #include <io.h>
 #endif
 
-#include "gmx_fatal.h"
 #include "macros.h"
 #include "gromacs/utility/smalloc.h"
 #include "futil.h"
index 9705486a20ed3dbfc2a77b0a6a9c5f1267987dc8..e1b7031ed3f6f6b2ede3595a4e3b4951f6ac5445 100644 (file)
@@ -44,7 +44,6 @@
 #include <io.h>
 #endif
 
-#include "gmx_fatal.h"
 #include "macros.h"
 #include "gromacs/utility/smalloc.h"
 #include "futil.h"
index ae117034f042461a17d561efcc6b7fd23625e0b8..219e64ead90b2e339e186640d2250d39b820eaa5 100644 (file)
 #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
index bcbf75b11456e2d963db0db381419405c587bc8f..4b50c2a6c08302a9646fa1a96852a4769a4704e9 100644 (file)
@@ -46,6 +46,7 @@
 #include "checkpoint.h"
 #include "copyrite.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 #include "gromacs/utility/smalloc.h"
 
 struct gmx_mdoutf {
index dcfc1ae07d34c373d2c92499dc2a3b4f3e573284..16fa4a23dba0b04afd903b9d02e6520116a5ea18 100644 (file)
@@ -56,6 +56,8 @@
 #include "pbc.h"
 #include "gmxfio.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
 typedef struct {
     int ai, aj;
 } gmx_conection_t;
index 065bad2445ad1c9e40a5b3800a6300ebda72a3d3..25d3dd1fa4f57088401873eb716e39251bf9f23b 100644 (file)
@@ -66,6 +66,7 @@
 #include "xdrf.h"
 
 #include "gromacs/fileio/timecontrol.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 /* defines for frame counter output */
 #define SKIP1   10
index 72a027183ed0fadc664864326b4710a4c8eef1df..a9d28823e8d8af3d6cfd1a4054d8ae3191ef7f65 100644 (file)
@@ -53,6 +53,8 @@
 #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[])
index 6c2d0caf9e7944954713c9e519652ad38458c8cf..406f5a36b184476784bb2ce3aba394b7d16d8f18 100644 (file)
@@ -49,6 +49,8 @@
 #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] = {
index 96b0376bed0418a5a56709a36c91201ad1438e87..7ee4bf867cb51ed0ac2df7b43e14c9dbd5bf01e2 100644 (file)
 
 #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)
 {
index bfb7153fbead5534358b41dedcaf6f9377ac40a9..79dc949fd34513b316c3684b7de219dde6fb8751 100644 (file)
@@ -42,6 +42,7 @@
 #include "vec.h"
 #include "geminate.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 #include "gromacs/utility/gmxomp.h"
 
 static void missing_code_message()
index 7f839f74613050d66badabbf38b67cb3d6564e62..263ed985e4c7f30acafff0542b98f696ec0c68da 100644 (file)
@@ -55,6 +55,7 @@
 #include "physics.h"
 #include "gmx_ana.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 #define MAX_ENDS 3
 
index 2b144ec75171558a3c25db2e97b2d06c751429d8..1e5a9e6d5a96f092eb579d24b147657a9e2c65be 100644 (file)
@@ -64,6 +64,7 @@
 
 #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
index 8a33f5e4523dc199819752b30853f110bed7ba0d..d84c79c2d82050fd6f2605cb30371ed03228d608 100644 (file)
@@ -63,6 +63,7 @@
 #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,
index 78f9f536a52b6609a87a3701a39b1fc9b1d72d42..501597e9acb7addff70ca18cbb79a2a8eb22395d 100644 (file)
@@ -70,6 +70,7 @@
 
 #include "gromacs/linearalgebra/eigensolver.h"
 #include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 int gmx_covar(int argc, char *argv[])
 {
index 030b4e7451d541a92cda40f7a4844891b7beea11..c706b40be5b1c35159b77c012b2c4ca38f57ba81 100644 (file)
 #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;
index 3c22d3bbf70efeb08e94c59bd3c840cab91976b8..a6b89c7b05e074c228e6e87e16d2198365bc5b50 100644 (file)
@@ -59,6 +59,8 @@
 #include "gmx_ana.h"
 #include "macros.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
 typedef struct {
     char *atomname;
     int   nr_el;
index 7a885a72e79ae69c37cfe81ee480b601111cbb3a..8675a164358a603785d9e9a8ea62142a87c59c8e 100644 (file)
@@ -62,6 +62,7 @@
 #include "pbc.h"
 #include "gmx_ana.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 int gmx_densmap(int argc, char *argv[])
 {
index 47962e8b804444517fd0abb4430b3d36ddf5bbb6..16f98c0c035d9847f0415367981008f04c0803d1 100644 (file)
@@ -63,6 +63,7 @@
 #include "copyrite.h"
 
 #include "gromacs/utility/exceptions.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
 #include "gromacs/utility/programcontext.h"
 
 #ifdef GMX_DOUBLE
index f1f6dc4aa8dcf0010257630978f924a62743c932..11c2328b6c884522b376f2175cd5b7f3b1f206b3 100644 (file)
@@ -67,6 +67,7 @@
 
 #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)
index 92a56928837fd5d60d6650a4be3c73e3c600da5d..eb41e318998920a109c8c1f9b59103afc72e481a 100644 (file)
@@ -65,6 +65,7 @@
 #include "gmx_ana.h"
 
 #include "gromacs/math/do_fit.h"
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 typedef struct {
     int  n;
index 6542966e5434e03b4ac44edd0bcf17c68f0c43d5..5eebeb12320eae0bac99a2ff48b77554efdd08dc 100644 (file)
@@ -42,6 +42,7 @@
 #include "xvgr.h"
 #include "gromacs/fileio/trxio.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 int gmx_dyecoupl(int argc, char *argv[])
 {
index c0836aa442db80f24ceef005fb4d2af59d61e799..28adc9e5a2f4a6f1c706b6b74f8255f0087f7ef9 100644 (file)
@@ -63,6 +63,8 @@
 #include "rmpbc.h"
 #include "gmx_ana.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
 typedef struct
 {
     char sanm[12];
index 42b54847719e7b3ede252a0f9a161550b5df71f1..9ffb8f10512e19797b723fdba28223980fbfcbbd 100644 (file)
@@ -60,6 +60,7 @@
 #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)
index f73644f4ff3422fc495e784bd4a8a2c03aec8f98..697fb54d7c9041e5e1b94e3825f49c438f1edb69 100644 (file)
@@ -56,6 +56,7 @@
 #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 */
index a0e179ab6aa4a1fb68d37e7d0f81f402d655773c..d9bbed9bada1b394ae047064d232bd3b46148ffb 100644 (file)
@@ -57,6 +57,8 @@
 #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)
index a8279ef8f382b24d5b1aa5b24d0c86c7054edf7a..3e29541e9eeda3cb426f9ed9e196542b02827d22 100644 (file)
@@ -48,7 +48,6 @@
 #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"
@@ -58,7 +57,6 @@
 #include "gmx_ana.h"
 #include "gromacs/fileio/trxio.h"
 
-
 typedef struct {
     int  nlj, nqq;
     int *lj;
index 8126bf828fb487c287868299a13eb8db89080f79..7c8f276f9721ecae0c9e9e40e942dfeaf27de03e 100644 (file)
@@ -53,6 +53,8 @@
 #include "vec.h"
 #include "index.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
+
 #define MAXNAMES 30
 #define NAME_LEN 30
 
index 26dcabd24ac9edc3de4d86b6c697f939aa5990a7..d73f262606000225400d80864de904f7c1171ba2 100644 (file)
@@ -59,6 +59,7 @@
 #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
index d1bb842d4a3b22cd1fb651d39edbfc3f73eadbb9..98dd1865990695ba0fadb60397112ce05d23e4a4 100644 (file)
@@ -58,6 +58,7 @@
 #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 */
index 7db07ee9109ddf3168a89837bd38ae4d8a25ec52..3d4766ca1a3db311715affc5404faab1699e5c6c 100644 (file)
@@ -54,6 +54,8 @@
 #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))
index b9bbcffbe992cd415bc7d2b39cade2261340932f..41d9eaf07761fa8c5b28fd20737bfab499b95bfb 100644 (file)
@@ -49,7 +49,6 @@
 #include "vec.h"
 #include "index.h"
 #include "macros.h"
-#include "gmx_fatal.h"
 #include "xvgr.h"
 #include "rmpbc.h"
 #include "gromacs/fileio/tpxio.h"
index 00e99a09d2ea1bafb8881201f288b70b795a8de0..29fa31584bbb98ccb8df4ab23f7bb44eb72243b4 100644 (file)
@@ -58,6 +58,8 @@
 #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
 
index 579cd2728946ce6d86122245e22e912b7db9c963..22234f91cc6485c0009d21c452408c60b2c9d672 100644 (file)
@@ -62,6 +62,8 @@
 #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] ||
index 399de70d06546e577162833bb3644a823614b3f6..97180622e4ad1935c6885fb79ad304f295a05e39 100644 (file)
@@ -50,7 +50,6 @@
 #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"
index 7c262e74cb34f228f966a95d13da74021d51a044..90c69cdf323dd38a2a31a001267792ce41ac2689 100644 (file)
@@ -54,6 +54,7 @@
 #include "xvgr.h"
 #include "gmx_ana.h"
 
+#include "gromacs/legacyheaders/gmx_fatal.h"
 
 typedef struct {
     char *label;
index b57e9f1a2e282f3ee3a49d764679bf58753cde2e..68904bcdca163d8e3b1b3f1eda7841fe5cacd7a5 100644 (file)
@@ -55,6 +55,7 @@
 #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[])
index 458e1271d934d96e3458e3cc723ee41480d3c646..c002ddeb76e330fce7da214bd86f6ffa2482bbc5 100644 (file)
@@ -40,9 +40,9 @@
 
 #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"
index 2ecd08ca92440813cf27d11e8caac36ad3b27f94..8ad45f3f3880112267b873f2ba884a7f70e3c874 100644 (file)
@@ -50,6 +50,7 @@
 #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)
index 3f1ab9d5b823405def2af9d1a05cf8529c7d71b0..b4734d79d50d597dca24575ee180c1596eb22b40 100644 (file)
@@ -51,6 +51,7 @@
 #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)
index a2de81721e2e89caeeb404df523f35736d7d45db..29f1bd49c329cd940e231d8f4181ddc5ae78e680 100644 (file)
@@ -59,6 +59,7 @@
 #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)
index 8ce1deea3d5ce3bd14ca282556b0b19e70ce61c7..629f221d0b6dc4ad02fb2d560860845d9e0587a6 100644 (file)
@@ -63,6 +63,8 @@
 #include "xvgr.h"
 #include "gmx_ana.h"
 
+#include "gmx_fatal.h"
+
 #define TIME_EXPLICIT 0
 #define TIME_CONTINUE 1
 #define TIME_LAST     2
index 8ddc50c37ba57214541d787f58a06e8daec98df5..48f4560bd1bf85f463caf40d36e8aa4c55c2e883 100644 (file)
@@ -66,6 +66,7 @@
 #include "gmx_ana.h"
 
 #include "gromacs/math/do_fit.h"
+#include "gmx_fatal.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
index d2d4d47039afdc012c9a144857e957c397743f78..6b357e1b801515098dcaab03cdb253c60cc5cc86 100644 (file)
@@ -58,6 +58,8 @@
 #include "gromacs/fileio/trxio.h"
 #include "gmx_ana.h"
 
+#include "gmx_fatal.h"
+
 typedef struct {
     atom_id i;
     real    d2;
index 7c267cbde2d6e8f1b5989efa50b0eb1cc08c0b14..b0a7fb80cbcdc24df146d71240dae02d579c831b 100644 (file)
 #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"
@@ -63,6 +60,7 @@
 #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
index 0cb6ce36584eb5e3a1bdd8b9314899b3d79d2708..6e63e7a5c0372dfb6035c40f218e61c87dbf5538 100644 (file)
@@ -65,6 +65,8 @@
 #include "gromacs/utility/cstringutil.h"
 #include "xvgr.h"
 
+#include "gmx_fatal.h"
+
 //! longest file names allowed in input files
 #define WHAM_MAXFILELEN 2048
 
index 99d636ede1bb0c8820de57be49ffc0c1d8178ba3..ee949e9c4db9ae5c2e7461181976ae7250e06882 100644 (file)
@@ -50,6 +50,8 @@
 #include "gromacs/utility/smalloc.h"
 #include "bondf.h"
 
+#include "gmx_fatal.h"
+
 real ellipticity(int nres, t_bb bb[])
 {
     typedef struct {
index dddd87b22632c6b67dbb1f30a38ab52f25198e9e..4b15a573c91f7ef6cec75ec8e0b59e7b66294e90 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "gromacs/fileio/futil.h"
 #include "gromacs/fileio/strdb.h"
+#include "gmx_fatal.h"
 #include "gromacs/utility/gmxomp.h"
 
 void check_binwidth(real binwidth)
index c52ba153c01c104f6548b90627f169e53e6d2dbd..397ab2dba87f198807e7fb6b4141b67e3ff8deb6 100644 (file)
@@ -44,6 +44,8 @@
 #include "vec.h"
 #include "physics.h"
 
+#include "gmx_fatal.h"
+
 #define xAI xa[0]
 #define xAJ xa[1]
 #define xAK xa[2]
index 3744392707db0d50dfcb4da579153633efd8a5cf..1dd000c09eb9573876d7cffe64693afd91e9864f 100644 (file)
@@ -77,6 +77,7 @@
 #include "gromacs/fileio/xdrf.h"
 #include "gromacs/fileio/xdr_datatype.h"
 #include "gromacs/utility/baseversion.h"
+#include "gmx_fatal.h"
 
 #include "buildinfo.h"
 
index 2682de6d80ae4ec28c69f4c9cc3f569b5d040214..b1e318522f945259161e46e04eed149e52643a75 100644 (file)
@@ -44,7 +44,6 @@
 #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)
index 7682148bae5ed275361c21896bc2d1971addf999..57a0e425e80144fadc8bd58767a8503514ed36ba 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <stdlib.h>
 
-#include "gmx_fatal.h"
 #include "gromacs/utility/smalloc.h"
 #include "typedefs.h"
 #include "cudautils.cuh"
index 2566f9c4184f71d4a1e6ab2959a0157d50bc7b25..8c6b2cb8d438f3d0a90d2b92a90c0342424866c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -35,8 +35,6 @@
 
 #include <stdlib.h>
 
-#include "gmx_fatal.h"
-
 #include "cudautils.cuh"
 #include "pmalloc_cuda.h"
 
index 6a9673dec3cef44bf2767e75751e1919af030ebc..8cbc4511304c0098a456b58d3eb067083ccb96e5 100644 (file)
@@ -34,6 +34,9 @@
  * 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)
 {
@@ -233,57 +232,11 @@ static void quit_gmx_noquit(const char *msg)
     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);
@@ -325,8 +278,6 @@ void gmx_fatal_collective(int f_errno, const char *file, int line,
     if ((cr != NULL && MASTER(cr)  ) ||
         (dd != NULL && DDMASTER(dd)))
     {
-        clean_fatal_tmp_file();
-
         va_start(ap, fmt);
         vsprintf(msg, fmt, ap);
         va_end(ap);
@@ -370,18 +321,6 @@ void gmx_fatal_collective(int f_errno, const char *file, int line,
     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
index f1f157b9aa8b5a2afdeed4bb0a03ae3571f483ab..9752fb0295c6c4066b9b8cb8c6ee6111c98fba28 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -45,6 +45,8 @@
 #include <assert.h>
 #include <stdio.h>
 
+#include "thread_mpi/threads.h"
+
 #include "typedefs.h"
 #include "types/commrec.h"
 #include "types/hw_info.h"
@@ -54,7 +56,7 @@
 #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
index 6a166bff1e85e32c050cfea5aaa11832a8e33b55..1ac6062a0b12652b029106200c1a2d3b8e91dd7f 100644 (file)
@@ -56,6 +56,7 @@
 #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";
 
index f09b0069ba637919e405a4577c404548dc6e6dbf..4ed5663833054212993d9d897eb59ac7bb0614d9 100644 (file)
@@ -48,6 +48,8 @@
 #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,
index bc58c7e6bb37a1dac289c9b471d02bfd33005c95..4f29311deaa61d044f465093dd9dd9c998e0639a 100644 (file)
 #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,
index 1eb690c7dff9af8cdc30b067566dd76cbe8d99a8..10b687b020b39713f5c25c59537ab4471dc798f5 100644 (file)
@@ -46,6 +46,8 @@
 #include "nb_generic_adress.h"
 #include "nrnb.h"
 
+#include "gmx_fatal.h"
+
 #include "nonbonded.h"
 #include "nb_kernel.h"
 
index f09dc0da9f616d0991df923a0117ad4c95336133..61198647eab34d78b89c3f6d1fee08a31bfa197a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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.
@@ -48,6 +48,8 @@
 #include "nb_kernel.h"
 #include "nrnb.h"
 
+#include "gmx_fatal.h"
+
 void
 gmx_nb_generic_cg_kernel(t_nblist *                nlist,
                          rvec *                    xx,
index 1d0143866ded176f1972c1a9131d2bc799c44ea5..d0d118d8d93297a9a932ae62f8e498b8b6b56c1c 100644 (file)
@@ -41,7 +41,6 @@
 #include <string.h>
 #include "types/commrec.h"
 #include "sysstuff.h"
-#include "gmx_fatal.h"
 #include "names.h"
 #include "macros.h"
 #include "nrnb.h"
index 11c970949fadd0e3e44e9b986e61ff8fe4dd90d4..da920db11dc0952780397f8a216dd9e60e9faf8d 100644 (file)
@@ -51,6 +51,7 @@
 
 #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[],
index 919d5ea42614216625a04a54d05da2eec4e5c7f0..e474ebb690eabb64e96a34bff271827fb484b2cf 100644 (file)
@@ -47,7 +47,6 @@
 #include "ns.h"
 #include "macros.h"
 #include "names.h"
-#include "gmx_fatal.h"
 #include "mshift.h"
 #include "main.h"
 #include "disre.h"
index 7f9c06ab17663a526006ee35ac3ac4a3f4409e41..1c0e0c9acff32da4ce714f96ded71ea260274325 100644 (file)
 
 #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;
index 5325bd88fe1e21fc9ef85acbc1c2e27dae5e85f0..e1705d20d0d96d83882d5b2bfce16bff745940bb 100644 (file)
@@ -41,7 +41,6 @@
 /* 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"
@@ -49,6 +48,8 @@
 #include "vec.h"
 #include "macros.h"
 
+#include "gmx_fatal.h"
+#include "gromacs/utility/smalloc.h"
 
 int pr_indent(FILE *fp, int n)
 {
index e193c92aa5e090aae9cabc9f73b79592f45c425c..11e362ebeb5a7a3db4876dde9a4a0577d569c9c0 100644 (file)
@@ -58,6 +58,7 @@
 #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)
index bf296b9ea1d94b20bfbd03fdf6745b89d4c61831..4afe493cb3c097e6fa19e3108d41bf06944702aa 100644 (file)
 #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"
@@ -56,6 +57,8 @@
 #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           */
index 65ee7a85b522f42197ca1fd2c513a3df0cc8e13d..52b7b048b38769c14b51ec8ac8fc23c327918f4b 100644 (file)
@@ -51,6 +51,8 @@
 #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)
 {
index de9ac7fb649e51e897bbb0934e4b639f6fa4547e..4274d779880b47adfd6d1958006918bd3010ec08 100644 (file)
@@ -51,6 +51,8 @@
 #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;
index fd4d111baac1ff339804e72908f913c65091dcc5..e9dd3961f18f3935f578f4c48f472923257bc2d2 100644 (file)
@@ -62,6 +62,8 @@
 
 #include "nm2type.h"
 
+#include "gmx_fatal.h"
+
 static void rd_nm2type_file(const char *fn, int *nnm, t_nm2type **nmp)
 {
     FILE         *fp;
index 63ce29bd2e1f029185653702a3e716fe7076eb53..38bf7cdc97bf5adcffe1c84f491ec2557da7aefe 100644 (file)
@@ -54,6 +54,8 @@
 #include "vec.h"
 #include "hackblock.h"
 
+#include "gmx_fatal.h"
+
 int gmx_protonate(int argc, char *argv[])
 {
     const char     *desc[] = {
index 56e0daac662500f748cda1c70dce9dd45cbf86bf..cc25957b1adcde7ceebac92a68449460e2b782e9 100644 (file)
@@ -46,6 +46,8 @@
 #include "gromacs/fileio/trnio.h"
 #include "txtdump.h"
 
+#include "gmx_fatal.h"
+
 static char *RotStr = {"Enforced rotation:"};
 
 
index da5a8ad64ca1bfa7946af2d0a5a8df4657a93671..52dcdd51cc6edc258b7fd8436fae6ef994592359 100644 (file)
@@ -995,7 +995,7 @@ static char **read_topol(const char *infile, const char *outfile,
                         }
                         default:
                             fprintf (stderr, "case: %d\n", d);
-                            invalid_case();
+                            gmx_incons("unknown directive");
                     }
                 }
             }
index adf877c938d989bb8d15d081369a031c293f4272..5a0c27af1bdc6eb6d0497fca0af31fa134a230d3 100644 (file)
 #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)
 
index fb73ce7fc436dd520c00d50de9d23e237b45fd82..2e8cbcece8b67194f923e556f0954eb8c5aecd0c 100644 (file)
 #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
index fe206048bc938a1f3bb59915940b3019021572ab..432f10ddf32be90bd42bc7b5c7ce90023cea1694 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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)
@@ -70,108 +73,119 @@ extern "C" {
 #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)
@@ -182,28 +196,33 @@ void _gmx_error(const char *key, const char *msg, const char *file, int line) GM
 #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
index 895c423a92381c9359e2dab3bb202319bfc0a67f..5e8a06c41e7f1ad8d8926caef273ae9f596fdb13 100644 (file)
@@ -48,6 +48,8 @@
 #include "pbc.h"
 #include "vec.h"
 
+#include "gmx_fatal.h"
+
 #define N 4
 
 void m4_op(mat4 m, rvec x, vec4 v)
index db483c8f41316a7c5c938ef189667f98b1d9bbe8..9701f769ab30982c3063c8c84012b2cc89ace86a 100644 (file)
 #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[])
index bfa1cd5a8657347d2ca6eba653f9c5830bade9d7..d2ac44d54c0c68a89ee35cdb7a2d92850cbfb5e8 100644 (file)
@@ -41,6 +41,8 @@
 #include "typedefs.h"
 #include "vec.h"
 
+#include "gmx_fatal.h"
+
 real
 adress_weight(rvec                 x,
               int                  adresstype,
index eec3eddf34899f51ae9d93016f5f73bbb53e49d0..3a2dc0b1a2c688bf85585771b2fc4b2c5dc2dc80 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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"
index 6ac3d2f81a86ddd8947002fcd4cd84dbbe1fab26..d215cbdac63273fe065b56b4cde398c0de98866a 100644 (file)
@@ -54,6 +54,7 @@
 #include "gmx_omp_nthreads.h"
 
 #include "gromacs/fileio/gmxfio.h"
+#include "gmx_fatal.h"
 #include "gromacs/utility/gmxomp.h"
 
 typedef struct {
index 716c65d54356a6ed6974b0dfd8635ad3dd6b8c8b..1f5addc99b990da065e764d3c2095f16f9f982eb 100644 (file)
@@ -61,6 +61,7 @@
 #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    */
index 9348512e64ddd3d999844c05c118d4588d81595b..6b20dd987c3a58d475fecb4c4b49a6899a605579 100644 (file)
@@ -46,6 +46,8 @@
 #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)
 {
index d7233bdf311616f74e11321e934d65f5a66de60a..d79ffb5065988f0cd9dd9fb8af448a275da60401 100644 (file)
@@ -50,6 +50,8 @@
 #include "gmx_omp_nthreads.h"
 #include "macros.h"
 
+#include "gmx_fatal.h"
+
 typedef struct {
     int  nsend;
     int *a;
index 9b69e69d035d4f48f4c56e69e79334dc2fed2d67..8aa77bfb6aa21c3c14d196339775c7979a486509 100644 (file)
@@ -56,6 +56,8 @@
 #include "force.h"
 #include "gmx_omp_nthreads.h"
 
+#include "gmx_fatal.h"
+
 /* for dd_init_local_state */
 #define NITEM_DD_INIT_LOCAL_STATE 5
 
index 64116f96d65c93b891f4176deaa9b0a2480acc38..14d0e7ea3d3a23ef7227d323928affa55e8e17e5 100644 (file)
@@ -71,6 +71,7 @@
 #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)
index c54d56ebcb561ae25dfb1cda7a38b27af8bd66ad..0726402913b01bb5d6f79fc79317132f73680163 100644 (file)
@@ -65,6 +65,7 @@
 #include "gmx_omp_nthreads.h"
 
 #include "gromacs/timing/wallcycle.h"
+#include "gmx_fatal.h"
 
 void ns(FILE              *fp,
         t_forcerec        *fr,
index 44cd7c4c5d84e5be682fe9501a83ff3da063dc0d..67cd36f34184ba820b4ab4a6196dd56fc135078a 100644 (file)
@@ -50,7 +50,6 @@
 #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"
index fb437c37a7efe2850a5635efa0192e3c0627c83c..4ba5acfb23c5d6a3ff582f928661b4c2843611cf 100644 (file)
 #include <config.h>
 #endif
 
+#include <assert.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <assert.h>
 
 #include <cuda.h>
 
index 13e782f1b58953205b36db9f1e8acba2ae8f8c53..85ae9d0b1412082f7c32be90ef37dee1e30f21ea 100644 (file)
@@ -40,6 +40,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index e947a0ed50c89f8f4ea37f27fe18c74f6d198eba..c6ba93966a7054bd9ab0f1b5cb15c3642ce5e07a 100644 (file)
@@ -44,7 +44,6 @@
 #include "gromacs/utility/smalloc.h"
 #include "macros.h"
 #include "xutil.h"
-#include "gmx_fatal.h"
 #include "buttons.h"
 #include "manager.h"
 #include "nmol.h"