Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
993be9f
Start generic netcdf data io class
drroe Sep 1, 2022
26d461d
Add id and initial creation of file
drroe Sep 1, 2022
a9be17e
Start getting dimensions
drroe Sep 1, 2022
db31546
Update files and dependencies
drroe Sep 1, 2022
ad02dac
Add to DataFile
drroe Sep 1, 2022
8a8e8ff
Start test
drroe Sep 1, 2022
4a4c9db
Indicate netcdf will be valid for 1d, 2d, 3d
drroe Sep 1, 2022
98f8a9d
Start adding sets
drroe Sep 1, 2022
8f5fca4
Save dimension indices for each set
drroe Sep 1, 2022
5c807d9
Define dimensions
drroe Sep 1, 2022
5fcd289
New grouping strategy
drroe Sep 2, 2022
4575126
Start defining variables
drroe Sep 2, 2022
61e3403
Choose type
drroe Sep 2, 2022
dc8d1e5
Add legends
drroe Sep 2, 2022
2301c06
Do variable write
drroe Sep 2, 2022
a772073
Do index write
drroe Sep 27, 2022
a4d3507
Put 1D set write into a separate routine
drroe Sep 27, 2022
81f61ad
Ensure all metadata is added to each variable
drroe Sep 28, 2022
e12d530
Add nctest
drroe Sep 29, 2022
b04cf41
Merge branch 'master' into netcdf.data
drroe Oct 4, 2022
f71b396
Merge branch 'master' into netcdf.data
drroe Oct 6, 2022
beb9419
Improve code docs
drroe Oct 6, 2022
f3c82ed
Add ifdef
drroe Oct 6, 2022
b5a134e
Start read. Ensure netcdf file is closed after read/write.
drroe Oct 6, 2022
395df94
Start inquiring about variables stored in the netcdf file
drroe Oct 6, 2022
0835452
Add monotonic attribute to distinguish between double and xymesh
drroe Oct 6, 2022
ada6e62
Start testing the mesh set
drroe Oct 6, 2022
e9cf5d4
Add DvalPtr function to DataSet_1D so writing XY mesh works correctly
drroe Oct 6, 2022
8f5d366
Added an xy mesh set
drroe Oct 6, 2022
8d740a8
Fix typo
drroe Oct 6, 2022
45c1530
Centralize recognized NetCDF conventions in the NC namespace.
drroe Oct 7, 2022
918b5a2
Use conventionsStr routine
drroe Oct 7, 2022
f8d42e8
Create single routine for creating the Conventions string
drroe Oct 7, 2022
5b636c6
Set Conventions string to CPPTRAJ_DATA
drroe Oct 7, 2022
0496367
Add note about keeping in sync with corresponding enum
drroe Oct 7, 2022
02bd5cd
Add 'index' attribute for variables. Remove AMBER application string.
drroe Oct 7, 2022
03ef4dd
Recognized index for a group of 1d vars
drroe Oct 7, 2022
bf55de0
Start reading data set metadata
drroe Oct 7, 2022
48c955c
Read more variables. Change index var status string from index to
drroe Oct 7, 2022
a0f13b6
Finish reading metadata. Add dataset description
drroe Oct 7, 2022
51802ed
Start a separate routine for xy mesh sets
drroe Oct 7, 2022
880d3e0
Separate routine for writing xy mesh sets
drroe Oct 7, 2022
d6697c8
Store min and step instead of explicit X and Y values for monotonic
drroe Oct 7, 2022
8feda48
Read descriptioin
drroe Oct 7, 2022
2c8541b
Add metadata and description to both xy sets
drroe Oct 7, 2022
928c664
Store varids for mesh
drroe Oct 11, 2022
9d1b85b
Save min and step only for the monotonic sets. Have xy mesh vars
drroe Oct 11, 2022
80538a7
Add function to get type from description
drroe Oct 11, 2022
87e09e7
Do XY mesh read
drroe Oct 11, 2022
6de7b2f
Make Resize a DataSet_1D function
drroe Oct 11, 2022
ba9dd5e
Implement Yptr to write to DataSet_1D underlying arrays
drroe Oct 11, 2022
45c5138
Read into generic 1d sets
drroe Oct 11, 2022
8e19f3d
New dimension labels. For XY mesh, only store attributes for the X var
drroe Oct 13, 2022
6b26ac4
Add more checks for reading XY mesh. Store attributes for X var only in
drroe Oct 13, 2022
350c81f
Ensure XY mesh is marked
drroe Oct 13, 2022
bf625a2
For backwards compat, if no label set for 1D set assume Frame
drroe Oct 13, 2022
b4c997e
Test netcdf data file read
drroe Oct 13, 2022
dcfdbbb
Enable netcdf data test
drroe Oct 13, 2022
cfa1f14
Add warning that not all data saved for PH sets
drroe Oct 13, 2022
7a62492
Fix variable type for PH set
drroe Oct 13, 2022
d0c9b9c
Ensure data set dimension label is stored
drroe Oct 13, 2022
03b1aed
Add some debug
drroe Oct 13, 2022
4a7ad0e
Start matrix write
drroe Oct 13, 2022
a6ed243
Start testing matrix write
drroe Oct 13, 2022
31b3fe1
Finish initial matrix write
drroe Oct 13, 2022
53548fa
Add missing breaks
drroe Oct 13, 2022
1f93d51
Ensure all 3 matrix kinds are written
drroe Oct 13, 2022
956710f
Store vect and mass if defined
drroe Oct 13, 2022
4524407
Add the ndim attribute
drroe Oct 13, 2022
bc11f59
More matrix stuff. New read routine that should hopefully make it easier
drroe Oct 13, 2022
9aa719d
Save nrows/ncols as attributes. Allocate matrix on read
drroe Oct 13, 2022
a586095
Actually read data
drroe Oct 13, 2022
8a1315d
Read matrix vect data
drroe Oct 14, 2022
b3553bf
Read matrix mass data
drroe Oct 14, 2022
d508ba0
Change ascii precision to override the default
drroe Oct 14, 2022
10ed802
Read nsnapshots
drroe Oct 14, 2022
f3ca92e
Test that netcdf matrix is diagonalized the same way after reading
drroe Oct 14, 2022
d212445
Comment out the old read routine
drroe Oct 14, 2022
b9d2458
Start modes write to netcdf. For netcdf, allow sets with different
drroe Oct 14, 2022
1320ad3
Consolidate variable creation
drroe Oct 14, 2022
1c8e542
Write the associated variables
drroe Oct 14, 2022
a8d7264
Mass write
drroe Oct 14, 2022
12d5698
Get rid of unused fxn
drroe Oct 16, 2022
e99a5f5
Get size of all modes-related vars
drroe Oct 17, 2022
45e1aa6
Read modes data
drroe Oct 17, 2022
b1b1c51
Compare original evecs with those written from the netcdf file
drroe Oct 17, 2022
6af202a
Merge branch 'master' into netcdf.data
drroe Oct 20, 2022
52f606e
Start a further abstraction of the netcdf functions
drroe Oct 20, 2022
e28ff5c
Fix classes. Update xy mesh write
drroe Oct 20, 2022
9305f44
Have read routine use the Dimensions_ array. Start putting individual
drroe Oct 21, 2022
c3d70dd
Put matrix read in its own routine
drroe Oct 21, 2022
a43b688
Split out generic 1d set read into its own function
drroe Oct 21, 2022
87bc5ab
Put modes read into its own function
drroe Oct 21, 2022
0f5685b
Update save with new var names
drroe Oct 21, 2022
2a6e704
Dont rely on const ref to the Dimensions_ array since it can change when
drroe Oct 21, 2022
6387f23
Test symmetric mass weighted covar
drroe Oct 21, 2022
9d64ee3
Test diag of mw covar
drroe Oct 21, 2022
97a3170
Add 3d grid write
drroe Oct 22, 2022
e9b0af6
Try to standardize the index dimension more
drroe Oct 24, 2022
3df312c
Create single function for adding index info. Have xy mesh set use it.
drroe Oct 25, 2022
d537a53
Use new index function for 1d and 2d sets
drroe Oct 25, 2022
7ba71cb
One function to add all common info from a dataset
drroe Oct 25, 2022
adeafe4
New function to read index dimension info
drroe Oct 26, 2022
930b9da
Try to get reads working. They dont yet.
drroe Oct 26, 2022
76680c6
Needed quotes, mistakenly was a variable.
drroe Oct 26, 2022
8cacebd
For backwards compatibility, sets with index variable instead of
drroe Oct 26, 2022
cff9a62
Merge branch 'master' into netcdf.data
drroe Nov 16, 2022
41d7ee6
Merge branch 'master' into netcdf.data.merge.master
drroe Nov 17, 2022
bae02cc
Merge branch 'master' into netcdf.data
drroe Nov 19, 2022
e4ca92e
Merge branch 'master' into netcdf.data
drroe Nov 21, 2022
1de934c
Add but do not enable 3d grid read yet
drroe Nov 21, 2022
c58d48f
Update clean rules
drroe Nov 22, 2022
77010c3
Start 3d read routine. Add origin and ucell attributes for grid.
drroe Nov 22, 2022
1db16a1
Finish 3d grid read and enable test
drroe Nov 22, 2022
5be1125
String write routine
drroe Nov 23, 2022
584a73f
Start adding string write to writeData_1D
drroe Nov 23, 2022
5accd4b
Finish string write
drroe Nov 23, 2022
2eeb607
Remove separate string write code. In writeData_1D now.
drroe Nov 23, 2022
8d847d4
Add a test that will write string data sets to netcdf
drroe Nov 23, 2022
1993140
Put xy mesh write into writeData_1D
drroe Nov 23, 2022
cb1eb45
Remove old xy write routine
drroe Nov 23, 2022
3c61831
Remove old x array code
drroe Nov 23, 2022
f62397f
Ensure string sets will be written if by themselves. Ensure other set
drroe Nov 23, 2022
44a46bf
Implement string set read
drroe Nov 28, 2022
69fd2ff
Create SetElement function for DataSet_string so that reading strings
drroe Nov 28, 2022
c3c57d4
Test string reads
drroe Nov 28, 2022
427e05b
Define vector variable
drroe Nov 28, 2022
13d1f32
Do vector set write. Use defineVar() to set child var id for string
drroe Nov 28, 2022
762c14d
Start adding a vector test
drroe Nov 28, 2022
e3f97f1
Read vector data
drroe Nov 28, 2022
bd485f9
Test read of vector data
drroe Nov 28, 2022
680fdae
Use NC::fmtTypeStr
drroe Nov 29, 2022
771b4dd
Clear up error message
drroe Nov 29, 2022
9e4c223
Do vector/scalar write. Needs to be separate because its currently a "0
drroe Nov 29, 2022
2543554
Add vector/scalar set read write
drroe Nov 29, 2022
bacb1fb
Merge branch 'master' into netcdf.data
drroe Nov 30, 2022
b8a39a4
Hide some debug info
drroe Dec 1, 2022
0a2a17c
Start new implementation of netcdf cluster matrix format
drroe Dec 2, 2022
3d75b6f
Do the cluster matrix variable writes
drroe Dec 2, 2022
b043a7f
Start adding a cluster matrix write test
drroe Dec 2, 2022
0439073
Merge branch 'master' into netcdf.data
drroe Dec 2, 2022
6d4ed85
Merge branch 'netcdf.data' into netcdf.data.cmatrix
drroe Dec 2, 2022
e8273ef
Merge branch 'master' into netcdf.data
drroe Dec 4, 2022
c5c84a2
Make cpptraj conventions check part of ID
drroe Dec 4, 2022
d81dd7d
Start cluster pairwise matrix read
drroe Dec 4, 2022
37428e3
Fix comment
drroe Dec 5, 2022
119c9c6
Finish pairwise matrix read
drroe Dec 5, 2022
97243b9
Add cluster pairwise test
drroe Dec 5, 2022
920e4b6
Add attributes for cluster pairwise matrix and change the ordering so
drroe Dec 5, 2022
a2034f2
Get rid of unused code
drroe Dec 5, 2022
5660e2d
Remove old code. Improve code docs
drroe Dec 5, 2022
78a2a52
Remove unneeded function
drroe Dec 5, 2022
c13daa5
Generalize AddDataSetIndexInfo so it can be used for any set
drroe Dec 5, 2022
a327829
If frames were sieved out of the pairwise cluster matrix (i.e. the
drroe Dec 5, 2022
b9d7600
Change nindexdim to nindexvar. Really it refers to index variables, not
drroe Dec 5, 2022
bc97d12
Update with nindexdim -> nindexvar
drroe Dec 5, 2022
fa70066
Update warning
drroe Dec 5, 2022
2e4f19c
Hide debug info
drroe Dec 5, 2022
8e01e53
Remove unused code
drroe Dec 5, 2022
fa96346
Remove more unused code
drroe Dec 5, 2022
b036ba8
Test user specified name for netcdf dataset read
drroe Dec 5, 2022
a79a764
Actually use user specfied name
drroe Dec 5, 2022
1730035
Test storing cluster num vs time in netcdf data along with pairwise
drroe Dec 5, 2022
83bc8a9
Change write for unsigned int set; netcdf classic does not have an
drroe Dec 5, 2022
017558d
Add routine for reading unsigned ints
drroe Dec 5, 2022
13d1074
Add test for read/write unsigned ints
drroe Dec 5, 2022
ebbc25a
Add netcdf data file format to table
drroe Dec 5, 2022
b4eac12
Version 6.16.3. Revision bump for addition of netcdf datafile
drroe Dec 5, 2022
dc6bc80
Use delete[] instead of incorrect delete
drroe Dec 5, 2022
6a13af7
Add missing arg for mprinterr
drroe Dec 5, 2022
933a798
Convert to size_t before multiply to prevent potential overflows.
drroe Dec 5, 2022
204634f
Ensure that if a grid is to be allocated, all processes allocate it
drroe Dec 5, 2022
8942e2e
Fix error message formatting
drroe Dec 5, 2022
c3e4d38
Try to fix TOCTOU issue
drroe Dec 6, 2022
1694217
Try to avoid multiplication overflows
drroe Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions doc/cpptraj.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -2911,7 +2911,7 @@ status open
\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="20" columns="5">
<lyxtabular version="3" rows="21" columns="5">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="20text%">
<column alignment="center" valignment="top" width="20text%">
Expand Down Expand Up @@ -3822,7 +3822,7 @@ Used for cluster analysis.
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Expand All @@ -3831,7 +3831,7 @@ Pairwise Cache (NetCDF)

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Expand All @@ -3840,7 +3840,7 @@ Pairwise Cache (NetCDF)

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Expand All @@ -3849,7 +3849,7 @@ nccmatrix

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Expand All @@ -3858,13 +3858,60 @@ pairwise distances

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Used for cluster analysis.
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
NetCDF Data
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
.nc
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
netcdf
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
All data
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Only state info saved for pH data.
\end_layout

\end_inset
</cell>
</row>
Expand Down
51 changes: 38 additions & 13 deletions src/Action_Bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Action_Bounds::Action_Bounds() :
outfile_(0),
offset_(1),
gridIsSetup_(false),
grid_(0),
ds_xmin_(0),
ds_ymin_(0),
Expand Down Expand Up @@ -44,6 +45,7 @@ Action::RetType Action_Bounds::Init(ArgList& actionArgs, ActionInit& init, int d
if (mask_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR;
std::string dsname = actionArgs.GetStringKey("name");
offset_ = actionArgs.getKeyInt("offset", 1);
gridIsSetup_ = false;
if (dxyz_[0] > -1.0) {
// Set up grid
if (dsname.empty()) {
Expand Down Expand Up @@ -127,14 +129,42 @@ int Action_Bounds::SyncAction() {
trajComm_.ReduceMaster( &buf, max_, 3, MPI_DOUBLE, MPI_MAX );
if (trajComm_.Master())
std::copy( buf, buf+3, max_ );
// Set up the grid here so all processes have it.
trajComm_.MasterBcast(min_, 3, MPI_DOUBLE);
trajComm_.MasterBcast(max_, 3, MPI_DOUBLE);
calc_center_and_bins();
return 0;
}
#endif

/** Calculate bounds center and grid bins based on min/max/spacing. */
int Action_Bounds::calc_center_and_bins() {
if (gridIsSetup_) return 0;
for (int i = 0; i < 3; i++) {
if (dxyz_[i] > 0.0) {
center_[i] = (max_[i] + min_[i]) / 2.0;
long int nbins = (long int)ceil( (max_[i] - min_[i]) / dxyz_[i] ) + (long int)offset_;
if (nbins < 0) {
mprinterr("Error: Overflow in bounds dim %i: max=%f min=%f spacing=%f\n",
i, max_[i], min_[i], dxyz_[i]);
return 1;
}
nxyz_[i] = (size_t)nbins;
}
}
if (grid_ != 0) {
DataSet_3D& grid3d = static_cast<DataSet_3D&>( *grid_ );
if (grid3d.Allocate_N_C_D( nxyz_[0], nxyz_[1], nxyz_[2], center_, dxyz_ )) {
mprinterr("Error: Could not allocate grid %s\n", grid_->legend());
return 1;
}
}
gridIsSetup_ = true;
return 0;
}

void Action_Bounds::Print() {
static const char cXYZ[3] = {'X', 'Y', 'Z'};
Vec3 center;
size_t nxyz[3];

mprintf(" BOUNDS: Output to %s\n", outfile_->Filename().full());
ds_xmin_->Add(0, min_ );
Expand All @@ -143,19 +173,14 @@ void Action_Bounds::Print() {
ds_xmax_->Add(0, max_ );
ds_ymax_->Add(0, max_+1);
ds_zmax_->Add(0, max_+2);

calc_center_and_bins();

for (int i = 0; i < 3; i++) {
outfile_->Printf("%f < %c < %f", min_[i], cXYZ[i], max_[i]);
if (dxyz_[i] > 0.0) {
center[i] = (max_[i] + min_[i]) / 2.0;
long int nbins = (long int)ceil( (max_[i] - min_[i]) / dxyz_[i] ) + (long int)offset_;
nxyz[i] = (size_t)nbins;
outfile_->Printf("\tCenter= %f Bins=%zu", center[i], nxyz[i]);
}
if (dxyz_[i] > 0.0)
outfile_->Printf("\tCenter= %f Bins=%zu", center_[i], nxyz_[i]);
outfile_->Printf("\n");
}
if (grid_ != 0) {
DataSet_3D& grid3d = static_cast<DataSet_3D&>( *grid_ );
if (grid3d.Allocate_N_C_D( nxyz[0], nxyz[1], nxyz[2], center, dxyz_ ))
mprinterr("Error: Could not allocate grid %s\n", grid_->legend());
}

}
21 changes: 14 additions & 7 deletions src/Action_Bounds.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef INC_ACTION_BOUNDS_H
#define INC_ACTION_BOUNDS_H
#include "Action.h"
#include <cstddef> // size_t
/// Report the min/max XYZ values for atoms in mask.
class Action_Bounds : public Action {
public:
Expand All @@ -16,13 +17,19 @@ class Action_Bounds : public Action {
Parallel::Comm trajComm_;
# endif
void Print();
AtomMask mask_;
CpptrajFile* outfile_;
double max_[3];
double min_[3];
Vec3 dxyz_;
int offset_;
DataSet* grid_;

int calc_center_and_bins();

AtomMask mask_; ///< Mask of atoms to obtain the bounds of.
CpptrajFile* outfile_; ///< File to print bounds to.
double max_[3]; ///< Minimum extent of any atom in mask.
double min_[3]; ///< Maximum extent of any atom in mask.
Vec3 dxyz_; ///< Grid spacing (if creating a grid from bounds).
size_t nxyz_[3]; ///< # grid bins in each dimension based on spacing.
Vec3 center_; ///< Grid center based on min/max.
int offset_; ///< # bins offset for grid.
bool gridIsSetup_; ///< True if grid has already been set up for bounds.
DataSet* grid_; ///< Hold grid created from bounds.
DataSet* ds_xmin_;
DataSet* ds_ymin_;
DataSet* ds_zmin_;
Expand Down
1 change: 1 addition & 0 deletions src/Cluster/Cframes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Cframes {
void clear() { frames_.clear(); }
void reserve(std::size_t n) { frames_.reserve(n); }
Iarray const& Data() const { return frames_; }
int* Ptr() { return &frames_[0]; }
bool empty() const { return frames_.empty(); }

bool HasFrame(int) const;
Expand Down
4 changes: 2 additions & 2 deletions src/Cluster/Cmatrix_NC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Cpptraj::Cluster::Cmatrix_NC::~Cmatrix_NC() {

/** \return true if NetCDF file has CPPTRAJ_CMATRIX conventions. */
bool Cpptraj::Cluster::Cmatrix_NC::IsCpptrajCmatrix(int NCID) {
return (NC::GetAttrText(NCID, "Conventions") == "CPPTRAJ_CMATRIX");
return (NC::GetConventions(NCID) == NC::NC_CPPTRAJCMATRIX);
}

#else /* BINTRAJ */
Expand Down Expand Up @@ -251,7 +251,7 @@ int Cpptraj::Cluster::Cmatrix_NC::CreateCmatrix(FileName const& fname, unsigned
actualFrames_VID_ = -1;

// Attributes
if (NC::CheckErr(nc_put_att_text(ncid_, NC_GLOBAL, "Conventions", 15, "CPPTRAJ_CMATRIX")))
if (NC::PutConventions(ncid_, NC::NC_CPPTRAJCMATRIX))
return 1;
if (NC::CheckErr(nc_put_att_text(ncid_, NC_GLOBAL, "Version", 3, "1.0")))
return 1;
Expand Down
27 changes: 19 additions & 8 deletions src/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "DataIO_Cmatrix_Binary.h"
#include "DataIO_Cmatrix_NC.h"
#include "DataIO_Peaks.h"
#include "DataIO_NetCDF.h"
#include "DataIO_AmberEne.h"

// CONSTRUCTOR
Expand Down Expand Up @@ -76,10 +77,16 @@ const FileTypes::AllocToken DataFile::DF_AllocArray[] = {
{ "Pairwise Cache (NetCDF)", 0, 0, 0 },
# endif
{ "Peaks", 0, 0, DataIO_Peaks::Alloc },
# ifdef BINTRAJ
{ "NetCDF data", 0, 0, DataIO_NetCDF::Alloc },
# else
{ "NetCDF data", 0, 0, 0 },
# endif
{ "Amber Energy File", 0, 0, DataIO_AmberEne::Alloc},
{ "Unknown Data file", 0, 0, 0 }
};

/** Types that support reads. */
const FileTypes::KeyToken DataFile::DF_KeyArray[] = {
{ DATAFILE, "dat", ".dat" },
{ XMGRACE, "grace", ".agr" },
Expand All @@ -96,6 +103,7 @@ const FileTypes::KeyToken DataFile::DF_KeyArray[] = {
{ CHARMMREPD, "charmmrepd", ".exch" },
{ CHARMMOUT, "charmmout", ".charmmout"},
{ CHARMMRTFPRM, "charmmrtfprm", ".rtfprm"},
{ NETCDFDATA, "netcdf", ".nc" },
{ CMATRIX_BINARY,"cmatrix", ".cmatrix" },
{ CMATRIX_NETCDF,"nccmatrix", ".nccmatrix" },
{ PEAKS, "peaks", ".peaks" },
Expand All @@ -120,6 +128,7 @@ const FileTypes::KeyToken DataFile::DF_WriteKeyArray[] = {
{ CMATRIX_NETCDF,"nccmatrix", ".nccmatrix" },
{ CHARMMRTFPRM, "charmmrtfprm", ".prm" },
{ PEAKS, "peaks", ".peaks" },
{ NETCDFDATA, "netcdf", ".nc" },
{ UNKNOWN_DATA, 0, 0 }
};

Expand Down Expand Up @@ -333,13 +342,15 @@ int DataFile::AddDataSet(DataSet* dataIn) {
dataIn->legend());
}
} else {
if ((int)dataIn->Ndim() != dimension_) {
mprinterr("Error: DataSets in DataFile %s have dimension %i\n"
"Error: Attempting to add set %s of dimension %zu\n",
filename_.base(), dimension_,
dataIn->legend(), dataIn->Ndim());
return Error("Error: Adding DataSets with different dimensions to same file"
" is currently unsupported.\n");
if (Type() != NETCDFDATA) {
if ((int)dataIn->Ndim() != dimension_) {
mprinterr("Error: DataSets in DataFile %s have dimension %i\n"
"Error: Attempting to add set %s of dimension %zu\n",
filename_.base(), dimension_,
dataIn->legend(), dataIn->Ndim());
return Error("Error: Adding DataSets with different dimensions to same file"
" is currently unsupported.\n");
}
}
if (!dataio_->CheckValidFor(*dataIn)) {
mprinterr("Error: DataSet '%s' is not valid for DataFile '%s' format.\n",
Expand Down Expand Up @@ -501,7 +512,7 @@ int DataFile::WriteSetsToFile(FileName const& fname, DataSetList& setsToWrite)
dftimer.Total());
# endif
if (err > 0)
mprinterr("Error writing %iD Data to %s\n", dimension_, fname.base());
mprinterr("Error: Could not write data sets to %s\n", fname.base());
}
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DataFile {
DATAFILE=0, XMGRACE, GNUPLOT, XPLOR, OPENDX, REMLOG, MDOUT, EVECS,
VECTRAJ, XVG, CCP4, CHARMMREPD, CHARMMFASTREP,
CHARMMOUT, CPOUT, CHARMMRTFPRM, CMATRIX_BINARY, CMATRIX_NETCDF, PEAKS,
AMBERENE,
NETCDFDATA, AMBERENE,
UNKNOWN_DATA
};
DataFile();
Expand Down
Loading