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 ) ) ) |
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); |
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 |
} |
} |