28 std::vector< std::string >::iterator vecIt;
29 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
30 tDim = vecIt - dimNames.begin();
33 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'time' dimension" );
38 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"lev" ) ) != dimNames.end() )
39 levDim = vecIt - dimNames.begin();
42 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lev' dimension" );
66 if( procs - 1 == rank )
67 assert(
"PARALLEL_RESOLVE_SHARED_ENTS option is set" &&
localVertsOwned.
size() < num_local_verts );
87 for(
size_t i = 0; i < var_names.size(); i++ )
89 std::string varname = var_names[i];
90 std::map< std::string, WriteNC::VarData >::iterator vit = varInfo.find( varname );
91 if( vit == varInfo.end() )
MB_SET_ERR( MB_FAILURE,
"Can't find variable " << varname );
96 std::vector< int >& varDims = currentVarData.
varDims;
106 unsigned int dim_idx = 0;
114 assert( 3 == varDims.size() || 2 == varDims.size() );
117 assert(
tDim == varDims[0] );
128 assert( 2 == varDims.size() || 1 == varDims.size() );
132 if( currentVarData.
numLev > 0 )
137 assert( 3 == varDims.size() || 2 == varDims.size() );
148 assert( 2 == varDims.size() || 1 == varDims.size() );
152 switch( currentVarData.
entLoc )
162 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << varname );
167 currentVarData.
sz = 1;
168 for( std::size_t idx = 0; idx < dim_idx; idx++ )
176 std::vector< int >& tstep_nums )
184 for(
unsigned int i = 0; i < vdatas.size(); i++ )
189 switch( variableData.
entLoc )
195 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << variableData.
varName );
198 unsigned int num_timesteps;
199 unsigned int ncol_idx = 0;
205 num_timesteps = tstep_nums.size();
216 unsigned int num_lev;
217 if( variableData.
numLev > 0 )
222 num_lev = variableData.
numLev;
235 for(
unsigned int t = 0; t < num_timesteps; t++ )
242 std::vector< double > tag_data( num_local_verts_owned * num_lev );
245 #ifdef MOAB_HAVE_PNETCDF
247 std::vector< int > requests( nb_writes ), statuss( nb_writes );
256 std::vector< double > tmpdoubledata( num_local_verts_owned * num_lev );
261 jik_to_kji_stride( num_local_verts_owned, 1, num_lev, &tmpdoubledata[0], &tag_data[0],
265 size_t indexInDoubleArray = 0;
276 #ifdef MOAB_HAVE_PNETCDF
281 &( tmpdoubledata[indexInDoubleArray] ), &requests[idxReq++] );
285 &( variableData.
writeCounts[0] ), &( tmpdoubledata[indexInDoubleArray] ) );
289 "Failed to write double data in a loop for variable " << variableData.
varName );
292 indexInDoubleArray += ( endh - starth + 1 ) * num_lev;
295 #ifdef MOAB_HAVE_PNETCDF
296 success = ncmpi_wait_all(
_fileId, requests.size(), &requests[0], &statuss[0] );
297 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );