#include "string.h"
#include "gmx_fatal.h"
+#define BUFSIZE 1024
static void atom_not_found(int fatal_errno,const char *file,int line,
const char *atomname,int resind,
- const char *bondtype,gmx_bool bDontQuit)
+ const char *bondtype,gmx_bool bAllowMissing)
{
- if (strcmp(bondtype,"check") != 0) {
- if (bDontQuit) {
- gmx_warning("WARNING: Atom %s is used in an interaction of type %s in the\n"
- "topology database, but an atom of that name was not found in\n"
- "residue number %d.\n",
- atomname,bondtype,resind+1);
- } else {
- gmx_fatal(fatal_errno,file,line,
- "Atom %s is used in an interaction of type %s in the topology\n"
- "database, but an atom of that name was not found in residue\n"
- "number %d.\n",
- atomname,bondtype,resind+1);
+ char message_buffer[BUFSIZE];
+ if (strcmp(bondtype,"check") != 0)
+ {
+ if (0 != strcmp(bondtype, "atom"))
+ {
+ snprintf(message_buffer, 1024,
+ "Atom %s is used in an interaction of type %s in the topology\n"
+ "database, but an atom of that name was not found in residue\n"
+ "number %d.\n",
+ atomname,bondtype,resind+1);
+ }
+ else
+ {
+ snprintf(message_buffer, 1024,
+ "Atom %s is used in the topology database, but an atom of that\n"
+ "name was not found in residue number %d.\n",
+ atomname,resind+1);
+ }
+ if (bAllowMissing)
+ {
+ gmx_warning("WARNING: %s", message_buffer);
+ }
+ else
+ {
+ gmx_fatal(fatal_errno,file,line,message_buffer);
+ }
}
- }
}
atom_id search_atom(const char *type,int start,int natoms,t_atom at[],
char ** const * anm,
- const char *bondtype,gmx_bool bDontQuit)
+ const char *bondtype,gmx_bool bAllowMissing)
{
int i,resind=-1;
gmx_bool bPrevious,bNext;
return (atom_id) i;
}
if (!(bNext && at[start].resind==at[natoms-1].resind))
- atom_not_found(FARGS,type,at[start].resind,bondtype,bDontQuit);
+ atom_not_found(FARGS,type,at[start].resind,bondtype,bAllowMissing);
}
else {
/* The previous residue */
if (gmx_strcasecmp(type,*(anm[i]))==0)
return (atom_id) i;
if (start > 0)
- atom_not_found(FARGS,type,at[start].resind,bondtype,bDontQuit);
+ atom_not_found(FARGS,type,at[start].resind,bondtype,bAllowMissing);
}
return NO_ATID;
}
extern atom_id search_atom(const char *type,int start,
int natoms,t_atom at[],
char ** const * anm,
- const char *bondtype,gmx_bool bDontQuit);
+ const char *bondtype,gmx_bool bAllowMissing);
/* Search an atom in array of pointers to strings, starting from start
* if type starts with '-' then searches backwards from start.
* bondtype is only used for printing the error/warning string,
* when bondtype="check" no error/warning is issued.
- * When bDontQuit=FALSE an fatal error is issued, otherwise a warning.
+ * When bAllowMissing=FALSE an fatal error is issued, otherwise a warning.
*/
extern void set_at(t_atom *at,real m,real q,int type,int resind);