29 std::map< std::string, ReadNC::AttData >& globalAtts = readNC->
globalAtts;
30 std::map< std::string, ReadNC::AttData >::iterator attIt = globalAtts.find(
"conventions" );
31 if( attIt == globalAtts.end() ) attIt = globalAtts.find(
"Conventions" );
33 if( attIt != globalAtts.end() )
35 unsigned int sz = attIt->second.attLen;
37 att_data.resize( sz + 1 );
38 att_data[sz] =
'\000';
40 NCFUNC( get_att_text )( fileId, attIt->second.attVarId, attIt->second.attName.c_str(), &att_data[0] );
41 if( 0 == success && att_data.find(
"CF" ) != std::string::npos ) is_CF =
true;
72 return "PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN;"
73 "PARALLEL_RESOLVE_SHARED_ENTS;NO_EDGES;NO_MIXED_ELEMENTS;VARIABLE=;";
75 return "PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN;";
77 return "PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=;";
79 return "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ;VARIABLE=;";
81 return "PARALLEL=READ_PART;PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS;";
84 return "PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;"
85 "PARTITION_METHOD=SQIJ;VARIABLE=;";
87 return "PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN;PARALLEL_RESOLVE_SHARED_ENTS;";
98 return new( std::nothrow )
NCHelperMPAS( readNC, fileId, opts, fileSet );
101 return new( std::nothrow )
NCHelperScrip( readNC, fileId, opts, fileSet );
103 return new( std::nothrow )
NCHelperESMF( readNC, fileId, opts, fileSet );
105 return new( std::nothrow )
NCHelperDomain( readNC, fileId, opts, fileSet );
108 return new( std::nothrow )
NCHelperHOMME( readNC, fileId, opts, fileSet );
110 return new( std::nothrow )
NCHelperGCRM( readNC, fileId, opts, fileSet );
112 return new( std::nothrow )
NCHelperEuler( readNC, fileId, opts, fileSet );
114 return new( std::nothrow )
NCHelperFV( readNC, fileId, opts, fileSet );
126 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
132 std::string tag_name;
136 tag_name =
"__NUM_DIMS";
137 int numDims = dimNames.size();
140 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
144 tag_name =
"__NUM_VARS";
145 int numVars = varInfo.size();
148 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
152 tag_name =
"__DIM_NAMES";
153 std::string dimnames;
154 unsigned int dimNamesSz = dimNames.size();
155 for(
unsigned int i = 0; i != dimNamesSz; i++ )
157 dimnames.append( dimNames[i] );
158 dimnames.push_back(
'\0' );
160 int dimnamesSz = dimnames.size();
163 const void* ptr = dimnames.c_str();
165 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
169 tag_name =
"__DIM_LENS";
170 int dimLensSz = dimLens.size();
173 ptr = &( dimLens[0] );
175 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
179 tag_name =
"__VAR_NAMES";
180 std::string varnames;
181 std::map< std::string, ReadNC::VarData >::iterator mapIter;
182 for( mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter )
184 varnames.append( mapIter->first );
185 varnames.push_back(
'\0' );
187 int varnamesSz = varnames.size();
190 ptr = varnames.c_str();
192 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
195 for(
unsigned int i = 0; i != dimNamesSz; i++ )
197 if( dimNames[i] ==
"time" || dimNames[i] ==
"Time" || dimNames[i] ==
"t" )
202 std::stringstream ss_tag_name;
203 ss_tag_name <<
"__" << dimNames[i] <<
"_LOC_MINMAX";
204 tag_name = ss_tag_name.str();
206 std::vector< int > val( 2, 0 );
211 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
216 for(
unsigned int i = 0; i != dimNamesSz; i++ )
218 if( dimNames[i] ==
"time" || dimNames[i] ==
"Time" || dimNames[i] ==
"t" )
220 std::vector< int > val;
221 if( !tstep_nums.empty() )
227 if(
tVals.empty() )
continue;
228 val.resize(
tVals.size() );
229 for(
unsigned int j = 0; j !=
tVals.size(); j++ )
233 std::stringstream ss_tag_name;
234 ss_tag_name <<
"__" << dimNames[i] <<
"_LOC_VALS";
235 tag_name = ss_tag_name.str();
239 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
244 for( mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter )
246 Tag varNamesDimsTag = 0;
247 std::stringstream ss_tag_name;
248 ss_tag_name <<
"__" << mapIter->first <<
"_DIMS";
249 tag_name = ss_tag_name.str();
250 unsigned int varDimSz = varInfo[mapIter->first].varDims.size();
251 if( varDimSz == 0 )
continue;
252 std::vector< Tag > varDimTags( varDimSz );
253 for(
unsigned int i = 0; i != varDimSz; i++ )
256 std::string tmptagname = dimNames[varInfo[mapIter->first].varDims[i]];
258 varDimTags[i] = tmptag;
268 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
273 if( !part_tag )
MB_SET_ERR( MB_FAILURE,
"Trouble getting PARTITION_METHOD tag" );
275 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
278 tag_name =
"__GLOBAL_ATTRIBS";
279 Tag globalAttTag = 0;
283 std::vector< int > gattLen;
285 const void* gattptr = gattVal.c_str();
286 int globalAttSz = gattVal.size();
288 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
291 tag_name =
"__GLOBAL_ATTRIBS_LEN";
292 Tag globalAttLenTag = 0;
293 if( gattLen.size() == 0 ) gattLen.push_back( 0 );
297 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
300 for( mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter )
302 std::stringstream ssTagName;
303 ssTagName <<
"__" << mapIter->first <<
"_ATTRIBS";
304 tag_name = ssTagName.str();
309 std::string varAttVal;
310 std::vector< int > varAttLen;
311 if( mapIter->second.numAtts < 1 )
316 varAttVal =
"DUMMY_VAR";
321 varAttVal =
"NO_ATTRIBS";
326 rval =
create_attrib_string( mapIter->second.varAtts, varAttVal, varAttLen );
MB_CHK_SET_ERR( rval,
"Trouble creating attribute string for variable " << mapIter->first );
328 const void* varAttPtr = varAttVal.c_str();
329 int varAttSz = varAttVal.size();
330 if( 0 == varAttSz ) varAttSz = 1;
332 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
335 tag_name = ssTagName.str();
336 Tag varAttLenTag = 0;
337 if( 0 == varAttLen.size() ) varAttLen.push_back( 0 );
341 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
345 tag_name =
"__VAR_NAMES_LOCATIONS";
346 Tag varNamesLocsTag = 0;
347 std::vector< int > varNamesLocs( varInfo.size() );
350 for( mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter )
352 varNamesLocs[std::distance( varInfo.begin(), mapIter )] = mapIter->second.entLoc;
355 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
359 tag_name =
"__MESH_TYPE";
364 ptr = meshTypeName.c_str();
365 int leng = meshTypeName.size();
367 dbgOut.
tprintf( 2,
"Conventional tag %s created\n", tag_name.c_str() );
380 std::string time_tag_name = dimNames[
tDim];
384 const void* data = NULL;
385 int time_tag_size = 0;
388 const double* time_tag_vals =
static_cast< const double*
>( data );
392 std::vector< double > merged_time_vals;
393 merged_time_vals.reserve( time_tag_size +
nTimeSteps );
400 if( time_tag_vals[i] <
tVals[j] )
401 merged_time_vals.push_back( time_tag_vals[i++] );
403 merged_time_vals.push_back(
tVals[j++] );
407 while( i < time_tag_size )
408 merged_time_vals.push_back( time_tag_vals[i++] );
412 merged_time_vals.push_back(
tVals[j++] );
414 data = &merged_time_vals[0];
415 time_tag_size = merged_time_vals.size();
422 std::vector< int >& tstep_nums,
423 std::vector< ReadNC::VarData >& vdatas,
424 std::vector< ReadNC::VarData >& vsetdatas )
426 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
429 std::map< std::string, ReadNC::VarData >::iterator mit;
432 if( var_names.empty() )
434 for( mit = varInfo.begin(); mit != varInfo.end(); ++mit )
442 if( std::find( dimNames.begin(), dimNames.end(), vd.
varName ) != dimNames.end() )
continue;
445 vsetdatas.push_back( vd );
447 vdatas.push_back( vd );
453 for(
unsigned int i = 0; i < var_names.size(); i++ )
455 mit = varInfo.find( var_names[i] );
456 if( mit != varInfo.end() )
464 vsetdatas.push_back( vd );
466 vdatas.push_back( vd );
470 MB_SET_ERR( MB_FAILURE,
"Couldn't find specified variable " << var_names[i] );
479 tstep_nums.push_back( i );
482 if( !tstep_nums.empty() )
484 for(
unsigned int i = 0; i < vdatas.size(); i++ )
486 vdatas[i].varTags.resize( tstep_nums.size(), 0 );
487 vdatas[i].varDatas.resize( tstep_nums.size() );
489 assert( std::find( vdatas[i].varDims.begin(), vdatas[i].varDims.end(),
tDim ) != vdatas[i].varDims.end() );
490 vdatas[i].has_tsteps =
true;
493 for(
unsigned int i = 0; i < vsetdatas.size(); i++ )
495 if( ( std::find( vsetdatas[i].varDims.begin(), vsetdatas[i].varDims.end(),
tDim ) !=
496 vsetdatas[i].varDims.end() ) &&
497 ( vsetdatas[i].varName != dimNames[
tDim] ) )
500 vsetdatas[i].varTags.resize( tstep_nums.size(), 0 );
501 vsetdatas[i].varDatas.resize( tstep_nums.size() );
502 vsetdatas[i].has_tsteps =
true;
507 vsetdatas[i].varTags.resize( 1, 0 );
508 vsetdatas[i].varDatas.resize( 1 );
509 vsetdatas[i].has_tsteps =
false;
526 for(
unsigned int i = 0; i < vdatas.size(); i++ )
529 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
531 void* data = vdatas[i].varDatas[t];
534 if( vdatas[i].has_tsteps )
537 vdatas[i].readStarts[0] = tstep_nums[t];
540 switch( vdatas[i].varDataType )
544 success =
NCFUNCAG( _vara_text )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
545 &vdatas[i].readCounts[0], (
char*)data );
547 MB_SET_ERR( MB_FAILURE,
"Failed to read byte/char data for variable " << vdatas[i].varName );
551 success =
NCFUNCAG( _vara_int )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
552 &vdatas[i].readCounts[0], (
int*)data );
554 MB_SET_ERR( MB_FAILURE,
"Failed to read short/int data for variable " << vdatas[i].varName );
557 success =
NCFUNCAG( _vara_long )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
558 &vdatas[i].readCounts[0], (
long*)data );
560 MB_SET_ERR( MB_FAILURE,
"Failed to read long data for variable " << vdatas[i].varName );
564 success =
NCFUNCAG( _vara_double )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
565 &vdatas[i].readCounts[0], (
double*)data );
567 MB_SET_ERR( MB_FAILURE,
"Failed to read float/double data for variable " << vdatas[i].varName );
570 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
573 dbgOut.
tprintf( 2,
"Setting data for variable %s, time step %d\n", vdatas[i].varName.c_str(),
575 rval = mbImpl->
tag_set_by_ptr( vdatas[i].varTags[t], &
_fileSet, 1, &data, &vdatas[i].sz );
MB_CHK_SET_ERR( rval,
"Trouble setting tag data for variable " << vdatas[i].varName );
579 switch( vdatas[i].varDataType )
594 delete[](
double*)data;
599 vdatas[i].varDatas[t] = NULL;
603 if( !vdatas[i].has_tsteps )
break;
610 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
611 for(
unsigned int i = 1; i < vdatas.size(); i++ )
612 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
621 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
622 std::map< std::string, ReadNC::VarData >::iterator vmit = varInfo.find( var_name );
623 if( varInfo.end() == vmit )
MB_SET_ERR( MB_FAILURE,
"Couldn't find variable " << var_name );
625 assert( lmin >= 0 && lmax >= lmin );
632 if( (std::size_t)tcount != cvals.size() ) cvals.resize( tcount );
635 switch( ( *vmit ).second.varDataType )
641 NCFUNCAG( _vars_double )(
_fileId, ( *vmit ).second.varId, &tstart, &tcount, &dum_stride, &cvals[0] );
642 if( success )
MB_SET_ERR( MB_FAILURE,
"Failed to read float/double data for variable " << var_name );
645 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << var_name );
657 if( tStepBase > 0 ) tstep_num += tStepBase;
659 std::ostringstream tag_name;
661 tag_name << var_data.
varName << tstep_num;
686 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << var_data.
varName );
689 dbgOut.
tprintf( 2,
"Tag %s created\n", tag_name.str().c_str() );
700 if( tStepBase > 0 ) tstep_num += tStepBase;
702 std::ostringstream tag_name;
703 tag_name << var_data.
varName << tstep_num;
726 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << var_data.
varName );
729 dbgOut.
tprintf( 2,
"Tag %s created\n", tag_name.str().c_str() );
736 std::vector< int >& attLen )
739 std::stringstream ssAtt;
741 std::map< std::string, ReadNC::AttData >::const_iterator attIt = attMap.begin();
742 for( ; attIt != attMap.end(); ++attIt )
744 ssAtt << attIt->second.attName;
746 void* attData = NULL;
747 switch( attIt->second.attDataType )
751 sz = attIt->second.attLen;
752 attData = (
char*)malloc( sz );
753 success =
NCFUNC( get_att_text )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
756 MB_SET_ERR( MB_FAILURE,
"Failed to read byte/char data for attribute " << attIt->second.attName );
760 sz = attIt->second.attLen *
sizeof( short );
761 attData = (
short*)malloc( sz );
762 success =
NCFUNC( get_att_short )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
765 MB_SET_ERR( MB_FAILURE,
"Failed to read short data for attribute " << attIt->second.attName );
769 sz = attIt->second.attLen *
sizeof( int );
770 attData = (
int*)malloc( sz );
771 success =
NCFUNC( get_att_int )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
774 MB_SET_ERR( MB_FAILURE,
"Failed to read int data for attribute " << attIt->second.attName );
778 sz = attIt->second.attLen *
sizeof( long );
779 attData = (
long*)malloc( sz );
780 success =
NCFUNC( get_att_long )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
783 MB_SET_ERR( MB_FAILURE,
"Failed to read int data for attribute " << attIt->second.attName );
787 sz = attIt->second.attLen *
sizeof( float );
788 attData = (
float*)malloc( sz );
789 success =
NCFUNC( get_att_float )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
792 MB_SET_ERR( MB_FAILURE,
"Failed to read float data for attribute " << attIt->second.attName );
796 sz = attIt->second.attLen *
sizeof( double );
797 attData = (
double*)malloc( sz );
798 success =
NCFUNC( get_att_double )(
_fileId, attIt->second.attVarId, attIt->second.attName.c_str(),
801 MB_SET_ERR( MB_FAILURE,
"Failed to read double data for attribute " << attIt->second.attName );
805 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for attribute " << attIt->second.attName );
807 char* tmpc = (
char*)attData;
808 for(
unsigned int counter = 0; counter != sz; ++counter )
809 ssAtt << tmpc[counter];
812 attLen.push_back( ssAtt.str().size() - 1 );
814 attVal = ssAtt.str();
824 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
831 for(
unsigned int i = 0; i < dimNames.size(); i++ )
834 if( varInfo.find( dimNames[i] ) != varInfo.end() )
continue;
837 int sizeTotalVar = varInfo.size();
838 std::string var_name( dimNames[i] );
841 data.
varId = sizeTotalVar;
849 dbgOut.
tprintf( 2,
"Dummy coordinate variable created for dimension %s\n", var_name.c_str() );
857 const void* ptr = &dimLens[i];
862 dbgOut.
tprintf( 2,
"Sparse tag created for dimension %s\n", var_name.c_str() );
869 std::vector< int >& tstep_nums )
876 for(
unsigned int i = 0; i < vdatas.size(); i++ )
879 if( vdatas[i].has_tsteps )
882 vdatas[i].readStarts.push_back( 0 );
883 vdatas[i].readCounts.push_back( 1 );
886 for(
unsigned int idx = 1; idx != vdatas[i].varDims.size(); idx++ )
888 vdatas[i].readStarts.push_back( 0 );
889 vdatas[i].readCounts.push_back( dimLens[vdatas[i].varDims[idx]] );
894 if( vdatas[i].varDims.empty() )
897 vdatas[i].readStarts.push_back( 0 );
898 vdatas[i].readCounts.push_back( 1 );
902 for(
unsigned int idx = 0; idx != vdatas[i].varDims.size(); idx++ )
904 vdatas[i].readStarts.push_back( 0 );
905 vdatas[i].readCounts.push_back( dimLens[vdatas[i].varDims[idx]] );
912 for( std::size_t idx = 0; idx != vdatas[i].readCounts.size(); idx++ )
913 vdatas[i].sz *= vdatas[i].readCounts[idx];
916 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
918 dbgOut.
tprintf( 2,
"Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t] );
920 if( tstep_nums[t] >= dimLens[
tDim] )
926 if( !vdatas[i].varTags[t] )
928 rval =
get_tag_to_set( vdatas[i], tstep_nums[t], vdatas[i].varTags[t] );
MB_CHK_SET_ERR( rval,
"Trouble getting tag to set variable " << vdatas[i].varName );
931 switch( vdatas[i].varDataType )
935 vdatas[i].varDatas[t] =
new char[vdatas[i].sz];
939 vdatas[i].varDatas[t] =
new int[vdatas[i].sz];
942 vdatas[i].varDatas[t] =
new long[vdatas[i].sz];
946 vdatas[i].varDatas[t] =
new double[vdatas[i].sz];
949 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
954 if( !vdatas[i].has_tsteps )
break;
1021 rval = mbImpl->
tag_iterate( *mpFileIdTag, tmp_range.
begin(), tmp_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate file ID tag on local vertices" );
1023 int* fid_data = (
int*)data;
1024 rval = mbImpl->
tag_iterate( mGlobalIdTag, tmp_range.
begin(), tmp_range.
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate global ID tag on local vertices" );
1026 int* gid_data = (
int*)data;
1027 for(
int i = 0; i < count; i++ )
1028 fid_data[i] = gid_data[i];
1039 double *xc, *yc, *zc;
1042 int i, j, k, il, jl, kl;
1045 assert( dil == (
int)
ilVals.size() && djl == (
int)
jlVals.size() &&
1057 unsigned int pos = i + j * dil + k * dil * djl;
1068 std::vector< int > gids( num_verts );
1070 rval = mbImpl->
tag_get_data( mGlobalIdTag, verts, &gids[0] );
MB_CHK_SET_ERR( rval,
"Trouble getting local gid values of vertices" );
1071 int vmin = *( std::min_element( gids.begin(), gids.end() ) ),
1072 vmax = *( std::max_element( gids.begin(), gids.end() ) );
1073 dbgOut.
tprintf( 1,
"Vertex gids %d-%d\n", vmin, vmax );
1085 std::vector< EntityHandle > connect;
1102 std::vector< ReadNC::VarData > vdatas;
1103 std::vector< ReadNC::VarData > vsetdatas;
1107 if( !vsetdatas.empty() )
1112 if( !vdatas.empty() )
1121 std::vector< int >& tstep_nums )
1127 Range* range = NULL;
1132 assert(
"Should only have a single vertex subrange, since they were read in one shot" && verts.
psize() == 1 );
1140 assert(
"Should only have a single face subrange, since they were read in one shot" && faces.
psize() == 1 );
1142 #ifdef MOAB_HAVE_MPI
1151 faces_owned = faces;
1154 for(
unsigned int i = 0; i < vdatas.size(); i++ )
1157 assert( 4 == vdatas[i].varDims.size() );
1160 assert(
tDim == vdatas[i].varDims[0] );
1163 vdatas[i].readStarts.resize( 4 );
1164 vdatas[i].readCounts.resize( 4 );
1167 vdatas[i].readStarts[0] = 0;
1168 vdatas[i].readCounts[0] = 1;
1171 vdatas[i].readStarts[1] = 0;
1172 vdatas[i].readCounts[1] = vdatas[i].numLev;
1175 switch( vdatas[i].entLoc )
1179 vdatas[i].readStarts[2] =
lDims[1];
1180 vdatas[i].readCounts[2] =
lDims[4] -
lDims[1] + 1;
1181 vdatas[i].readStarts[3] =
lDims[0];
1182 vdatas[i].readCounts[3] =
lDims[3] -
lDims[0] + 1;
1192 vdatas[i].readStarts[2] =
lCDims[1];
1194 vdatas[i].readStarts[3] =
lCDims[0];
1196 #ifdef MOAB_HAVE_MPI
1197 range = &faces_owned;
1203 MB_SET_ERR( MB_FAILURE,
"Unexpected entity location type for variable " << vdatas[i].varName );
1206 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
1208 dbgOut.
tprintf( 2,
"Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t] );
1210 if( tstep_nums[t] >= dimLens[
tDim] )
1216 if( !vdatas[i].varTags[t] )
1218 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 to non-set variable " << vdatas[i].varName );
1224 rval = mbImpl->
tag_iterate( vdatas[i].varTags[t], range->
begin(), range->
end(), count, data );
MB_CHK_SET_ERR( rval,
"Failed to iterate tag for non-set variable " << vdatas[i].varName );
1225 assert( (
unsigned)count == range->
size() );
1226 vdatas[i].varDatas[t] = data;
1231 for( std::size_t idx = 0; idx != vdatas[i].readCounts.size(); idx++ )
1232 vdatas[i].sz *= vdatas[i].readCounts[idx];
1239 std::vector< int >& tstep_nums )
1247 for(
unsigned int i = 0; i < vdatas.size(); i++ )
1249 std::size_t sz = vdatas[i].sz;
1253 size_t ni = vdatas[i].readCounts[3];
1254 size_t nj = vdatas[i].readCounts[2];
1255 size_t nk = vdatas[i].readCounts[1];
1257 for(
unsigned int t = 0; t < tstep_nums.size(); t++ )
1260 void* data = vdatas[i].varDatas[t];
1263 vdatas[i].readStarts[0] = tstep_nums[t];
1265 switch( vdatas[i].varDataType )
1269 std::vector< char > tmpchardata( sz );
1270 success =
NCFUNCAG( _vara_text )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
1271 &vdatas[i].readCounts[0], &tmpchardata[0] );
1273 MB_SET_ERR( MB_FAILURE,
"Failed to read byte/char data for variable " << vdatas[i].varName );
1274 if( vdatas[i].numLev > 1 )
1276 kji_to_jik( ni, nj, nk, data, &tmpchardata[0] );
1279 for( std::size_t idx = 0; idx != tmpchardata.size(); idx++ )
1280 ( (
char*)data )[idx] = tmpchardata[idx];
1286 std::vector< int > tmpintdata( sz );
1287 success =
NCFUNCAG( _vara_int )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
1288 &vdatas[i].readCounts[0], &tmpintdata[0] );
1290 MB_SET_ERR( MB_FAILURE,
"Failed to read short/int data for variable " << vdatas[i].varName );
1291 if( vdatas[i].numLev > 1 )
1293 kji_to_jik( ni, nj, nk, data, &tmpintdata[0] );
1296 for( std::size_t idx = 0; idx != tmpintdata.size(); idx++ )
1297 ( (
int*)data )[idx] = tmpintdata[idx];
1302 std::vector< long > tmpintdata( sz );
1303 success =
NCFUNCAG( _vara_long )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
1304 &vdatas[i].readCounts[0], &tmpintdata[0] );
1306 MB_SET_ERR( MB_FAILURE,
"Failed to read long data for variable " << vdatas[i].varName );
1307 if( vdatas[i].numLev > 1 )
1309 kji_to_jik( ni, nj, nk, data, &tmpintdata[0] );
1312 for( std::size_t idx = 0; idx != tmpintdata.size(); idx++ )
1313 ( (
long*)data )[idx] = tmpintdata[idx];
1319 std::vector< double > tmpdoubledata( sz );
1320 success =
NCFUNCAG( _vara_double )(
_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
1321 &vdatas[i].readCounts[0], &tmpdoubledata[0] );
1323 MB_SET_ERR( MB_FAILURE,
"Failed to read float/double data for variable " << vdatas[i].varName );
1324 if( vdatas[i].numLev > 1 )
1326 kji_to_jik( ni, nj, nk, data, &tmpdoubledata[0] );
1329 for( std::size_t idx = 0; idx != tmpdoubledata.size(); idx++ )
1330 ( (
double*)data )[idx] = tmpdoubledata[idx];
1335 MB_SET_ERR( MB_FAILURE,
"Unexpected data type for variable " << vdatas[i].varName );
1343 dbgOut.
printf( 1,
"Read variables: %s", vdatas.begin()->varName.c_str() );
1344 for(
unsigned int i = 1; i < vdatas.size(); i++ )
1345 dbgOut.
printf( 1,
", %s ", vdatas[i].varName.c_str() );
1359 std::size_t numOwnedEnts = 0;
1360 #ifdef MOAB_HAVE_MPI
1367 numOwnedEnts = ents_owned.
size();
1371 numOwnedEnts = ents.
size();
1375 numOwnedEnts = ents.
size();
1381 std::vector< double > coords( numOwnedEnts * 3 );
1382 std::size_t pos = 0;
1383 for( std::size_t j = 0; j !=
jlCVals.size(); ++j )
1385 for( std::size_t i = 0; i !=
ilCVals.size(); ++i )
1387 pos = j *
ilCVals.size() * 3 + i * 3;
1390 coords[pos + 2] = 0.0;
1393 std::string tag_name =
"COORDS";
1399 #ifdef MOAB_HAVE_MPI
1404 assert( count == (
int)numOwnedEnts );
1405 double* quad_data = (
double*)data;
1406 std::copy( coords.begin(), coords.end(), quad_data );
1413 std::vector< ReadNC::VarData > vdatas;
1414 std::vector< ReadNC::VarData > vsetdatas;
1418 if( !vsetdatas.empty() )
1423 if( !vdatas.empty() )
1425 #ifdef MOAB_HAVE_PNETCDF
1427 rval = read_ucd_variables_to_nonset_async( vdatas, tstep_nums );
MB_CHK_SET_ERR( rval,
"Trouble reading variables to verts/edges/faces" );