28 std::vector< std::string >::iterator vecIt;
29 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"Time" ) ) != dimNames.end() )
30 tDim = vecIt - dimNames.begin();
31 else if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
32 tDim = vecIt - dimNames.begin();
35 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'Time' or 'time' dimension" );
40 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"layers" ) ) != dimNames.end() )
41 levDim = vecIt - dimNames.begin();
44 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'layers' dimension" );
76 if( procs - 1 == rank )
77 assert(
"PARALLEL_RESOLVE_SHARED_ENTS option is set" &&
localVertsOwned.
size() < num_local_verts );
121 std::vector< unsigned int > opt_lev_dims;
123 unsigned int lev_idx;
124 std::vector< std::string >::iterator vecIt;
127 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"interfaces" ) ) != dimNames.end() )
129 lev_idx = vecIt - dimNames.begin();
130 opt_lev_dims.push_back( lev_idx );
133 std::map< std::string, WriteNC::VarData >& varInfo =
_writeNC->
varInfo;
135 for(
size_t i = 0; i < var_names.size(); i++ )
137 std::string varname = var_names[i];
138 std::map< std::string, WriteNC::VarData >::iterator vit = varInfo.find( varname );
139 if( vit == varInfo.end() )
MB_SET_ERR( MB_FAILURE,
"Can't find variable " << varname );
142 std::vector< int >& varDims = currentVarData.
varDims;
148 if( std::find( varDims.begin(), varDims.end(),
levDim ) == varDims.end() )
150 for(
unsigned int j = 0; j < opt_lev_dims.size(); j++ )
152 if( std::find( varDims.begin(), varDims.end(), opt_lev_dims[j] ) != varDims.end() )
154 currentVarData.
numLev = dimLens[opt_lev_dims[j]];
167 unsigned int dim_idx = 0;
175 assert( 3 == varDims.size() || 2 == varDims.size() );
178 assert(
tDim == varDims[0] );
189 assert( 2 == varDims.size() || 1 == varDims.size() );
193 switch( currentVarData.
entLoc )
217 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << varname );
223 if( currentVarData.
numLev > 0 )
228 assert( 3 == varDims.size() || 2 == varDims.size() );
239 assert( 2 == varDims.size() || 1 == varDims.size() );
243 currentVarData.
sz = 1;
244 for( std::size_t idx = 0; idx < dim_idx; idx++ )
258 for(
unsigned int i = 0; i < vdatas.size(); i++ )
266 Range* pLocalEntsOwned = NULL;
267 Range* pLocalGidEntsOwned = NULL;
268 switch( variableData.
entLoc )
286 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << variableData.
varName );
289 unsigned int num_timesteps;
290 unsigned int ents_idx = 0;
296 num_timesteps = tstep_nums.size();
307 unsigned int num_lev;
308 if( variableData.
numLev > 0 )
313 num_lev = variableData.
numLev;
323 for(
unsigned int t = 0; t < num_timesteps; t++ )
329 std::vector< double > tag_data( pLocalEntsOwned->
size() * num_lev );
332 #ifdef MOAB_HAVE_PNETCDF
333 size_t nb_writes = pLocalGidEntsOwned->
psize();
334 std::vector< int > requests( nb_writes ), statuss( nb_writes );
343 size_t indexInDoubleArray = 0;
346 pair_iter != pLocalGidEntsOwned->
pair_end(); ++pair_iter, ic++ )
354 #ifdef MOAB_HAVE_PNETCDF
359 &( tag_data[indexInDoubleArray] ), &requests[idxReq++] );
363 &( variableData.
writeCounts[0] ), &( tag_data[indexInDoubleArray] ) );
367 "Failed to write double data in a loop for variable " << variableData.
varName );
370 indexInDoubleArray += ( endh - starth + 1 ) * num_lev;
372 assert( ic == pLocalGidEntsOwned->
psize() );
373 #ifdef MOAB_HAVE_PNETCDF
374 success = ncmpi_wait_all(
_fileId, requests.size(), &requests[0], &statuss[0] );
375 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );