/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#include "tngio_for_tools.h"
+#include "gmxpre.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "tngio_for_tools.h"
-#include <vector>
+#include "config.h"
-#include "tngio.h"
-#include "trx.h"
+#include <math.h>
#ifdef GMX_USE_TNG
-#include "../../external/tng_io/include/tng_io.h"
+#include "tng/tng_io.h"
#endif
+#include "gromacs/fileio/tngio.h"
+#include "gromacs/fileio/trx.h"
+#include "gromacs/math/units.h"
#include "gromacs/utility/common.h"
-#include "gromacs/legacyheaders/types/atoms.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/physics.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/tools/dump.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
void gmx_prepare_tng_writing(const char *filename,
char mode,
"FORCES", "LAMBDAS"
};
+ 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 char*,
+ const char,
+ const char);
+#ifdef GMX_DOUBLE
+ set_writing_interval_func_pointer set_writing_interval = tng_util_generic_write_interval_double_set;
+#else
+ set_writing_interval_func_pointer set_writing_interval = tng_util_generic_write_interval_set;
+#endif
gmx_tng_open(filename, mode, output);
{
case TNG_TRAJ_POSITIONS:
case TNG_TRAJ_VELOCITIES:
- tng_util_generic_write_interval_set(*output, interval, 3, fallbackIds[i],
- fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
- compression_type);
+ set_writing_interval(*output, interval, 3, fallbackIds[i],
+ fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
+ compression_type);
break;
case TNG_TRAJ_FORCES:
- tng_util_generic_write_interval_set(*output, interval, 3, fallbackIds[i],
- fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
- TNG_GZIP_COMPRESSION);
+ set_writing_interval(*output, interval, 3, fallbackIds[i],
+ fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
+ TNG_GZIP_COMPRESSION);
break;
case TNG_TRAJ_BOX_SHAPE:
- tng_util_generic_write_interval_set(*output, interval, 9, fallbackIds[i],
- fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
- TNG_GZIP_COMPRESSION);
+ set_writing_interval(*output, interval, 9, fallbackIds[i],
+ fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
+ TNG_GZIP_COMPRESSION);
break;
case TNG_GMX_LAMBDA:
- tng_util_generic_write_interval_set(*output, interval, 1, fallbackIds[i],
- fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
- TNG_GZIP_COMPRESSION);
+ set_writing_interval(*output, interval, 1, fallbackIds[i],
+ fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
+ TNG_GZIP_COMPRESSION);
default:
continue;
}
GMX_UNUSED_VALUE(input);
GMX_UNUSED_VALUE(output);
GMX_UNUSED_VALUE(nAtoms);
+ GMX_UNUSED_VALUE(mtop);
+ GMX_UNUSED_VALUE(index);
+ GMX_UNUSED_VALUE(indexGroupName);
#endif
}
#else
GMX_UNUSED_VALUE(output);
GMX_UNUSED_VALUE(frame);
+ GMX_UNUSED_VALUE(natoms);
#endif
}
gmx_bool bOK = TRUE;
tng_function_status stat;
gmx_int64_t numberOfAtoms = -1, frameNumber = -1;
- gmx_int64_t nBlocks, blockId, *blockIds = NULL;
- char datatype = -1, codecId;
+ gmx_int64_t nBlocks, blockId, *blockIds = NULL, codecId;
+ char datatype = -1;
void *values = NULL;
double frameTime = -1.0;
int size, blockDependency;
- float prec;
+ double prec;
const int defaultNumIds = 5;
static gmx_int64_t fallbackRequestedIds[defaultNumIds] =
{
size = sizeof(double);
break;
default:
- size = 0; /* Just to make the compiler happy. */
gmx_incons("Illegal datatype of box shape values!");
}
for (int i = 0; i < DIM; i++)
{
convert_array_to_real_array((char *)(values) + size * i * DIM,
- (real *) fr->box[i],
- getDistanceScaleFactor(input),
- 1,
- DIM,
- datatype);
+ (real *) fr->box[i],
+ getDistanceScaleFactor(input),
+ 1,
+ DIM,
+ datatype);
}
fr->bBox = TRUE;
break;
case TNG_TRAJ_POSITIONS:
srenew(fr->x, fr->natoms);
convert_array_to_real_array(values,
- (real *) fr->x,
- getDistanceScaleFactor(input),
- fr->natoms,
- DIM,
- datatype);
+ (real *) fr->x,
+ getDistanceScaleFactor(input),
+ fr->natoms,
+ DIM,
+ datatype);
fr->bX = TRUE;
tng_util_frame_current_compression_get(input, blockId, &codecId, &prec);
/* This must be updated if/when more lossy compression methods are added */
case TNG_TRAJ_VELOCITIES:
srenew(fr->v, fr->natoms);
convert_array_to_real_array(values,
- (real *) fr->v,
- getDistanceScaleFactor(input),
- fr->natoms,
- DIM,
- datatype);
+ (real *) fr->v,
+ getDistanceScaleFactor(input),
+ fr->natoms,
+ DIM,
+ datatype);
fr->bV = TRUE;
tng_util_frame_current_compression_get(input, blockId, &codecId, &prec);
/* This must be updated if/when more lossy compression methods are added */
case TNG_TRAJ_FORCES:
srenew(fr->f, fr->natoms);
convert_array_to_real_array(values,
- (real *) fr->f,
- getDistanceScaleFactor(input),
- fr->natoms,
- DIM,
- datatype);
+ (real *) fr->f,
+ getDistanceScaleFactor(input),
+ fr->natoms,
+ DIM,
+ datatype);
fr->bF = TRUE;
break;
case TNG_GMX_LAMBDA:
GMX_UNUSED_VALUE(input);
GMX_UNUSED_VALUE(fr);
GMX_UNUSED_VALUE(requestedIds);
+ GMX_UNUSED_VALUE(numRequestedIds);
return FALSE;
#endif
}
{
#ifdef GMX_USE_TNG
tng_function_status stat;
- char datatype = -1, codecId;
+ char datatype = -1;
+ gmx_int64_t codecId;
int blockDependency;
void *data = 0;
- float localPrec;
+ double localPrec;
stat = tng_data_block_name_get(input, blockId, name, maxLen);
if (stat != TNG_SUCCESS)
}
snew(*values, sizeof(real) * *nValuesPerFrame * *nAtoms);
convert_array_to_real_array(data,
- *values,
- getDistanceScaleFactor(input),
- *nAtoms,
- *nValuesPerFrame,
- datatype);
+ *values,
+ getDistanceScaleFactor(input),
+ *nAtoms,
+ *nValuesPerFrame,
+ datatype);
tng_util_frame_current_compression_get(input, blockId, &codecId, &localPrec);
return FALSE;
#endif
}
-
-void list_tng_for_gmx_dump(const char *fn)
-{
-#ifdef GMX_USE_TNG
- tng_trajectory_t tng;
- gmx_int64_t nframe = 0;
- gmx_int64_t i, *block_ids = NULL, step, ndatablocks;
- gmx_bool bOK;
-
- gmx_tng_open(fn, 'r', &tng);
- gmx_print_tng_molecule_system(tng, stdout);
-
- bOK = gmx_get_tng_data_block_types_of_next_frame(tng, -1,
- 0,
- NULL,
- &step, &ndatablocks,
- &block_ids);
- do
- {
- for (i = 0; i < ndatablocks; i++)
- {
- double frame_time;
- real prec, *values = NULL;
- gmx_int64_t n_values_per_frame, n_atoms;
- char block_name[STRLEN];
-
- gmx_get_tng_data_next_frame_of_block_type(tng, block_ids[i], &values,
- &step, &frame_time,
- &n_values_per_frame, &n_atoms,
- &prec,
- block_name, STRLEN, &bOK);
- if (!bOK)
- {
- /* Can't write any output because we don't know what
- arrays are valid. */
- fprintf(stderr, "\nWARNING: Incomplete frame at time %g, will not write output\n", frame_time);
- list_tng_inner(fn, (0 == i), values, step, frame_time,
- n_values_per_frame, n_atoms, prec, nframe, block_name);
- }
- }
- nframe++;
- }
- while (gmx_get_tng_data_block_types_of_next_frame(tng, step,
- 0,
- NULL,
- &step,
- &ndatablocks,
- &block_ids));
-
- if (block_ids)
- {
- sfree(block_ids);
- }
-
- gmx_tng_close(&tng);
-#else
- GMX_UNUSED_VALUE(fn);
-#endif
-}