17 std::vector< std::string >& dimNames = readNC->
dimNames;
20 if( ( std::find( dimNames.begin(), dimNames.end(), std::string(
"n" ) ) != dimNames.end() ) &&
21 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"ni" ) ) != dimNames.end() ) &&
22 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"nj" ) ) != dimNames.end() ) &&
23 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"nv" ) ) != dimNames.end() ) )
26 std::map< std::string, ReadNC::AttData >::iterator attIt = readNC->
globalAtts.find(
"source" );
27 if( attIt == readNC->
globalAtts.end() )
return false;
28 unsigned int sz = attIt->second.attLen;
30 att_data.resize( sz + 1 );
31 att_data[sz] =
'\000';
33 NCFUNC( get_att_text )( fileId, attIt->second.attVarId, attIt->second.attName.c_str(), &att_data[0] );
34 if( success )
return false;
49 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
61 std::vector< std::string >::iterator vit;
63 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"ni" ) ) != dimNames.end() )
64 idx = vit - dimNames.begin();
67 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'ni' variable" );
71 gDims[3] = dimLens[idx];
74 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"nj" ) ) != dimNames.end() )
75 idx = vit - dimNames.begin();
78 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'nj' variable" );
82 gDims[4] = dimLens[idx];
91 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"nv" ) ) != dimNames.end() )
92 idx = vit - dimNames.begin();
95 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'nv' dimension" );
101 int rank = 0, procs = 1;
112 for(
int i = 0; i < 6; i++ )
119 for(
int i = 0; i < 3; i++ )
120 parData.
pDims[i] = pdims[i];
125 dbgOut.
tprintf( 1,
"Contiguous chunks of size %d bytes.\n",
130 for(
int i = 0; i < 6; i++ )
163 std::map< std::string, ReadNC::VarData >::iterator mit;
164 for( mit = varInfo.begin(); mit != varInfo.end(); ++mit )
186 std::vector< std::string > ijdimNames( 2 );
187 ijdimNames[0] =
"__ni";
188 ijdimNames[1] =
"__nj";
189 std::string tag_name;
193 for(
unsigned int i = 0; i != ijdimNames.size(); i++ )
195 std::vector< int > val( 2, 0 );
196 if( ijdimNames[i] ==
"__ni" )
201 else if( ijdimNames[i] ==
"__nj" )
207 std::stringstream ss_tag_name;
208 ss_tag_name << ijdimNames[i] <<
"_LOC_MINMAX";
209 tag_name = ss_tag_name.str();
212 if(
MB_SUCCESS == rval ) dbgOut.
tprintf( 2,
"Conventional tag %s is created.\n", tag_name.c_str() );
217 switch( varInfo[
"xc"].varDataType )
223 MB_SET_ERR( MB_FAILURE,
"Unexpected variable data type for 'lon'" );
227 Tag convTagsCreated = 0;
231 int create_conv_tags_flag = 1;
278 dbgOut.
tprintf( 1,
"local cells: %d \n", local_elems );
282 std::string maskstr(
"mask" );
290 std::vector< int > mask( local_elems );
292 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read int data for mask variable " );
294 int nb_with_mask1 = 0;
295 for(
int i = 0; i < local_elems; i++ )
296 if( 1 == mask[i] ) nb_with_mask1++;
298 dbgOut.
tprintf( 1,
"local cells with mask 1: %d \n", nb_with_mask1 );
299 std::vector< NCDF_SIZE > startsv( 3 );
303 std::vector< NCDF_SIZE > countsv( 3 );
309 std::string xvstr(
"xv" );
311 std::vector< double > xv( local_elems *
nv );
313 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for xv variable " );
315 std::string yvstr(
"yv" );
317 std::vector< double > yv( local_elems *
nv );
319 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for yv variable " );
322 std::string xcstr(
"xc" );
324 std::vector< double > xc( local_elems );
326 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for xc variable " );
328 std::string ycstr(
"yc" );
330 std::vector< double > yc( local_elems );
332 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for yc variable " );
334 std::string fracstr(
"frac" );
336 std::vector< double > frac( local_elems );
338 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for frac variable " );
339 std::string areastr(
"area" );
341 std::vector< double > area( local_elems );
343 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read double data for area variable " );
345 Tag areaTag, fracTag, xcTag, ycTag;
368 if(
nv > 1 && nb_with_mask1 > 0 )
371 tmp_range.
insert( start_cell, start_cell + nb_with_mask1 - 1 );
375 std::map< Node3D, EntityHandle > vertex_map;
377 if( nb_with_mask1 > 0 )
383 const double pideg = acos( -1.0 ) / 180.0;
385 for( ; elem_index < local_elems; elem_index++ )
387 if( 0 == mask[elem_index] )
continue;
389 for(
int k = 0; k <
nv; k++ )
391 int index_v_arr =
nv * elem_index + k;
397 double cosphi = cos(
pideg * y );
398 double zmult = sin(
pideg * y );
399 double xmult = cosphi * cos( x *
pideg );
400 double ymult = cosphi * sin( x *
pideg );
401 Node3D pt( xmult, ymult, zmult );
413 int nLocalVertices = (int)vertex_map.size();
414 std::vector< double* > arrays;
418 vtx_handle = start_vertex;
421 double *x = arrays[0], *y = arrays[1], *z = arrays[2];
422 for(
auto i = vertex_map.begin(); i != vertex_map.end(); ++i )
424 i->second = vtx_handle;
426 *x = i->first.coords[0];
428 *y = i->first.coords[1];
430 *z = i->first.coords[2];
446 if( 0 == mask[elem_index] )
continue;
448 for(
int k = 0; k <
nv; k++ )
450 int index_v_arr =
nv * elem_index + k;
453 double x = xv[index_v_arr];
454 double y = yv[index_v_arr];
455 double cosphi = cos(
pideg * y );
456 double zmult = sin(
pideg * y );
457 double xmult = cosphi * cos( x *
pideg );
458 double ymult = cosphi * sin( x *
pideg );
459 Node3D pt( xmult, ymult, zmult );
460 conn_arr[index *
nv + k] = vertex_map[pt];
464 if(
nv > 1 ) cell = start_cell + index;
472 int globalId = j * global_row_size + i + 1;
480 std::vector< Tag > tagList;
481 tagList.push_back( mGlobalIdTag );
482 tagList.push_back( xcTag );
483 tagList.push_back( ycTag );
484 tagList.push_back( areaTag );
485 tagList.push_back( fracTag );
507 rval =
mb->get_connectivity( eh, conn, num_nodes );
MB_CHK_ERR( rval );
521 2 );
MB_CHK_SET_ERR( rval,
"Failed to merge vertices in parallel" );