26 std::vector< std::string >::iterator vecIt;
27 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
28 tDim = vecIt - dimNames.begin();
31 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'time' dimension" );
36 if( ( vecIt = std::find( dimNames.begin(), dimNames.end(),
"lev" ) ) != dimNames.end() )
37 levDim = vecIt - dimNames.begin();
40 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lev' dimension" );
46 "Trouble getting local vertices in current file set" );
62 "Trouble getting owned vertices in current set" );
66 if( procs - 1 == rank )
67 assert(
"PARALLEL_RESOLVE_SHARED_ENTS option is set" &&
localVertsOwned.
size() < num_local_verts );
74 "Trouble getting global IDs on local vertices" );
88 for(
size_t i = 0; i < var_names.size(); i++ )
90 std::string varname = var_names[i];
91 std::map< std::string, WriteNC::VarData >::iterator vit = varInfo.find( varname );
92 if( vit == varInfo.end() )
MB_SET_ERR( MB_FAILURE,
"Can't find variable " << varname );
97 std::vector< int >& varDims = currentVarData.
varDims;
107 unsigned int dim_idx = 0;
115 assert( 3 == varDims.size() || 2 == varDims.size() );
118 assert(
tDim == varDims[0] );
129 assert( 2 == varDims.size() || 1 == varDims.size() );
133 if( currentVarData.
numLev > 0 )
138 assert( 3 == varDims.size() || 2 == varDims.size() );
149 assert( 2 == varDims.size() || 1 == varDims.size() );
153 switch( currentVarData.
entLoc )
163 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << varname );
168 currentVarData.
sz = 1;
169 for( std::size_t idx = 0; idx < dim_idx; idx++ )
177 std::vector< int >& tstep_nums )
185 for(
unsigned int i = 0; i < vdatas.size(); i++ )
190 switch( variableData.
entLoc )
196 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << variableData.
varName );
199 unsigned int num_timesteps;
200 unsigned int ncol_idx = 0;
206 num_timesteps = tstep_nums.size();
217 unsigned int num_lev;
218 if( variableData.
numLev > 0 )
223 num_lev = variableData.
numLev;
236 for(
unsigned int t = 0; t < num_timesteps; t++ )
243 std::vector< double > tag_data( num_local_verts_owned * num_lev );
245 "Trouble getting tag data on owned vertices" );
247 #ifdef MOAB_HAVE_PNETCDF
249 std::vector< int > requests( nb_writes ), statuss( nb_writes );
258 std::vector< double > tmpdoubledata( num_local_verts_owned * num_lev );
263 jik_to_kji_stride( num_local_verts_owned, 1, num_lev, &tmpdoubledata[0], &tag_data[0],
267 size_t indexInDoubleArray = 0;
278 #ifdef MOAB_HAVE_PNETCDF
283 &( tmpdoubledata[indexInDoubleArray] ), &requests[idxReq++] );
287 &( variableData.
writeCounts[0] ), &( tmpdoubledata[indexInDoubleArray] ) );
291 "Failed to write double data in a loop for variable " << variableData.
varName );
294 indexInDoubleArray += ( endh - starth + 1 ) * num_lev;
297 #ifdef MOAB_HAVE_PNETCDF
298 success = ncmpi_wait_all(
_fileId, requests.size(), &requests[0], &statuss[0] );
299 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );