/[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 967 by gross, Tue Feb 13 09:40:12 2007 UTC revision 982 by gross, Mon Feb 19 23:55:52 2007 UTC
# Line 150  load(const std::string fileName, Line 150  load(const std::string fileName,
150     }     }
151     /* recover stuff */     /* recover stuff */
152     Data out;     Data out;
153     NcVar *var;     NcVar *var, *ids_var;
154     if (type == 0) {     if (type == 0) {
155        /* constant data */        /* constant data */
156        if ( ! ( (ndims == rank && rank >0) || ( ndims ==1 && rank == 0 ) ) )        if ( ! ( (ndims == rank && rank >0) || ( ndims ==1 && rank == 0 ) ) )
# Line 186  load(const std::string fileName, Line 186  load(const std::string fileName,
186        if ( ! (num_data_points_per_sample_dim = dataFile.get_dim("num_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        num_data_points_per_sample=num_data_points_per_sample_dim->size();        num_data_points_per_sample=num_data_points_per_sample_dim->size();
189        // add checks!        // check shape:
190        if ( ! (num_samples == function_space.getNumSamples() && num_data_points_per_sample == function_space.getNumDataPointsPerSample()) )        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.");            throw DataException("Error - load:: data sample layout of file does not match data layout of function space.");
192          // get ids
193          if (! ( ids_var = dataFile.get_var("id")) )
194             throw DataException("Error - load:: unable to find reference ids in netCDF file.");
195          const int* ids_p=function_space.borrowSampleReferenceIDs();
196          int ids_of_nc[num_samples];
197          if (! ids_var->get(ids_of_nc, (long) num_samples) )
198                  throw DataException("Error - load:: unable to recover ids from netCDF file.");
199          // check order:
200          int failed=-1, local_failed=-1, i;
201          #pragma omp parallel private(local_failed)
202          {
203              #pragma omp for private(i) schedule(static)
204              for (i=0;i < num_samples; ++i)
205                  if (ids_of_nc[i]!=ids_p[i]) local_failed=i;
206              #pragma omp critical
207              if (local_failed>=0) failed = local_failed;
208          }
209          if (failed>=0)
210              throw DataException("Error - load:: data ordering in netCDF file does not match ordering of FunctionSpace.");
211          // get the data:
212        dims[rank]=num_data_points_per_sample;        dims[rank]=num_data_points_per_sample;
213        dims[rank+1]=num_samples;        dims[rank+1]=num_samples;
214        out=Data(0,shape,function_space,true);        out=Data(0,shape,function_space,true);
# Line 196  load(const std::string fileName, Line 216  load(const std::string fileName,
216                throw DataException("Error - load:: unable to find data in netCDF file.");                throw DataException("Error - load:: unable to find data in netCDF file.");
217        if (! var->get(&(out.getDataPoint(0,0).getData()[0]), dims) )        if (! var->get(&(out.getDataPoint(0,0).getData()[0]), dims) )
218                throw DataException("Error - load:: unable to recover data from netCDF file.");                throw DataException("Error - load:: unable to recover data from netCDF file.");
219          // if (failed==-1)
220          //   out->m_data.reorderByReferenceIDs(ids_of_nc)
221     } else {     } else {
222         throw DataException("Error - load:: unknown escript data type in netCDF file.");         throw DataException("Error - load:: unknown escript data type in netCDF file.");
223     }     }

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

  ViewVC Help
Powered by ViewVC 1.1.26