Merge release-4-5-patches into release-4-6
[alexxy/gromacs.git] / src / gmxlib / trxio.c
index 9a298797ba4edb799ea27d64b091ab93f8557a7d..f191bfd4a86718d3135681bf241cdf4be7c26336 100644 (file)
@@ -75,6 +75,7 @@ struct t_trxstatus
     int         NATOMS;
     double      DT,BOX[3];
     gmx_bool        bReadBox;
+    char *persistent_line; /* Persistent line for reading g96 trajectories */
 };
 
 static void initcount(t_trxstatus *status)
@@ -88,6 +89,7 @@ static void status_init(t_trxstatus *status)
     status->xframe=NULL;
     status->fio=NULL;
     status->__frame=-1;
+    status->persistent_line=NULL;
 }
 
 
@@ -694,10 +696,8 @@ gmx_bool read_next_frame(const output_env_t oenv,t_trxstatus *status,t_trxframe
       /* Checkpoint files can not contain mulitple frames */
       break;
     case efG96:
-      gmx_fatal(FARGS,
-               "Reading trajectories in .g96 format is broken. Please use\n"
-               "a different file format.");
-      read_g96_conf(gmx_fio_getfp(status->fio),NULL,fr);
+      read_g96_conf(gmx_fio_getfp(status->fio),NULL,fr, 
+                    status->persistent_line);
       bRet = (fr->natoms > 0);
       break;
     case efG87:
@@ -810,7 +810,12 @@ int read_first_frame(const output_env_t oenv,t_trxstatus **status,
     break;
   case efG96:
     /* Can not rewind a compressed file, so open it twice */
-    read_g96_conf(gmx_fio_getfp(fio),fn,fr);
+    if (!(*status)->persistent_line)
+    {
+        /* allocate the persistent line */
+        snew((*status)->persistent_line, STRLEN+1);
+    }
+    read_g96_conf(gmx_fio_getfp(fio),fn,fr, (*status)->persistent_line);
     gmx_fio_close(fio);
     clear_trxframe(fr,FALSE);
     if (flags & (TRX_READ_X | TRX_NEED_X))