Merge branch release-2018
[alexxy/gromacs.git] / src / gromacs / fileio / tngio.cpp
index b8ac1aee26909e23832a2b95e9de108ca34dcd76..eb62e4c7563a8acf309309cf6bf9a3193301c2a3 100644 (file)
@@ -86,12 +86,14 @@ using tng_trajectory_t = void *;
  */
 struct gmx_tng_trajectory
 {
-    tng_trajectory_t tng;                 //!< Actual TNG handle (pointer)
-    bool             lastStepDataIsValid; //!< True if lastStep has been set
-    std::int64_t     lastStep;            //!< Index/step used for last frame
-    bool             lastTimeDataIsValid; //!< True if lastTime has been set
-    double           lastTime;            //!< Time of last frame (TNG unit is seconds)
-    bool             timePerFrameIsSet;   //!< True if we have set the time per frame
+    tng_trajectory_t tng;                  //!< Actual TNG handle (pointer)
+    bool             lastStepDataIsValid;  //!< True if lastStep has been set
+    std::int64_t     lastStep;             //!< Index/step used for last frame
+    bool             lastTimeDataIsValid;  //!< True if lastTime has been set
+    double           lastTime;             //!< Time of last frame (TNG unit is seconds)
+    bool             timePerFrameIsSet;    //!< True if we have set the time per frame
+    int              boxOutputInterval;    //!< Number of steps between the output of box size
+    int              lambdaOutputInterval; //!< Number of steps between the output of lambdas
 };
 
 #if GMX_USE_TNG
@@ -111,8 +113,6 @@ static const char *modeToVerb(char mode)
             break;
         default:
             gmx_fatal(FARGS, "Invalid file opening mode %c", mode);
-            p = "";
-            break;
     }
     return p;
 }
