7 #ifdef MOAB_HAVE_ZOLTAN
20 :
UcdNCHelper( readNC, fileId, opts, fileSet ), createGatherSet( false )
32 std::vector< std::string >& dimNames = readNC->
dimNames;
35 if( std::find( dimNames.begin(), dimNames.end(), std::string(
"cells" ) ) != dimNames.end() )
return true;
44 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
48 std::vector< std::string >::iterator vit;
51 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"Time" ) ) != dimNames.end() )
52 idx = vit - dimNames.begin();
53 else if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
54 idx = vit - dimNames.begin();
57 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'Time' or 'time' dimension" );
63 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"cells" ) ) != dimNames.end() )
64 idx = vit - dimNames.begin();
67 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'cells' dimension" );
73 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"edges" ) ) != dimNames.end() )
74 idx = vit - dimNames.begin();
77 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'edges' dimension" );
84 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"corners" ) ) != dimNames.end() )
85 idx = vit - dimNames.begin();
88 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'corners' dimension" );
94 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"layers" ) ) != dimNames.end() )
95 idx = vit - dimNames.begin();
98 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'layers' dimension" );
104 std::vector< unsigned int > opt_lev_dims;
107 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"interfaces" ) ) != dimNames.end() )
109 idx = vit - dimNames.begin();
110 opt_lev_dims.push_back( idx );
113 std::map< std::string, ReadNC::VarData >::iterator vmit;
118 if( ( vmit = varInfo.find(
"time" ) ) != varInfo.end() )
122 else if( ( vmit = varInfo.find(
"t" ) ) != varInfo.end() )
130 tVals.push_back( (
double)t );
135 for( vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit )
156 for(
unsigned int i = 0; i < opt_lev_dims.size(); i++ )
160 vd.
numLev = dimLens[opt_lev_dims[i]];
194 if( !local_verts.
empty() )
196 std::vector< int > gids( local_verts.
size() );
199 rval = mbImpl->
tag_get_data( mGlobalIdTag, local_verts, &gids[0] );
MB_CHK_SET_ERR( rval,
"Trouble getting local gid values of vertices" );
213 if( !local_edges.
empty() )
215 std::vector< int > gids( local_edges.
size() );
218 rval = mbImpl->
tag_get_data( mGlobalIdTag, local_edges, &gids[0] );
MB_CHK_SET_ERR( rval,
"Trouble getting local gid values of edges" );
232 if( !local_cells.
empty() )
234 std::vector< int > gids( local_cells.
size() );
237 rval = mbImpl->
tag_get_data( mGlobalIdTag, local_cells, &gids[0] );
MB_CHK_SET_ERR( rval,
"Trouble getting local gid values of cells" );
272 int shifted_rank = rank;
274 if( trivialPartitionShift > 0 ) shifted_rank = ( rank + trivialPartitionShift ) % procs;
283 int iextra =
nCells % procs;
287 start_cell_idx += std::min( shifted_rank, iextra );
292 ErrorCode rval = redistribute_local_cells( start_cell_idx, myPcomm );
MB_CHK_SET_ERR( rval,
"Failed to redistribute local cells after trivial partition" );
307 int verticesOnCellVarId;
308 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_corners", &verticesOnCellVarId );
309 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_corners" );
312 dbgOut.
tprintf( 1,
" vertices_on_local_cells.size() = %d\n", (
int)vertices_on_local_cells.size() );
313 #ifdef MOAB_HAVE_PNETCDF
315 std::vector< int > requests( nb_reads );
316 std::vector< int > statuss( nb_reads );
319 size_t indexInArray = 0;
325 dbgOut.
tprintf( 1,
" cell_corners starth = %d\n", (
int)starth );
326 dbgOut.
tprintf( 1,
" cell_corners endh = %d\n", (
int)endh );
332 #ifdef MOAB_HAVE_PNETCDF
333 success = NCFUNCREQG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts,
334 &( vertices_on_local_cells[indexInArray] ), &requests[idxReq++] );
336 success =
NCFUNCAG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts,
337 &( vertices_on_local_cells[indexInArray] ) );
339 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data in a loop" );
345 #ifdef MOAB_HAVE_PNETCDF
347 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
348 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
353 for(
int local_cell_idx = 0; local_cell_idx <
nLocalCells; local_cell_idx++ )
355 int* pvertex = &vertices_on_local_cells[local_cell_idx *
EDGES_PER_CELL];
358 if( *( pvertex + k ) == *( pvertex + k + 1 ) )
362 *( pvertex + kk ) = *( pvertex + kk + 1 );
370 for( std::size_t idx = 0; idx < vertices_on_local_cells.size(); idx++ )
371 vertices_on_local_cells[idx] += 1;
409 std::vector< int >& tstep_nums )
421 assert(
"Should only have a single vertex subrange, since they were read in one shot" && verts.
psize() == 1 );
430 assert(
"Should only have a single face subrange, since they were read in one shot" && faces.
psize() == 1 );
445 for(
unsigned int i = 0; i < vdatas.size(); i++ )
452 assert( 3 == vdatas[i].varDims.size() || 2 == vdatas[i].varDims.size() );
455 assert(
tDim == vdatas[i].varDims[0] );
458 vdatas[i].readStarts.resize( 3 );
459 vdatas[i].readCounts.resize( 3 );
462 vdatas[i].readStarts[0] = 0;
463 vdatas[i].readCounts[0] = 1;
466 switch( vdatas[i].entLoc )
493 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
498 if( vdatas[i].numLev < 1 ) vdatas[i].numLev = 1;
499 vdatas[i].readStarts[2] = 0;
500 vdatas[i].readCounts[2] = vdatas[i].numLev;
504 for( std::size_t idx = 0; idx != 3; idx++ )
505 vdatas[i].sz *= vdatas[i].readCounts[idx];
507 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
509 dbgOut.
tprintf( 2,
"Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t] );
511 if( tstep_nums[t] >= dimLens[
tDim] )
517 if( !vdatas[i].varTags[t] )
519 rval =
get_tag_to_nonset( vdatas[i], tstep_nums[t], vdatas[i].varTags[t], vdatas[i].numLev );
MB_CHK_SET_ERR( rval,
"Trouble getting tag for variable " << vdatas[i].varName );
523 assert( 1 == range->
psize() );
526 rval = mbImpl->
tag_iterate( vdatas[i].varTags[t], range->
begin(), range->
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate tag for variable " << vdatas[i].varName );
527 assert( (
unsigned)count == range->
size() );
528 vdatas[i].varDatas[t] = data;
535 #ifdef MOAB_HAVE_PNETCDF
536 ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset_async( std::vector< ReadNC::VarData >& vdatas,
537 std::vector< int >& tstep_nums )
546 Range* pLocalGid = NULL;
548 for(
unsigned int i = 0; i < vdatas.size(); i++ )
553 switch( vdatas[i].entLoc )
565 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
568 std::size_t sz = vdatas[i].sz;
570 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
574 size_t nb_reads = pLocalGid->
psize();
575 std::vector< int > requests( nb_reads ), statuss( nb_reads );
579 vdatas[i].readStarts[0] = tstep_nums[t];
581 switch( vdatas[i].varDataType )
586 std::vector< double > tmpdoubledata( sz );
593 size_t indexInDoubleArray = 0;
595 for( Range::pair_iterator pair_iter = pLocalGid->
pair_begin(); pair_iter != pLocalGid->
pair_end();
600 vdatas[i].readStarts[1] = (
NCDF_SIZE)( starth - 1 );
601 vdatas[i].readCounts[1] = (
NCDF_SIZE)( endh - starth + 1 );
606 NCFUNCREQG( _vara_double )(
_fileId, vdatas[i].varId, &( vdatas[i].readStarts[0] ),
607 &( vdatas[i].readCounts[0] ),
608 &( tmpdoubledata[indexInDoubleArray] ), &requests[idxReq++] );
611 "Failed to read double data in a loop for variable " << vdatas[i].varName );
614 indexInDoubleArray += ( endh - starth + 1 ) * 1 * vdatas[i].numLev;
616 assert( ic == pLocalGid->
psize() );
618 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
619 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
621 void* data = vdatas[i].varDatas[t];
622 for( std::size_t idx = 0; idx != tmpdoubledata.size(); idx++ )
623 ( (
double*)data )[idx] = tmpdoubledata[idx];
628 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
636 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
637 for(
unsigned int i = 1; i < vdatas.size(); i++ )
638 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
646 std::vector< int >& tstep_nums )
655 Range* pLocalGid = NULL;
657 for(
unsigned int i = 0; i < vdatas.size(); i++ )
662 switch( vdatas[i].entLoc )
674 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
677 std::size_t sz = vdatas[i].sz;
679 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
682 vdatas[i].readStarts[0] = tstep_nums[t];
684 switch( vdatas[i].varDataType )
689 std::vector< double > tmpdoubledata( sz );
696 size_t indexInDoubleArray = 0;
703 vdatas[i].readStarts[1] = (
NCDF_SIZE)( starth - 1 );
704 vdatas[i].readCounts[1] = (
NCDF_SIZE)( endh - starth + 1 );
706 success =
NCFUNCAG( _vara_double )(
_fileId, vdatas[i].varId, &( vdatas[i].readStarts[0] ),
707 &( vdatas[i].readCounts[0] ),
708 &( tmpdoubledata[indexInDoubleArray] ) );
711 "Failed to read double data in a loop for variable " << vdatas[i].varName );
714 indexInDoubleArray += ( endh - starth + 1 ) * 1 * vdatas[i].numLev;
716 assert( ic == pLocalGid->
psize() );
718 void* data = vdatas[i].varDatas[t];
719 for( std::size_t idx = 0; idx != tmpdoubledata.size(); idx++ )
720 ( (
double*)data )[idx] = tmpdoubledata[idx];
725 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
733 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
734 for(
unsigned int i = 1; i < vdatas.size(); i++ )
735 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
747 #ifdef MOAB_HAVE_ZOLTAN
753 int success =
NCFUNC( inq_varid )(
_fileId,
"grid_center_lat", &xCellVarId );
754 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_center_lat" );
758 success =
NCFUNCAG( _vara_double )(
_fileId, xCellVarId, &read_start, &read_count, &xCell[0] );
759 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_center_lat data" );
763 success =
NCFUNC( inq_varid )(
_fileId,
"grid_center_lon", &yCellVarId );
764 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_center_lon" );
766 success =
NCFUNCAG( _vara_double )(
_fileId, yCellVarId, &read_start, &read_count, &yCell[0] );
767 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_center_lon data" );
774 double cosphi = cos( xCell[i] );
775 double zmult = sin( xCell[i] );
776 double xmult = cosphi * cos( yCell[i] );
777 double ymult = cosphi * sin( yCell[i] );
778 xCell[i] = rad * xmult;
779 yCell[i] = rad * ymult;
780 zCell[i] = rad * zmult;
791 dbgOut.tprintf( 1,
"After Zoltan partitioning, localGidCells.psize() = %d\n", (
int)
localGidCells.
psize() );
815 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
819 std::vector< int > vertices_on_local_cells_sorted( vertices_on_local_cells );
820 std::sort( vertices_on_local_cells_sorted.begin(), vertices_on_local_cells_sorted.end() );
821 std::copy( vertices_on_local_cells_sorted.rbegin(), vertices_on_local_cells_sorted.rend(),
829 std::vector< double* > arrays;
842 rval = mbImpl->
tag_iterate( mGlobalIdTag, local_verts_range.
begin(), local_verts_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate global id tag on local vertices" );
844 int* gid_data = (
int*)data;
850 rval = mbImpl->
tag_iterate( *mpFileIdTag, local_verts_range.
begin(), local_verts_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate file id tag on local vertices" );
852 int bytes_per_tag = 4;
854 if( 4 == bytes_per_tag )
856 gid_data = (
int*)data;
859 else if( 8 == bytes_per_tag )
861 long* handle_tag_data = (
long*)data;
866 #ifdef MOAB_HAVE_PNETCDF
868 std::vector< int > requests( nb_reads );
869 std::vector< int > statuss( nb_reads );
874 std::map< std::string, ReadNC::VarData >::iterator vmit;
875 if( ( vmit = varInfo.find(
"layers" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
879 else if( ( vmit = varInfo.find(
"interfaces" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
885 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'layers' or 'interfaces' variable" );
889 char posval[10] = { 0 };
890 int success =
NCFUNC( get_att_text )(
_fileId, ( *vmit ).second.varId,
"positive", posval );
891 if( 0 == success && !strncmp( posval,
"down", 4 ) )
893 for( std::vector< double >::iterator dvit =
levVals.begin(); dvit !=
levVals.end(); ++dvit )
898 double* xptr = arrays[0];
900 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lon", &xVertexVarId );
901 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lon" );
902 size_t indexInArray = 0;
912 #ifdef MOAB_HAVE_PNETCDF
913 success = NCFUNCREQG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, &( xptr[indexInArray] ),
914 &requests[idxReq++] );
916 success =
NCFUNCAG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, &( xptr[indexInArray] ) );
918 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data in a loop" );
921 indexInArray += ( endh - starth + 1 );
924 #ifdef MOAB_HAVE_PNETCDF
926 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
927 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
931 double* yptr = arrays[1];
933 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lat", &yVertexVarId );
934 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lat" );
935 #ifdef MOAB_HAVE_PNETCDF
948 #ifdef MOAB_HAVE_PNETCDF
949 success = NCFUNCREQG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, &( yptr[indexInArray] ),
950 &requests[idxReq++] );
952 success =
NCFUNCAG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, &( yptr[indexInArray] ) );
954 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data in a loop" );
957 indexInArray += ( endh - starth + 1 );
960 #ifdef MOAB_HAVE_PNETCDF
962 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
963 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
967 double* zptr = arrays[2];
968 double rad = 8000.0 +
levVals[0];
971 double cosphi = cos( yptr[i] );
972 double zmult = sin( yptr[i] );
973 double xmult = cosphi * cos( xptr[i] );
974 double ymult = cosphi * sin( xptr[i] );
975 xptr[i] = rad * xmult;
976 yptr[i] = rad * ymult;
977 zptr[i] = rad * zmult;
990 int edgesOnCellVarId;
991 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_edges", &edgesOnCellVarId );
992 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_edges" );
995 dbgOut.
tprintf( 1,
" edges_on_local_cells.size() = %d\n", (
int)edges_on_local_cells.size() );
997 #ifdef MOAB_HAVE_PNETCDF
999 std::vector< int > requests( nb_reads );
1000 std::vector< int > statuss( nb_reads );
1003 size_t indexInArray = 0;
1009 dbgOut.
tprintf( 1,
" starth = %d\n", (
int)starth );
1010 dbgOut.
tprintf( 1,
" endh = %d\n", (
int)endh );
1016 #ifdef MOAB_HAVE_PNETCDF
1017 success = NCFUNCREQG( _vara_int )(
_fileId, edgesOnCellVarId, read_starts, read_counts,
1018 &( edges_on_local_cells[indexInArray] ), &requests[idxReq++] );
1020 success =
NCFUNCAG( _vara_int )(
_fileId, edgesOnCellVarId, read_starts, read_counts,
1021 &( edges_on_local_cells[indexInArray] ) );
1023 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_edges data in a loop" );
1029 #ifdef MOAB_HAVE_PNETCDF
1031 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
1032 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
1036 for( std::size_t idx = 0; idx < edges_on_local_cells.size(); idx++ )
1037 edges_on_local_cells[idx] += 1;
1040 std::sort( edges_on_local_cells.begin(), edges_on_local_cells.end() );
1062 rval = mbImpl->
tag_iterate( mGlobalIdTag, local_edges_range.
begin(), local_edges_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate global id tag on local edges" );
1064 int* gid_data = (
int*)data;
1067 int verticesOnEdgeVarId;
1070 success =
NCFUNC( inq_varid )(
_fileId,
"edge_corners", &verticesOnEdgeVarId );
1071 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of edge_corners" );
1073 int* vertices_on_local_edges = (
int*)conn_arr_edges;
1074 #ifdef MOAB_HAVE_PNETCDF
1076 requests.resize( nb_reads );
1077 statuss.resize( nb_reads );
1090 #ifdef MOAB_HAVE_PNETCDF
1091 success = NCFUNCREQG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts,
1092 &( vertices_on_local_edges[indexInArray] ), &requests[idxReq++] );
1094 success =
NCFUNCAG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts,
1095 &( vertices_on_local_edges[indexInArray] ) );
1097 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data in a loop" );
1100 indexInArray += ( endh - starth + 1 ) * 2;
1103 #ifdef MOAB_HAVE_PNETCDF
1105 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
1106 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
1112 for(
int edge_vert =
nLocalEdges * 2 - 1; edge_vert >= 0; edge_vert-- )
1115 int global_vert_idx = vertices_on_local_edges[edge_vert] + 1;
1117 assert( local_vert_idx != -1 );
1118 conn_arr_edges[edge_vert] = start_vertex + local_vert_idx;
1136 conn_arr_local_cells,
1148 rval = mbImpl->
tag_iterate( mGlobalIdTag, local_cells_range.
begin(), local_cells_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate global id tag on local cells" );
1150 int* gid_data = (
int*)data;
1156 for(
int local_cell_idx = 0; local_cell_idx <
nLocalCells; local_cell_idx++ )
1164 assert( local_vert_idx != -1 );
1165 conn_arr_local_cells[local_cell_idx *
EDGES_PER_CELL + i] = start_vertex + local_vert_idx;
1179 std::vector< double* > arrays;
1185 Range gather_set_verts_range( gather_set_start_vertex, gather_set_start_vertex +
nVertices - 1 );
1186 rval = mbImpl->
add_entities( gather_set, gather_set_verts_range );
MB_CHK_SET_ERR( rval,
"Failed to add vertices to the gather set" );
1189 double* xptr = arrays[0];
1191 int success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lon", &xVertexVarId );
1192 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lon" );
1195 #ifdef MOAB_HAVE_PNETCDF
1198 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1199 success =
NCFUNCG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, xptr );
1200 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data" );
1202 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1204 success =
NCFUNCG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, xptr );
1205 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data" );
1209 double* yptr = arrays[1];
1211 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lat", &yVertexVarId );
1212 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lat" );
1213 #ifdef MOAB_HAVE_PNETCDF
1216 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1217 success =
NCFUNCG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, yptr );
1218 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data" );
1220 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1222 success =
NCFUNCG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, yptr );
1223 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data" );
1227 double* zptr = arrays[2];
1228 double rad = 8000.0 +
levVals[0];
1231 double cosphi = cos( yptr[i] );
1232 double zmult = sin( yptr[i] );
1233 double xmult = cosphi * cos( xptr[i] );
1234 double ymult = cosphi * sin( xptr[i] );
1235 xptr[i] = rad * xmult;
1236 yptr[i] = rad * ymult;
1237 zptr[i] = rad * zmult;
1244 mbImpl->
tag_iterate( mGlobalIdTag, gather_set_verts_range.
begin(), gather_set_verts_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate global id tag on gather set vertices" );
1246 int* gid_data = (
int*)data;
1248 gid_data[j - 1] = j;
1253 rval = mbImpl->
tag_iterate( *mpFileIdTag, gather_set_verts_range.
begin(), gather_set_verts_range.
end(), count,
1254 data );
MB_CHK_SET_ERR( rval,
"Failed to iterate file id tag on gather set vertices" );
1256 int bytes_per_tag = 4;
1258 if( 4 == bytes_per_tag )
1260 gid_data = (
int*)data;
1264 else if( 8 == bytes_per_tag )
1266 long* handle_tag_data = (
long*)data;
1288 Range gather_set_edges_range( start_edge, start_edge +
nEdges - 1 );
1289 rval = mbImpl->
add_entities( gather_set, gather_set_edges_range );
MB_CHK_SET_ERR( rval,
"Failed to add edges to the gather set" );
1292 int verticesOnEdgeVarId;
1293 int success =
NCFUNC( inq_varid )(
_fileId,
"edge_corners", &verticesOnEdgeVarId );
1294 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of edge_corners" );
1296 int* vertices_on_gather_set_edges = (
int*)conn_arr_gather_set_edges;
1299 #ifdef MOAB_HAVE_PNETCDF
1302 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1304 NCFUNCG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts, vertices_on_gather_set_edges );
1305 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data" );
1307 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1310 NCFUNCG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts, vertices_on_gather_set_edges );
1311 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data" );
1317 for(
int edge_vert =
nEdges * 2 - 1; edge_vert >= 0; edge_vert-- )
1320 int gather_set_vert_idx = vertices_on_gather_set_edges[edge_vert];
1322 conn_arr_gather_set_edges[edge_vert] = gather_set_start_vertex + gather_set_vert_idx;
1338 conn_arr_gather_set_cells );
MB_CHK_SET_ERR( rval,
"Failed to create gather set cells" );
1341 Range gather_set_cells_range( start_element, start_element +
nCells - 1 );
1342 rval = mbImpl->
add_entities( gather_set, gather_set_cells_range );
MB_CHK_SET_ERR( rval,
"Failed to add cells to the gather set" );
1345 int verticesOnCellVarId;
1346 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_corners", &verticesOnCellVarId );
1347 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_corners" );
1349 int* vertices_on_gather_set_cells = (
int*)conn_arr_gather_set_cells;
1352 #ifdef MOAB_HAVE_PNETCDF
1355 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1357 NCFUNCG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts, vertices_on_gather_set_cells );
1358 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data" );
1360 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1363 NCFUNCG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts, vertices_on_gather_set_cells );
1364 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data" );
1369 for(
int gather_set_cell_idx = 0; gather_set_cell_idx <
nCells; gather_set_cell_idx++ )
1371 int* pvertex = vertices_on_gather_set_cells + gather_set_cell_idx *
EDGES_PER_CELL;
1374 if( *( pvertex + k ) == *( pvertex + k + 1 ) )
1378 *( pvertex + kk ) = *( pvertex + kk + 1 );
1391 int gather_set_vert_idx = vertices_on_gather_set_cells[cell_vert];
1393 conn_arr_gather_set_cells[cell_vert] = gather_set_start_vertex + gather_set_vert_idx;