Merge remote-tracking branch 'gerrit/release-4-5-patches' into release-4-6
[alexxy/gromacs.git] / src / kernel / pgutil.c
index 337c8fb21c0ef5658785f32b5932afe06835e1ae..db8423932bf926fb2b1bdc50423ccf80af1f15a2 100644 (file)
@@ -45,6 +45,7 @@
 #define BUFSIZE 1024
 static void atom_not_found(int fatal_errno,const char *file,int line,
                           const char *atomname,int resind,
+                           const char *resname,
                           const char *bondtype,gmx_bool bAllowMissing)
 {
     char message_buffer[BUFSIZE];
@@ -53,17 +54,21 @@ static void atom_not_found(int fatal_errno,const char *file,int line,
         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);
+                     "Residue %d named %s of a molecule in the input file was mapped\n"
+                     "to an entry in the topology database, but the atom %s used in\n"
+                     "an interaction of type %s in that entry is not found in the\n"
+                     "input file. Perhaps your atom and/or residue naming needs to be\n"
+                     "fixed.\n",
+                     resind+1, resname, atomname, bondtype);
         }
         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);
+                     "Residue %d named %s of a molecule in the input file was mapped\n"
+                     "to an entry in the topology database, but the atom %s used in\n"
+                     "that entry is not found in the input file. Perhaps your atom\n"
+                     "and/or residue naming needs to be fixed.\n",
+                     resind+1, resname, atomname);
         }
         if (bAllowMissing)
         {
@@ -76,12 +81,15 @@ static void atom_not_found(int fatal_errno,const char *file,int line,
     }
 }
        
-atom_id search_atom(const char *type,int start,int natoms,t_atom at[],
-                   char ** const * anm,
+atom_id search_atom(const char *type,int start,
+                    t_atoms *atoms,
                    const char *bondtype,gmx_bool bAllowMissing)
 {
   int     i,resind=-1;
   gmx_bool    bPrevious,bNext;
+  int natoms = atoms->nr;
+  t_atom *at = atoms->atom;
+  char ** const * anm = atoms->atomname;
 
   bPrevious = (strchr(type,'-') != NULL);
   bNext     = (strchr(type,'+') != NULL);
@@ -102,7 +110,9 @@ atom_id search_atom(const char *type,int start,int natoms,t_atom at[],
        return (atom_id) i;
     }
     if (!(bNext && at[start].resind==at[natoms-1].resind))
-      atom_not_found(FARGS,type,at[start].resind,bondtype,bAllowMissing);
+    {
+        atom_not_found(FARGS,type,at[start].resind,*atoms->resinfo[resind].name,bondtype,bAllowMissing);
+    }
   }
   else {
     /* The previous residue */
@@ -113,7 +123,9 @@ atom_id search_atom(const char *type,int start,int natoms,t_atom at[],
       if (gmx_strcasecmp(type,*(anm[i]))==0)
        return (atom_id) i;
     if (start > 0)
-      atom_not_found(FARGS,type,at[start].resind,bondtype,bAllowMissing);
+    {
+        atom_not_found(FARGS,type,at[start].resind,*atoms->resinfo[resind].name,bondtype,bAllowMissing);
+    }
   }
   return NO_ATID;
 }