@@ -231,7 +231,7 @@ void gmx_tng_close(gmx_tng_trajectory_t *gmx_tng)
 static void addTngMoleculeFromTopology(gmx_tng_trajectory_t gmx_tng,
                                        const char          *moleculeName,
                                        const t_atoms       *atoms,
-                                       gmx_int64_t          numMolecules,
+                                       int64_t              numMolecules,
                                        tng_molecule_t      *tngMol)
 {
     tng_trajectory_t tng      = gmx_tng->tng;
@@ -314,17 +314,17 @@ void gmx_tng_add_mtop(gmx_tng_trajectory_t  gmx_tng,
     atomCharges.reserve(mtop->natoms);
     atomMasses.reserve(mtop->natoms);
 
-    for (int molIndex = 0; molIndex < mtop->nmolblock; molIndex++)
+    for (const gmx_molblock_t &molBlock :  mtop->molblock)
     {
         tng_molecule_t       tngMol  = nullptr;
-        const gmx_moltype_t *molType = &mtop->moltype[mtop->molblock[molIndex].type];
+        const gmx_moltype_t *molType = &mtop->moltype[molBlock.type];
 
         /* Add a molecule to the TNG trajectory with the same name as the
          * current molecule. */
         addTngMoleculeFromTopology(gmx_tng,
                                    *(molType->name),
                                    &molType->atoms,
-                                   mtop->molblock[molIndex].nmol,
+                                   molBlock.nmol,
                                    &tngMol);
 
         /* Bonds have to be deduced from interactions (constraints etc). Different
@@ -365,7 +365,7 @@ void gmx_tng_add_mtop(gmx_tng_trajectory_t  gmx_tng,
             atomCharges.push_back(molType->atoms.atom[atomCounter].q);
             atomMasses.push_back(molType->atoms.atom[atomCounter].m);
         }
-        for (int molCounter = 1; molCounter < mtop->molblock[molIndex].nmol; molCounter++)
+        for (int molCounter = 1; molCounter < molBlock.nmol; molCounter++)
         {
             std::copy_n(atomCharges.end() - molType->atoms.nr, molType->atoms.nr, std::back_inserter(atomCharges));
             std::copy_n(atomMasses.end()  - molType->atoms.nr, molType->atoms.nr, std::back_inserter(atomMasses));
@@ -454,9 +454,9 @@ static void set_writing_intervals(gmx_tng_trajectory_t  gmx_tng,
     /* Define pointers to specific writing functions depending on if we
      * write float or double data */
     typedef tng_function_status (*set_writing_interval_func_pointer)(tng_trajectory_t,
-                                                                     const gmx_int64_t,
-                                                                     const gmx_int64_t,
-                                                                     const gmx_int64_t,
+                                                                     const int64_t,
+                                                                     const int64_t,
+                                                                     const int64_t,
                                                                      const char*,
                                                                      const char,
                                                                      const char);
@@ -548,6 +548,8 @@ static void set_writing_intervals(gmx_tng_trajectory_t  gmx_tng,
         set_writing_interval(tng, gcd, 9, TNG_TRAJ_BOX_SHAPE,
                              "BOX SHAPE", TNG_NON_PARTICLE_BLOCK_DATA,
                              TNG_GZIP_COMPRESSION);
+        gmx_tng->lambdaOutputInterval = gcd;
+        gmx_tng->boxOutputInterval    = gcd;
         if (gcd < lowest / 10)
         {
             gmx_warning("The lowest common denominator of trajectory output is "
@@ -580,21 +582,18 @@ void gmx_tng_prepare_md_writing(gmx_tng_trajectory_t  gmx_tng,
 static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
                                    const int         gtype)
 {
-    const gmx_moltype_t     *molType;
-    const t_atoms           *atoms;
-
     /* Iterate through all atoms in the molecule system and
      * check if they belong to a selection group of the
      * requested type. */
-    for (int molIndex = 0, i = 0; molIndex < mtop->nmoltype; molIndex++)
+    int i = 0;
+    for (const gmx_molblock_t &molBlock : mtop->molblock)
     {
-        molType = &mtop->moltype[mtop->molblock[molIndex].type];
-
-        atoms = &molType->atoms;
+        const gmx_moltype_t &molType = mtop->moltype[molBlock.type];
+        const t_atoms       &atoms   = molType.atoms;
 
-        for (int j = 0; j < mtop->molblock[molIndex].nmol; j++)
+        for (int j = 0; j < molBlock.nmol; j++)
         {
-            for (int atomIndex = 0; atomIndex < atoms->nr; atomIndex++, i++)
+            for (int atomIndex = 0; atomIndex < atoms.nr; atomIndex++, i++)
             {
                 if (ggrpnr(&mtop->groups, gtype, i) != 0)
                 {
@@ -616,7 +615,6 @@ static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
 static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                                  const gmx_mtop_t     *mtop)
 {
-    const gmx_moltype_t     *molType;
     const t_atoms           *atoms;
     const t_atom            *at;
     const t_resinfo         *resInfo;
@@ -628,7 +626,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
     tng_residue_t            res;
     tng_atom_t               atom;
     tng_bond_t               tngBond;
-    gmx_int64_t              nMols;
+    int64_t                  nMols;
     char                    *groupName;
     tng_trajectory_t         tng = gmx_tng->tng;
 
@@ -659,13 +657,14 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
     tng_molecule_alloc(tng, &mol);
     tng_molecule_name_set(tng, mol, groupName);
     tng_molecule_chain_add(tng, mol, "", &chain);
-    for (int molIndex = 0, i = 0; molIndex < mtop->nmolblock; molIndex++)
+    int i = 0;
+    for (const gmx_molblock_t &molBlock :  mtop->molblock)
     {
-        molType = &mtop->moltype[mtop->molblock[molIndex].type];
+        const gmx_moltype_t &molType = mtop->moltype[molBlock.type];
 
-        atoms = &molType->atoms;
+        atoms = &molType.atoms;
 
-        for (int j = 0; j < mtop->molblock[molIndex].nmol; j++)
+        for (int j = 0; j < molBlock.nmol; j++)
         {
             bool bAtomsAdded = FALSE;
             for (int atomIndex = 0; atomIndex < atoms->nr; atomIndex++, i++)
@@ -688,7 +687,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                 }
                 else
                 {
-                    res_name = (char *)"";
+                    res_name = const_cast<char*>("");
                     res_id   = 0;
                 }
                 if (tng_chain_residue_find(tng, chain, res_name, res_id, &res)
@@ -710,7 +709,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                 {
                     if (IS_CHEMBOND(k))
                     {
-                        ilist = &molType->ilist[k];
+                        ilist = &molType.ilist[k];
                         if (ilist)
                         {
                             int l = 1;
@@ -731,7 +730,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                     }
                 }
                 /* Settle is described using three atoms */
-                ilist = &molType->ilist[F_SETTLE];
+                ilist = &molType.ilist[F_SETTLE];
                 if (ilist)
                 {
                     int l = 1;
@@ -764,7 +763,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
     tng_molecule_existing_add(tng, &mol);
     tng_molecule_cnt_set(tng, mol, 1);
     tng_num_molecule_types_get(tng, &nMols);
-    for (gmx_int64_t k = 0; k < nMols; k++)
+    for (int64_t k = 0; k < nMols; k++)
     {
         tng_molecule_of_index_get(tng, k, &iterMol);
         if (iterMol == mol)
@@ -807,7 +806,7 @@ void gmx_tng_prepare_low_prec_writing(gmx_tng_trajectory_t  gmx_tng,
 
 void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
                     const gmx_bool       bUseLossyCompression,
-                    gmx_int64_t          step,
+                    int64_t              step,
                     real                 elapsedPicoSeconds,
                     real                 lambda,
                     const rvec          *box,
@@ -818,11 +817,11 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
 {
 #if GMX_USE_TNG
     typedef tng_function_status (*write_data_func_pointer)(tng_trajectory_t,
-                                                           const gmx_int64_t,
+                                                           const int64_t,
                                                            const double,
                                                            const real*,
-                                                           const gmx_int64_t,
-                                                           const gmx_int64_t,
+                                                           const int64_t,
+                                                           const int64_t,
                                                            const char*,
                                                            const char,
                                                            const char);
@@ -832,7 +831,7 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
     static write_data_func_pointer           write_data           = tng_util_generic_with_time_write;
 #endif
     double                                   elapsedSeconds = elapsedPicoSeconds * PICO;
-    gmx_int64_t                              nParticles;
+    int64_t                                  nParticles;
     char                                     compression;
 
 
@@ -881,7 +880,7 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
     }
 
     tng_num_particles_get(tng, &nParticles);
-    if (nAtoms != (int)nParticles)
+    if (nAtoms != static_cast<int>(nParticles))
     {
         tng_implicit_num_particles_set(tng, nAtoms);
     }
@@ -937,24 +936,32 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
         }
     }
 
-    /* TNG-MF1 compression only compresses positions and velocities. Use lossless
-     * compression for lambdas and box shape regardless of output mode */
-    if (write_data(tng, step, elapsedSeconds,
-                   reinterpret_cast<const real *>(box),
-                   9, TNG_TRAJ_BOX_SHAPE, "BOX SHAPE",
-                   TNG_NON_PARTICLE_BLOCK_DATA,
-                   TNG_GZIP_COMPRESSION) != TNG_SUCCESS)
+    if (box)
     {
-        gmx_file("Cannot write TNG trajectory frame; maybe you are out of disk space?");
+        /* TNG-MF1 compression only compresses positions and velocities. Use lossless
+         * compression for box shape regardless of output mode */
+        if (write_data(tng, step, elapsedSeconds,
+                       reinterpret_cast<const real *>(box),
+                       9, TNG_TRAJ_BOX_SHAPE, "BOX SHAPE",
+                       TNG_NON_PARTICLE_BLOCK_DATA,
+                       TNG_GZIP_COMPRESSION) != TNG_SUCCESS)
+        {
+            gmx_file("Cannot write TNG trajectory frame; maybe you are out of disk space?");
+        }
     }
 
-    if (write_data(tng, step, elapsedSeconds,
-                   reinterpret_cast<const real *>(&lambda),
-                   1, TNG_GMX_LAMBDA, "LAMBDAS",
-                   TNG_NON_PARTICLE_BLOCK_DATA,
-                   TNG_GZIP_COMPRESSION) != TNG_SUCCESS)
+    if (lambda >= 0)
     {
-        gmx_file("Cannot write TNG trajectory frame; maybe you are out of disk space?");
+        /* TNG-MF1 compression only compresses positions and velocities. Use lossless
+         * compression for lambda regardless of output mode */
+        if (write_data(tng, step, elapsedSeconds,
+                       reinterpret_cast<const real *>(&lambda),
+                       1, TNG_GMX_LAMBDA, "LAMBDAS",
+                       TNG_NON_PARTICLE_BLOCK_DATA,
+                       TNG_GZIP_COMPRESSION) != TNG_SUCCESS)
+        {
+            gmx_file("Cannot write TNG trajectory frame; maybe you are out of disk space?");
+        }
     }
 
     // Update the data in the wrapper
@@ -993,7 +1000,7 @@ void fflush_tng(gmx_tng_trajectory_t gmx_tng)
 float gmx_tng_get_time_of_final_frame(gmx_tng_trajectory_t gmx_tng)
 {
 #if GMX_USE_TNG
-    gmx_int64_t      nFrames;
+    int64_t          nFrames;
     double           time;
     float            fTime;
     tng_trajectory_t tng = gmx_tng->tng;
@@ -1022,7 +1029,7 @@ void gmx_prepare_tng_writing(const char              *filename,
     tng_trajectory_t   *input  = (gmx_tng_input && *gmx_tng_input) ? &(*gmx_tng_input)->tng : nullptr;
     /* FIXME after 5.0: Currently only standard block types are read */
     const int           defaultNumIds              = 5;
-    static gmx_int64_t  fallbackIds[defaultNumIds] =
+    static int64_t      fallbackIds[defaultNumIds] =
     {
         TNG_TRAJ_BOX_SHAPE, TNG_TRAJ_POSITIONS,
         TNG_TRAJ_VELOCITIES, TNG_TRAJ_FORCES,
@@ -1035,9 +1042,9 @@ void gmx_prepare_tng_writing(const char              *filename,
     };
 
     typedef tng_function_status (*set_writing_interval_func_pointer)(tng_trajectory_t,
-                                                                     const gmx_int64_t,
-                                                                     const gmx_int64_t,
-                                                                     const gmx_int64_t,
+                                                                     const int64_t,
+                                                                     const int64_t,
+                                                                     const int64_t,
                                                                      const char*,
                                                                      const char,
                                                                      const char);
@@ -1060,7 +1067,7 @@ void gmx_prepare_tng_writing(const char              *filename,
          * output tng container based on their respective values int
          * the input tng container */
         double      time, compression_precision;
-        gmx_int64_t n_frames_per_frame_set, interval = -1;
+        int64_t     n_frames_per_frame_set, interval = -1;
 
         tng_compression_precision_get(*input, &compression_precision);
         tng_compression_precision_set(*output, compression_precision);
@@ -1099,11 +1106,13 @@ void gmx_prepare_tng_writing(const char              *filename,
                         set_writing_interval(*output, interval, 9, fallbackIds[i],
                                              fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
                                              TNG_GZIP_COMPRESSION);
+                        (*gmx_tng_output)->boxOutputInterval = interval;
                         break;
                     case TNG_GMX_LAMBDA:
                         set_writing_interval(*output, interval, 1, fallbackIds[i],
                                              fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
                                              TNG_GZIP_COMPRESSION);
+                        (*gmx_tng_output)->lambdaOutputInterval = interval;
                         break;
                     default:
                         continue;
@@ -1226,7 +1235,7 @@ convert_array_to_real_array(void       *from,
             {
                 for (j = 0; j < nValues; j++)
                 {
-                    to[i*nValues+j] = reinterpret_cast<gmx_int64_t *>(from)[i*nValues+j] * fact;
+                    to[i*nValues+j] = reinterpret_cast<int64_t *>(from)[i*nValues+j] * fact;
                 }
             }
             break;
@@ -1261,14 +1270,12 @@ convert_array_to_real_array(void       *from,
             break;
         default:
             gmx_incons("Illegal datatype when converting values to a real array!");
-            return;
     }
-    return;
 }
 
 real getDistanceScaleFactor(gmx_tng_trajectory_t in)
 {
-    gmx_int64_t exp = -1;
+    int64_t     exp = -1;
     real        distanceScaleFactor;
 
     // TODO Hopefully, TNG 2.0 will do this kind of thing for us
@@ -1299,7 +1306,7 @@ void gmx_tng_setup_atom_subgroup(gmx_tng_trajectory_t gmx_tng,
                                  const char          *name)
 {
 #if GMX_USE_TNG
-    gmx_int64_t              nAtoms, cnt, nMols;
+    int64_t                  nAtoms, cnt, nMols;
     tng_molecule_t           mol, iterMol;
     tng_chain_t              chain;
     tng_residue_t            res;
@@ -1370,7 +1377,7 @@ void gmx_tng_setup_atom_subgroup(gmx_tng_trajectory_t gmx_tng,
      * other molecules to 0 */
     tng_molecule_cnt_set(tng, mol, 1);
     tng_num_molecule_types_get(tng, &nMols);
-    for (gmx_int64_t k = 0; k < nMols; k++)
+    for (int64_t k = 0; k < nMols; k++)
     {
         tng_molecule_of_index_get(tng, k, &iterMol);
         if (iterMol == mol)
@@ -1393,22 +1400,22 @@ void gmx_tng_setup_atom_subgroup(gmx_tng_trajectory_t gmx_tng,
  * and lose no information. */
 gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
                                  t_trxframe                 *fr,
-                                 gmx_int64_t                *requestedIds,
+                                 int64_t                    *requestedIds,
                                  int                         numRequestedIds)
 {
 #if GMX_USE_TNG
     tng_trajectory_t        input = gmx_tng_input->tng;
     gmx_bool                bOK   = TRUE;
     tng_function_status     stat;
-    gmx_int64_t             numberOfAtoms = -1, frameNumber = -1;
-    gmx_int64_t             nBlocks, blockId, *blockIds = nullptr, codecId;
+    int64_t                 numberOfAtoms = -1, frameNumber = -1;
+    int64_t                 nBlocks, blockId, *blockIds = nullptr, codecId;
     char                    datatype      = -1;
     void                   *values        = nullptr;
     double                  frameTime     = -1.0;
     int                     size, blockDependency;
     double                  prec;
     const int               defaultNumIds = 5;
-    static gmx_int64_t      fallbackRequestedIds[defaultNumIds] =
+    static int64_t          fallbackRequestedIds[defaultNumIds] =
     {
         TNG_TRAJ_BOX_SHAPE, TNG_TRAJ_POSITIONS,
         TNG_TRAJ_VELOCITIES, TNG_TRAJ_FORCES,
@@ -1448,7 +1455,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
                                                                       &frameNumber,
                                                                       &nBlocks,
                                                                       &blockIds);
-    gmx::unique_cptr<gmx_int64_t, gmx::free_wrapper> blockIdsGuard(blockIds);
+    gmx::unique_cptr<int64_t, gmx::free_wrapper> blockIdsGuard(blockIds);
     if (!nextFrameExists)
     {
         return FALSE;
@@ -1459,7 +1466,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
         return FALSE;
     }
 
-    for (gmx_int64_t i = 0; i < nBlocks; i++)
+    for (int64_t i = 0; i < nBlocks; i++)
     {
         blockId = blockIds[i];
         tng_data_block_dependency_get(input, blockId, &blockDependency);
@@ -1496,7 +1503,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
                 switch (datatype)
                 {
                     case TNG_INT_DATA:
-                        size = sizeof(gmx_int64_t);
+                        size = sizeof(int64_t);
                         break;
                     case TNG_FLOAT_DATA:
                         size = sizeof(float);
@@ -1538,7 +1545,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
             case TNG_TRAJ_VELOCITIES:
                 srenew(fr->v, fr->natoms);
                 convert_array_to_real_array(values,
-                                            (real *) fr->v,
+                                            reinterpret_cast<real *>(fr->v),
                                             getDistanceScaleFactor(gmx_tng_input),
                                             fr->natoms,
                                             DIM,
@@ -1608,8 +1615,8 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
                                    FILE                *stream)
 {
 #if GMX_USE_TNG
-    gmx_int64_t         nMolecules, nChains, nResidues, nAtoms, nFramesRead;
-    gmx_int64_t         strideLength, nParticlesRead, nValuesPerFrameRead, *molCntList;
+    int64_t             nMolecules, nChains, nResidues, nAtoms, nFramesRead;
+    int64_t             strideLength, nParticlesRead, nValuesPerFrameRead, *molCntList;
     tng_molecule_t      molecule;
     tng_chain_t         chain;
     tng_residue_t       residue;
@@ -1628,17 +1635,17 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
     /* Can the number of particles change in the trajectory or is it constant? */
     tng_num_particles_variable_get(input, &varNAtoms);
 
-    for (gmx_int64_t i = 0; i < nMolecules; i++)
+    for (int64_t i = 0; i < nMolecules; i++)
     {
         tng_molecule_of_index_get(input, i, &molecule);
         tng_molecule_name_get(input, molecule, str, 256);
         if (varNAtoms == TNG_CONSTANT_N_ATOMS)
         {
-            if ((int)molCntList[i] == 0)
+            if (static_cast<int>(molCntList[i]) == 0)
             {
                 continue;
             }
-            fprintf(stream, "Molecule: %s, count: %d\n", str, (int)molCntList[i]);
+            fprintf(stream, "Molecule: %s, count: %d\n", str, static_cast<int>(molCntList[i]));
         }
         else
         {
@@ -1647,19 +1654,19 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
         tng_molecule_num_chains_get(input, molecule, &nChains);
         if (nChains > 0)
         {
-            for (gmx_int64_t j = 0; j < nChains; j++)
+            for (int64_t j = 0; j < nChains; j++)
             {
                 tng_molecule_chain_of_index_get(input, molecule, j, &chain);
                 tng_chain_name_get(input, chain, str, 256);
                 fprintf(stream, "\tChain: %s\n", str);
                 tng_chain_num_residues_get(input, chain, &nResidues);
-                for (gmx_int64_t k = 0; k < nResidues; k++)
+                for (int64_t k = 0; k < nResidues; k++)
                 {
                     tng_chain_residue_of_index_get(input, chain, k, &residue);
                     tng_residue_name_get(input, residue, str, 256);
                     fprintf(stream, "\t\tResidue: %s\n", str);
                     tng_residue_num_atoms_get(input, residue, &nAtoms);
-                    for (gmx_int64_t l = 0; l < nAtoms; l++)
+                    for (int64_t l = 0; l < nAtoms; l++)
                     {
                         tng_residue_atom_of_index_get(input, residue, l, &atom);
                         tng_atom_name_get(input, atom, str, 256);
@@ -1678,13 +1685,13 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
             tng_molecule_num_residues_get(input, molecule, &nResidues);
             if (nResidues > 0)
             {
-                for (gmx_int64_t k = 0; k < nResidues; k++)
+                for (int64_t k = 0; k < nResidues; k++)
                 {
                     tng_molecule_residue_of_index_get(input, molecule, k, &residue);
                     tng_residue_name_get(input, residue, str, 256);
                     fprintf(stream, "\t\tResidue: %s\n", str);
                     tng_residue_num_atoms_get(input, residue, &nAtoms);
-                    for (gmx_int64_t l = 0; l < nAtoms; l++)
+                    for (int64_t l = 0; l < nAtoms; l++)
                     {
                         tng_residue_atom_of_index_get(input, residue, l, &atom);
                         tng_atom_name_get(input, atom, str, 256);
@@ -1697,7 +1704,7 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
             else
             {
                 tng_molecule_num_atoms_get(input, molecule, &nAtoms);
-                for (gmx_int64_t l = 0; l < nAtoms; l++)
+                for (int64_t l = 0; l < nAtoms; l++)
                 {
                     tng_molecule_atom_of_index_get(input, molecule, l, &atom);
                     tng_atom_name_get(input, atom, str, 256);
@@ -1724,10 +1731,10 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
                                     datatype);
 
         fprintf(stream, "Atom Charges (%d):\n", int(nAtoms));
-        for (gmx_int64_t i = 0; i < nAtoms; i += 10)
+        for (int64_t i = 0; i < nAtoms; i += 10)
         {
             fprintf(stream, "Atom Charges [%8d-]=[", int(i));
-            for (gmx_int64_t j = 0; (j < 10 && i + j < nAtoms); j++)
+            for (int64_t j = 0; (j < 10 && i + j < nAtoms); j++)
             {
                 fprintf(stream, " %12.5e", atomCharges[i + j]);
             }
@@ -1749,10 +1756,10 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
                                     datatype);
 
         fprintf(stream, "Atom Masses (%d):\n", int(nAtoms));
-        for (gmx_int64_t i = 0; i < nAtoms; i += 10)
+        for (int64_t i = 0; i < nAtoms; i += 10)
         {
             fprintf(stream, "Atom Masses [%8d-]=[", int(i));
-            for (gmx_int64_t j = 0; (j < 10 && i + j < nAtoms); j++)
+            for (int64_t j = 0; (j < 10 && i + j < nAtoms); j++)
             {
                 fprintf(stream, " %12.5e", atomMasses[i + j]);
             }
@@ -1770,10 +1777,10 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
 gmx_bool gmx_get_tng_data_block_types_of_next_frame(gmx_tng_trajectory_t gmx_tng_input,
                                                     int                  frame,
                                                     int                  nRequestedIds,
-                                                    gmx_int64_t         *requestedIds,
-                                                    gmx_int64_t         *nextFrame,
-                                                    gmx_int64_t         *nBlocks,
-                                                    gmx_int64_t        **blockIds)
+                                                    int64_t             *requestedIds,
+                                                    int64_t             *nextFrame,
+                                                    int64_t             *nBlocks,
+                                                    int64_t            **blockIds)
 {
 #if GMX_USE_TNG
     tng_function_status stat;
@@ -1806,12 +1813,12 @@ gmx_bool gmx_get_tng_data_block_types_of_next_frame(gmx_tng_trajectory_t gmx_tng
 }
 
 gmx_bool gmx_get_tng_data_next_frame_of_block_type(gmx_tng_trajectory_t gmx_tng_input,
-                                                   gmx_int64_t          blockId,
+                                                   int64_t              blockId,
                                                    real               **values,
-                                                   gmx_int64_t         *frameNumber,
+                                                   int64_t             *frameNumber,
                                                    double              *frameTime,
-                                                   gmx_int64_t         *nValuesPerFrame,
-                                                   gmx_int64_t         *nAtoms,
+                                                   int64_t             *nValuesPerFrame,
+                                                   int64_t             *nAtoms,
                                                    real                *prec,
                                                    char                *name,
                                                    int                  maxLen,
@@ -1820,7 +1827,7 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(gmx_tng_trajectory_t gmx_tng_
 #if GMX_USE_TNG
     tng_function_status stat;
     char                datatype = -1;
-    gmx_int64_t         codecId;
+    int64_t             codecId;
     int                 blockDependency;
     void               *data = nullptr;
     double              localPrec;
@@ -1911,3 +1918,21 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(gmx_tng_trajectory_t gmx_tng_
     return FALSE;
 #endif
 }
+
+int gmx_tng_get_box_output_interval(gmx_tng_trajectory_t gmx_tng)
+{
+#if GMX_USE_TNG
+    return gmx_tng->boxOutputInterval;
+#else
+    GMX_UNUSED_VALUE(gmx_tng);
+#endif
+}
+
+int gmx_tng_get_lambda_output_interval(gmx_tng_trajectory_t gmx_tng)
+{
+#if GMX_USE_TNG
+    return gmx_tng->lambdaOutputInterval;
+#else
+    GMX_UNUSED_VALUE(gmx_tng);
+#endif
+}