From: Magnus Lundborg Date: Fri, 29 Oct 2021 18:36:42 +0000 (+0000) Subject: Allow TNG to TNG file conversion without time per frame info X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=35ad98436750bf350cf42060a931ce15eb44ff5a Allow TNG to TNG file conversion without time per frame info --- diff --git a/src/gromacs/fileio/tngio.cpp b/src/gromacs/fileio/tngio.cpp index 485d3e35b2..8604b59a75 100644 --- a/src/gromacs/fileio/tngio.cpp +++ b/src/gromacs/fileio/tngio.cpp @@ -1063,9 +1063,15 @@ void gmx_prepare_tng_writing(const char* filename, tng_molecule_system_copy(*input, *output); tng_time_per_frame_get(*input, &time); - tng_time_per_frame_set(*output, time); - // Since we have copied the value from the input TNG we should not change it again - (*gmx_tng_output)->timePerFrameIsSet = true; + /* Only write the time per frame if it was written (and valid). E.g., single + * frame files do not usually contain any time per frame information. */ + if (time >= 0) + { + (*gmx_tng_input)->timePerFrameIsSet = true; + tng_time_per_frame_set(*output, time); + // Since we have copied the value from the input TNG we should not change it again + (*gmx_tng_output)->timePerFrameIsSet = true; + } tng_num_frames_per_frame_set_get(*input, &n_frames_per_frame_set); tng_num_frames_per_frame_set_set(*output, n_frames_per_frame_set);