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(),
"nVertLevels" ) ) != dimNames.end() )
41 levDim = vecIt - dimNames.begin();
44 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'nVertLevels' 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(),
"nVertLevelsP1" ) ) != dimNames.end() )
129 lev_idx = vecIt - dimNames.begin();
130 opt_lev_dims.push_back( lev_idx );
134 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"nVertLevelsP2" ) ) != dimNames.end() )
136 lev_idx = vecIt - dimNames.begin();
137 opt_lev_dims.push_back( lev_idx );
141 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"nSoilLevels" ) ) != dimNames.end() )
143 lev_idx = vecIt - dimNames.begin();
144 opt_lev_dims.push_back( lev_idx );
147 std::map< std::string, WriteNC::VarData >& varInfo =
_writeNC->
varInfo;
149 for(
size_t i = 0; i < var_names.size(); i++ )
151 std::string varname = var_names[i];
152 std::map< std::string, WriteNC::VarData >::iterator vit = varInfo.find( varname );
153 if( vit == varInfo.end() )
MB_SET_ERR( MB_FAILURE,
"Can't find variable " << varname );
156 std::vector< int >& varDims = currentVarData.
varDims;
162 if( std::find( varDims.begin(), varDims.end(),
levDim ) == varDims.end() )
164 for(
unsigned int j = 0; j < opt_lev_dims.size(); j++ )
166 if( std::find( varDims.begin(), varDims.end(), opt_lev_dims[j] ) != varDims.end() )
168 currentVarData.
numLev = dimLens[opt_lev_dims[j]];
181 unsigned int dim_idx = 0;
189 assert( 3 == varDims.size() || 2 == varDims.size() );
192 assert(
tDim == varDims[0] );
203 assert( 2 == varDims.size() || 1 == varDims.size() );
207 switch( currentVarData.
entLoc )
231 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << varname );
237 if( currentVarData.
numLev > 0 )
242 assert( 3 == varDims.size() || 2 == varDims.size() );
253 assert( 2 == varDims.size() || 1 == varDims.size() );
257 currentVarData.
sz = 1;
258 for( std::size_t idx = 0; idx < dim_idx; idx++ )
272 for(
unsigned int i = 0; i < vdatas.size(); i++ )
280 Range* pLocalEntsOwned = NULL;
281 Range* pLocalGidEntsOwned = NULL;
282 switch( variableData.
entLoc )
300 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << variableData.
varName );
303 unsigned int num_timesteps;
304 unsigned int ents_idx = 0;
310 num_timesteps = tstep_nums.size();
321 unsigned int num_lev;
322 if( variableData.
numLev > 0 )
327 num_lev = variableData.
numLev;
337 for(
unsigned int t = 0; t < num_timesteps; t++ )
343 std::vector< double > tag_data( pLocalEntsOwned->
size() * num_lev );
346 #ifdef MOAB_HAVE_PNETCDF
347 size_t nb_writes = pLocalGidEntsOwned->
psize();
348 std::vector< int > requests( nb_writes ), statuss( nb_writes );
357 size_t indexInDoubleArray = 0;
360 pair_iter != pLocalGidEntsOwned->
pair_end(); ++pair_iter, ic++ )
368 #ifdef MOAB_HAVE_PNETCDF
373 &( tag_data[indexInDoubleArray] ), &requests[idxReq++] );
377 &( variableData.
writeCounts[0] ), &( tag_data[indexInDoubleArray] ) );
381 "Failed to write double data in a loop for variable " << variableData.
varName );
384 indexInDoubleArray += ( endh - starth + 1 ) * num_lev;
386 assert( ic == pLocalGidEntsOwned->
psize() );
387 #ifdef MOAB_HAVE_PNETCDF
388 success = ncmpi_wait_all(
_fileId, requests.size(), &requests[0], &statuss[0] );
389 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );