Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_trjconv.c
index 2c52f8e85efcb906681d831f5dd1087bca73d6f6..19f6f8b5300abf893354b11fc1ea8eb4689761d1 100644 (file)
@@ -1250,14 +1250,20 @@ int gmx_trjconv(int argc, char *argv[])
         /* Make atoms struct for output in GRO or PDB files */
         if ((ftp == efGRO) || ((ftp == efG96) && bTPS) || (ftp == efPDB))
         {
-            /* get memory for stuff to go in .pdb file */
-            init_t_atoms(&useatoms, atoms->nr, FALSE);
+            /* get memory for stuff to go in .pdb file, and initialize
+             * the pdbinfo structure part if the input has it.
+             */
+            init_t_atoms(&useatoms, atoms->nr, (atoms->pdbinfo != NULL));
             sfree(useatoms.resinfo);
             useatoms.resinfo = atoms->resinfo;
             for (i = 0; (i < nout); i++)
             {
                 useatoms.atomname[i] = atoms->atomname[index[i]];
                 useatoms.atom[i]     = atoms->atom[index[i]];
+                if (atoms->pdbinfo != NULL)
+                {
+                    useatoms.pdbinfo[i]  = atoms->pdbinfo[index[i]];
+                }
                 useatoms.nres        = max(useatoms.nres, useatoms.atom[i].resind+1);
             }
             useatoms.nr = nout;