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;
47 std::vector< std::string >::iterator vit;
50 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"Time" ) ) != dimNames.end() )
51 idx = vit - dimNames.begin();
52 else if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
53 idx = vit - dimNames.begin();
56 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'Time' or 'time' dimension" );
62 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"cells" ) ) != dimNames.end() )
63 idx = vit - dimNames.begin();
66 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'cells' dimension" );
72 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"edges" ) ) != dimNames.end() )
73 idx = vit - dimNames.begin();
76 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'edges' dimension" );
83 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"corners" ) ) != dimNames.end() )
84 idx = vit - dimNames.begin();
87 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'corners' dimension" );
93 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"layers" ) ) != dimNames.end() )
94 idx = vit - dimNames.begin();
97 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'layers' dimension" );
103 std::vector< unsigned int > opt_lev_dims;
106 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"interfaces" ) ) != dimNames.end() )
108 idx = vit - dimNames.begin();
109 opt_lev_dims.push_back( idx );
112 std::map< std::string, ReadNC::VarData >::iterator vmit;
117 if( ( vmit = varInfo.find(
"time" ) ) != varInfo.end() )
121 else if( ( vmit = varInfo.find(
"t" ) ) != varInfo.end() )
129 tVals.push_back( (
double)t );
134 for( vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit )
155 for(
unsigned int i = 0; i < opt_lev_dims.size(); i++ )
159 vd.
numLev = dimLens[opt_lev_dims[i]];
190 "Trouble getting local vertices in current file set" );
192 if( !local_verts.
empty() )
194 std::vector< int > gids( local_verts.
size() );
198 "Trouble getting local gid values of vertices" );
211 "Trouble getting local edges in current file set" );
213 if( !local_edges.
empty() )
215 std::vector< int > gids( local_edges.
size() );
219 "Trouble getting local gid values of edges" );
232 "Trouble getting local cells in current file set" );
234 if( !local_cells.
empty() )
236 std::vector< int > gids( local_cells.
size() );
240 "Trouble getting local gid values of cells" );
275 int shifted_rank = rank;
277 if( trivialPartitionShift > 0 ) shifted_rank = ( rank + trivialPartitionShift ) % procs;
286 int iextra =
nCells % procs;
290 start_cell_idx += std::min( shifted_rank, iextra );
295 MB_CHK_SET_ERR( redistribute_local_cells( start_cell_idx, myPcomm ),
296 "Failed to redistribute local cells after trivial partition" );
311 int verticesOnCellVarId;
312 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_corners", &verticesOnCellVarId );
313 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_corners" );
316 dbgOut.
tprintf( 1,
" vertices_on_local_cells.size() = %d\n", (
int)vertices_on_local_cells.size() );
317 #ifdef MOAB_HAVE_PNETCDF
319 std::vector< int > requests( nb_reads );
320 std::vector< int > statuss( nb_reads );
323 size_t indexInArray = 0;
329 dbgOut.
tprintf( 1,
" cell_corners starth = %d\n", (
int)starth );
330 dbgOut.
tprintf( 1,
" cell_corners endh = %d\n", (
int)endh );
336 #ifdef MOAB_HAVE_PNETCDF
337 success = NCFUNCREQG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts,
338 &( vertices_on_local_cells[indexInArray] ), &requests[idxReq++] );
340 success =
NCFUNCAG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts,
341 &( vertices_on_local_cells[indexInArray] ) );
343 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data in a loop" );
349 #ifdef MOAB_HAVE_PNETCDF
351 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
352 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
357 for(
int local_cell_idx = 0; local_cell_idx <
nLocalCells; local_cell_idx++ )
359 int* pvertex = &vertices_on_local_cells[local_cell_idx *
EDGES_PER_CELL];
362 if( *( pvertex + k ) == *( pvertex + k + 1 ) )
366 *( pvertex + kk ) = *( pvertex + kk + 1 );
374 for( std::size_t idx = 0; idx < vertices_on_local_cells.size(); idx++ )
375 vertices_on_local_cells[idx] += 1;
380 "Failed to create local vertices for GCRM mesh" );
390 "Failed to create padded local cells for GCRM mesh" );
400 "Failed to create gather set vertices for GCRM mesh" );
406 "Failed to create gather set edges for GCRM mesh" );
411 "Failed to create padded gather set cells for GCRM mesh" );
418 std::vector< int >& tstep_nums )
430 "Trouble getting vertices in current file set" );
431 assert(
"Should only have a single vertex subrange, since they were read in one shot" && verts.
psize() == 1 );
436 "Trouble getting edges in current file set" );
441 "Trouble getting faces in current file set" );
442 assert(
"Should only have a single face subrange, since they were read in one shot" && faces.
psize() == 1 );
450 "Trouble getting owned faces in current file set" );
458 for(
unsigned int i = 0; i < vdatas.size(); i++ )
465 assert( 3 == vdatas[i].varDims.size() || 2 == vdatas[i].varDims.size() );
468 assert(
tDim == vdatas[i].varDims[0] );
471 vdatas[i].readStarts.resize( 3 );
472 vdatas[i].readCounts.resize( 3 );
475 vdatas[i].readStarts[0] = 0;
476 vdatas[i].readCounts[0] = 1;
479 switch( vdatas[i].entLoc )
506 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
511 if( vdatas[i].numLev < 1 ) vdatas[i].numLev = 1;
512 vdatas[i].readStarts[2] = 0;
513 vdatas[i].readCounts[2] = vdatas[i].numLev;
517 for( std::size_t idx = 0; idx != 3; idx++ )
518 vdatas[i].sz *= vdatas[i].readCounts[idx];
520 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
522 dbgOut.
tprintf( 2,
"Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t] );
524 if( tstep_nums[t] >= dimLens[
tDim] )
530 if( !vdatas[i].varTags[t] )
533 "Trouble getting tag for variable " << vdatas[i].varName );
537 assert( 1 == range->
psize() );
541 "Failed to iterate tag for variable " << vdatas[i].varName );
542 assert( (
unsigned)count == range->
size() );
543 vdatas[i].varDatas[t] = data;
550 #ifdef MOAB_HAVE_PNETCDF
551 ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset_async( std::vector< ReadNC::VarData >& vdatas,
552 std::vector< int >& tstep_nums )
558 "Trouble allocating space to read non-set variables" );
562 Range* pLocalGid = NULL;
564 for(
unsigned int i = 0; i < vdatas.size(); i++ )
569 switch( vdatas[i].entLoc )
581 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
584 std::size_t sz = vdatas[i].sz;
586 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
590 size_t nb_reads = pLocalGid->
psize();
591 std::vector< int > requests( nb_reads ), statuss( nb_reads );
595 vdatas[i].readStarts[0] = tstep_nums[t];
597 switch( vdatas[i].varDataType )
602 std::vector< double > tmpdoubledata( sz );
609 size_t indexInDoubleArray = 0;
611 for( Range::pair_iterator pair_iter = pLocalGid->
pair_begin(); pair_iter != pLocalGid->
pair_end();
616 vdatas[i].readStarts[1] = (
NCDF_SIZE)( starth - 1 );
617 vdatas[i].readCounts[1] = (
NCDF_SIZE)( endh - starth + 1 );
622 NCFUNCREQG( _vara_double )(
_fileId, vdatas[i].varId, &( vdatas[i].readStarts[0] ),
623 &( vdatas[i].readCounts[0] ),
624 &( tmpdoubledata[indexInDoubleArray] ), &requests[idxReq++] );
627 "Failed to read double data in a loop for variable " << vdatas[i].varName );
630 indexInDoubleArray += ( endh - starth + 1 ) * 1 * vdatas[i].numLev;
632 assert( ic == pLocalGid->
psize() );
634 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
635 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
637 void* data = vdatas[i].varDatas[t];
638 for( std::size_t idx = 0; idx != tmpdoubledata.size(); idx++ )
639 ( (
double*)data )[idx] = tmpdoubledata[idx];
644 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
652 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
653 for(
unsigned int i = 1; i < vdatas.size(); i++ )
654 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
662 std::vector< int >& tstep_nums )
668 "Trouble allocating space to read non-set variables" );
672 Range* pLocalGid = NULL;
674 for(
unsigned int i = 0; i < vdatas.size(); i++ )
679 switch( vdatas[i].entLoc )
691 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
694 std::size_t sz = vdatas[i].sz;
696 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
699 vdatas[i].readStarts[0] = tstep_nums[t];
701 switch( vdatas[i].varDataType )
706 std::vector< double > tmpdoubledata( sz );
713 size_t indexInDoubleArray = 0;
720 vdatas[i].readStarts[1] = (
NCDF_SIZE)( starth - 1 );
721 vdatas[i].readCounts[1] = (
NCDF_SIZE)( endh - starth + 1 );
723 success =
NCFUNCAG( _vara_double )(
_fileId, vdatas[i].varId, &( vdatas[i].readStarts[0] ),
724 &( vdatas[i].readCounts[0] ),
725 &( tmpdoubledata[indexInDoubleArray] ) );
728 "Failed to read double data in a loop for variable " << vdatas[i].varName );
731 indexInDoubleArray += ( endh - starth + 1 ) * 1 * vdatas[i].numLev;
733 assert( ic == pLocalGid->
psize() );
735 void* data = vdatas[i].varDatas[t];
736 for( std::size_t idx = 0; idx != tmpdoubledata.size(); idx++ )
737 ( (
double*)data )[idx] = tmpdoubledata[idx];
742 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
750 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
751 for(
unsigned int i = 1; i < vdatas.size(); i++ )
752 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
764 #ifdef MOAB_HAVE_ZOLTAN
770 int success =
NCFUNC( inq_varid )(
_fileId,
"grid_center_lat", &xCellVarId );
771 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_center_lat" );
775 success =
NCFUNCAG( _vara_double )(
_fileId, xCellVarId, &read_start, &read_count, &xCell[0] );
776 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_center_lat data" );
780 success =
NCFUNC( inq_varid )(
_fileId,
"grid_center_lon", &yCellVarId );
781 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_center_lon" );
783 success =
NCFUNCAG( _vara_double )(
_fileId, yCellVarId, &read_start, &read_count, &yCell[0] );
784 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_center_lon data" );
791 double cosphi = cos( xCell[i] );
792 double zmult = sin( xCell[i] );
793 double xmult = cosphi * cos( yCell[i] );
794 double ymult = cosphi * sin( yCell[i] );
795 xCell[i] = rad * xmult;
796 yCell[i] = rad * ymult;
797 zCell[i] = rad * zmult;
806 "Error in Zoltan partitioning" );
809 dbgOut.tprintf( 1,
"After Zoltan partitioning, localGidCells.psize() = %d\n", (
int)
localGidCells.
psize() );
835 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
839 std::vector< int > vertices_on_local_cells_sorted( vertices_on_local_cells );
840 std::sort( vertices_on_local_cells_sorted.begin(), vertices_on_local_cells_sorted.end() );
841 std::copy( vertices_on_local_cells_sorted.rbegin(), vertices_on_local_cells_sorted.rend(),
849 std::vector< double* > arrays;
854 "Failed to create local vertices" );
859 "Failed to add local vertices to current file set" );
866 "Failed to iterate global id tag on local vertices" );
868 int* gid_data = (
int*)data;
876 "Failed to iterate file id tag on local vertices" );
878 int bytes_per_tag = 4;
880 "can't get number of bytes for file id tag" );
881 if( 4 == bytes_per_tag )
883 gid_data = (
int*)data;
886 else if( 8 == bytes_per_tag )
888 long* handle_tag_data = (
long*)data;
893 #ifdef MOAB_HAVE_PNETCDF
895 std::vector< int > requests( nb_reads );
896 std::vector< int > statuss( nb_reads );
901 std::map< std::string, ReadNC::VarData >::iterator vmit;
902 if( ( vmit = varInfo.find(
"layers" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
906 else if( ( vmit = varInfo.find(
"interfaces" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
909 "Trouble reading 'interfaces' variable" );
913 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'layers' or 'interfaces' variable" );
917 char posval[10] = { 0 };
918 int success =
NCFUNC( get_att_text )(
_fileId, ( *vmit ).second.varId,
"positive", posval );
919 if( 0 == success && !strncmp( posval,
"down", 4 ) )
921 for( std::vector< double >::iterator dvit =
levVals.begin(); dvit !=
levVals.end(); ++dvit )
926 double* xptr = arrays[0];
928 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lon", &xVertexVarId );
929 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lon" );
930 size_t indexInArray = 0;
940 #ifdef MOAB_HAVE_PNETCDF
941 success = NCFUNCREQG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, &( xptr[indexInArray] ),
942 &requests[idxReq++] );
944 success =
NCFUNCAG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, &( xptr[indexInArray] ) );
946 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data in a loop" );
949 indexInArray += ( endh - starth + 1 );
952 #ifdef MOAB_HAVE_PNETCDF
954 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
955 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
959 double* yptr = arrays[1];
961 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lat", &yVertexVarId );
962 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lat" );
963 #ifdef MOAB_HAVE_PNETCDF
976 #ifdef MOAB_HAVE_PNETCDF
977 success = NCFUNCREQG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, &( yptr[indexInArray] ),
978 &requests[idxReq++] );
980 success =
NCFUNCAG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, &( yptr[indexInArray] ) );
982 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data in a loop" );
985 indexInArray += ( endh - starth + 1 );
988 #ifdef MOAB_HAVE_PNETCDF
990 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
991 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
995 double* zptr = arrays[2];
996 double rad = 8000.0 +
levVals[0];
999 double cosphi = cos( yptr[i] );
1000 double zmult = sin( yptr[i] );
1001 double xmult = cosphi * cos( xptr[i] );
1002 double ymult = cosphi * sin( xptr[i] );
1003 xptr[i] = rad * xmult;
1004 yptr[i] = rad * ymult;
1005 zptr[i] = rad * zmult;
1018 int edgesOnCellVarId;
1019 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_edges", &edgesOnCellVarId );
1020 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_edges" );
1023 dbgOut.
tprintf( 1,
" edges_on_local_cells.size() = %d\n", (
int)edges_on_local_cells.size() );
1025 #ifdef MOAB_HAVE_PNETCDF
1027 std::vector< int > requests( nb_reads );
1028 std::vector< int > statuss( nb_reads );
1031 size_t indexInArray = 0;
1037 dbgOut.
tprintf( 1,
" starth = %d\n", (
int)starth );
1038 dbgOut.
tprintf( 1,
" endh = %d\n", (
int)endh );
1044 #ifdef MOAB_HAVE_PNETCDF
1045 success = NCFUNCREQG( _vara_int )(
_fileId, edgesOnCellVarId, read_starts, read_counts,
1046 &( edges_on_local_cells[indexInArray] ), &requests[idxReq++] );
1048 success =
NCFUNCAG( _vara_int )(
_fileId, edgesOnCellVarId, read_starts, read_counts,
1049 &( edges_on_local_cells[indexInArray] ) );
1051 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_edges data in a loop" );
1057 #ifdef MOAB_HAVE_PNETCDF
1059 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
1060 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
1064 for( std::size_t idx = 0; idx < edges_on_local_cells.size(); idx++ )
1065 edges_on_local_cells[idx] += 1;
1068 std::sort( edges_on_local_cells.begin(), edges_on_local_cells.end() );
1082 "Failed to create local edges" );
1087 "Failed to add local edges to current file set" );
1094 "Failed to iterate global id tag on local edges" );
1096 int* gid_data = (
int*)data;
1099 int verticesOnEdgeVarId;
1102 success =
NCFUNC( inq_varid )(
_fileId,
"edge_corners", &verticesOnEdgeVarId );
1103 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of edge_corners" );
1105 int* vertices_on_local_edges = (
int*)conn_arr_edges;
1106 #ifdef MOAB_HAVE_PNETCDF
1108 requests.resize( nb_reads );
1109 statuss.resize( nb_reads );
1122 #ifdef MOAB_HAVE_PNETCDF
1123 success = NCFUNCREQG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts,
1124 &( vertices_on_local_edges[indexInArray] ), &requests[idxReq++] );
1126 success =
NCFUNCAG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts,
1127 &( vertices_on_local_edges[indexInArray] ) );
1129 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data in a loop" );
1132 indexInArray += ( endh - starth + 1 ) * 2;
1135 #ifdef MOAB_HAVE_PNETCDF
1137 success =
NCFUNC( wait_all )(
_fileId, requests.size(), &requests[0], &statuss[0] );
1138 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed on wait_all" );
1144 for(
int edge_vert =
nLocalEdges * 2 - 1; edge_vert >= 0; edge_vert-- )
1147 int global_vert_idx = vertices_on_local_edges[edge_vert] + 1;
1149 assert( local_vert_idx != -1 );
1150 conn_arr_edges[edge_vert] = start_vertex + local_vert_idx;
1170 "Failed to create local cells" );
1176 "Failed to add local cells to current file set" );
1183 "Failed to iterate global id tag on local cells" );
1185 int* gid_data = (
int*)data;
1191 for(
int local_cell_idx = 0; local_cell_idx <
nLocalCells; local_cell_idx++ )
1199 assert( local_vert_idx != -1 );
1200 conn_arr_local_cells[local_cell_idx *
EDGES_PER_CELL + i] = start_vertex + local_vert_idx;
1214 std::vector< double* > arrays;
1218 "Failed to create gather set vertices" );
1221 Range gather_set_verts_range( gather_set_start_vertex, gather_set_start_vertex +
nVertices - 1 );
1223 "Failed to add vertices to the gather set" );
1226 double* xptr = arrays[0];
1228 int success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lon", &xVertexVarId );
1229 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lon" );
1232 #ifdef MOAB_HAVE_PNETCDF
1235 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1236 success =
NCFUNCG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, xptr );
1237 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data" );
1239 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1241 success =
NCFUNCG( _vara_double )(
_fileId, xVertexVarId, &read_start, &read_count, xptr );
1242 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lon data" );
1246 double* yptr = arrays[1];
1248 success =
NCFUNC( inq_varid )(
_fileId,
"grid_corner_lat", &yVertexVarId );
1249 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of grid_corner_lat" );
1250 #ifdef MOAB_HAVE_PNETCDF
1253 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1254 success =
NCFUNCG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, yptr );
1255 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data" );
1257 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1259 success =
NCFUNCG( _vara_double )(
_fileId, yVertexVarId, &read_start, &read_count, yptr );
1260 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read grid_corner_lat data" );
1264 double* zptr = arrays[2];
1265 double rad = 8000.0 +
levVals[0];
1268 double cosphi = cos( yptr[i] );
1269 double zmult = sin( yptr[i] );
1270 double xmult = cosphi * cos( xptr[i] );
1271 double ymult = cosphi * sin( xptr[i] );
1272 xptr[i] = rad * xmult;
1273 yptr[i] = rad * ymult;
1274 zptr[i] = rad * zmult;
1282 "Failed to iterate global id tag on gather set vertices" );
1284 int* gid_data = (
int*)data;
1286 gid_data[j - 1] = j;
1293 "Failed to iterate file id tag on gather set vertices" );
1295 int bytes_per_tag = 4;
1297 "Can't get number of bytes for file id tag" );
1298 if( 4 == bytes_per_tag )
1300 gid_data = (
int*)data;
1304 else if( 8 == bytes_per_tag )
1306 long* handle_tag_data = (
long*)data;
1325 conn_arr_gather_set_edges ),
1326 "Failed to create gather set edges" );
1329 Range gather_set_edges_range( start_edge, start_edge +
nEdges - 1 );
1331 "Failed to add edges to the gather set" );
1334 int verticesOnEdgeVarId;
1335 int success =
NCFUNC( inq_varid )(
_fileId,
"edge_corners", &verticesOnEdgeVarId );
1336 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of edge_corners" );
1338 int* vertices_on_gather_set_edges = (
int*)conn_arr_gather_set_edges;
1341 #ifdef MOAB_HAVE_PNETCDF
1344 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1346 NCFUNCG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts, vertices_on_gather_set_edges );
1347 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data" );
1349 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1352 NCFUNCG( _vara_int )(
_fileId, verticesOnEdgeVarId, read_starts, read_counts, vertices_on_gather_set_edges );
1353 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read edge_corners data" );
1359 for(
int edge_vert =
nEdges * 2 - 1; edge_vert >= 0; edge_vert-- )
1362 int gather_set_vert_idx = vertices_on_gather_set_edges[edge_vert];
1364 conn_arr_gather_set_edges[edge_vert] = gather_set_start_vertex + gather_set_vert_idx;
1380 conn_arr_gather_set_cells ),
1381 "Failed to create gather set cells" );
1384 Range gather_set_cells_range( start_element, start_element +
nCells - 1 );
1386 "Failed to add cells to the gather set" );
1389 int verticesOnCellVarId;
1390 int success =
NCFUNC( inq_varid )(
_fileId,
"cell_corners", &verticesOnCellVarId );
1391 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to get variable id of cell_corners" );
1393 int* vertices_on_gather_set_cells = (
int*)conn_arr_gather_set_cells;
1396 #ifdef MOAB_HAVE_PNETCDF
1399 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to begin independent I/O mode" );
1401 NCFUNCG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts, vertices_on_gather_set_cells );
1402 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data" );
1404 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to end independent I/O mode" );
1407 NCFUNCG( _vara_int )(
_fileId, verticesOnCellVarId, read_starts, read_counts, vertices_on_gather_set_cells );
1408 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read cell_corners data" );
1413 for(
int gather_set_cell_idx = 0; gather_set_cell_idx <
nCells; gather_set_cell_idx++ )
1415 int* pvertex = vertices_on_gather_set_cells + gather_set_cell_idx *
EDGES_PER_CELL;
1418 if( *( pvertex + k ) == *( pvertex + k + 1 ) )
1422 *( pvertex + kk ) = *( pvertex + kk + 1 );
1435 int gather_set_vert_idx = vertices_on_gather_set_cells[cell_vert];
1437 conn_arr_gather_set_cells[cell_vert] = gather_set_start_vertex + gather_set_vert_idx;