/[escript]/trunk/escript/src/DataFactory.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 950 by gross, Tue Feb 6 07:01:11 2007 UTC revision 967 by gross, Tue Feb 13 09:40:12 2007 UTC
# Line 115  load(const std::string fileName, Line 115  load(const std::string fileName,
115     delete type_str;     delete type_str;
116     /* recover dimension */     /* recover dimension */
117     int ndims=dataFile.num_dims();     int ndims=dataFile.num_dims();
118     int ntags =0 , nsamples =0 , ndata_points_per_sample =0, d=0;     int ntags =0 , num_samples =0 , num_data_points_per_sample =0, d=0;
119     NcDim *d_dim, *tags_dim, *samples_dim, *data_points_per_sample_dim;     NcDim *d_dim, *tags_dim, *num_samples_dim, *num_data_points_per_sample_dim;
120     /* recover shape */     /* recover shape */
121     DataArrayView::ShapeType shape;     DataArrayView::ShapeType shape;
122     long dims[DataArrayView::maxRank+2];     long dims[DataArrayView::maxRank+2];
# Line 180  load(const std::string fileName, Line 180  load(const std::string fileName,
180        /* expanded data */        /* expanded data */
181        if ( ! (ndims == rank + 2) )        if ( ! (ndims == rank + 2) )
182            throw DataException("Error - load:: illegal number of dimensions for exanded data in netCDF file.");            throw DataException("Error - load:: illegal number of dimensions for exanded data in netCDF file.");
183        if ( ! (samples_dim = dataFile.get_dim("samples") ) )        if ( ! (num_samples_dim = dataFile.get_dim("num_samples") ) )
184            throw DataException("Error - load:: unable to recover number of samples from netCDF file.");            throw DataException("Error - load:: unable to recover number of samples from netCDF file.");
185        nsamples = samples_dim->size();        num_samples = num_samples_dim->size();
186        if ( ! (data_points_per_sample_dim = dataFile.get_dim("data_points_per_sample") ) )        if ( ! (num_data_points_per_sample_dim = dataFile.get_dim("num_data_points_per_sample") ) )
187            throw DataException("Error - load:: unable to recover number of data points per sample from netCDF file.");            throw DataException("Error - load:: unable to recover number of data points per sample from netCDF file.");
188        ndata_points_per_sample=data_points_per_sample_dim->size();        num_data_points_per_sample=num_data_points_per_sample_dim->size();
189        out=Data(0,shape,function_space);        // add checks!
190          if ( ! (num_samples == function_space.getNumSamples() && num_data_points_per_sample == function_space.getNumDataPointsPerSample()) )
191              throw DataException("Error - load:: data sample layout of file does not match data layout of function space.");
192          dims[rank]=num_data_points_per_sample;
193          dims[rank+1]=num_samples;
194          out=Data(0,shape,function_space,true);
195          if (!(var = dataFile.get_var("data")))
196                  throw DataException("Error - load:: unable to find data in netCDF file.");
197          if (! var->get(&(out.getDataPoint(0,0).getData()[0]), dims) )
198                  throw DataException("Error - load:: unable to recover data from netCDF file.");
199     } else {     } else {
200         throw DataException("Error - load:: unknown escript data type in netCDF file.");         throw DataException("Error - load:: unknown escript data type in netCDF file.");
201     }     }

Legend:
Removed from v.950  
changed lines
  Added in v.967

  ViewVC Help
Powered by ViewVC 1.1.26