Update header when appending to TNG file.
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Fri, 27 Mar 2015 11:20:38 +0000 (12:20 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 24 Jun 2015 20:55:58 +0000 (22:55 +0200)
The library now handles updating the size of the headers
by moving the first frame sets to make room (if necessary).
Therefore this is now enabled when appending to a trajectory
from mdrun.

Change-Id: I7334a1b0c251856f30e116b63161f7676055dce1

src/gromacs/fileio/tngio.cpp

index 2ae31c288ec8027b20e44edc3a818da2db567c34..417c246ca34101e15d794255fd61bd7feb2dd1d9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 2015 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.
@@ -106,22 +106,16 @@ void gmx_tng_open(const char       *filename,
 
     if (mode == 'w' || mode == 'a')
     {
-        /* FIXME in TNG: When adding data to the header, subsequent blocks might get
-         * overwritten. This could be solved by moving the first trajectory
-         * frame set(s) to the end of the file. Could that cause other problems,
-         * e.g. when continuing a simulation? */
         char hostname[256];
         gmx_gethostname(hostname, 256);
         if (mode == 'w')
         {
             tng_first_computer_name_set(*tng, hostname);
         }
-/* TODO: This should be implemented when the above fixme is done (adding data to
- * the header). */
-//         else
-//         {
-//             tng_last_computer_name_set(*tng, hostname);
-//         }
+        else
+        {
+            tng_last_computer_name_set(*tng, hostname);
+        }
 
         char        programInfo[256];
         const char *precisionString = "";
@@ -135,12 +129,10 @@ void gmx_tng_open(const char       *filename,
         {
             tng_first_program_name_set(*tng, programInfo);
         }
-/* TODO: This should be implemented when the above fixme is done (adding data to
- * the header). */
-//         else
-//         {
-//             tng_last_program_name_set(*tng, programInfo);
-//         }
+        else
+        {
+            tng_last_program_name_set(*tng, programInfo);
+        }
 
         char username[256];
         if (!gmx_getusername(username, 256))
@@ -149,13 +141,12 @@ void gmx_tng_open(const char       *filename,
             {
                 tng_first_user_name_set(*tng, username);
             }
+            else
+            {
+                tng_last_user_name_set(*tng, username);
+                tng_file_headers_write(*tng, TNG_USE_HASH);
+            }
         }
-/* TODO: This should be implemented when the above fixme is done (adding data to
- * the header). */
-//         else
-//         {
-//             tng_last_user_name_set(*tng, username);
-//         }
     }
 #else
     gmx_file("GROMACS was compiled without TNG support, cannot handle this file type");