12 std::vector< std::string >& dimNames = readNC->
dimNames;
15 if( ( std::find( dimNames.begin(), dimNames.end(), std::string(
"lon" ) ) != dimNames.end() ) &&
16 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"lat" ) ) != dimNames.end() ) &&
17 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"slon" ) ) != dimNames.end() ) &&
18 ( std::find( dimNames.begin(), dimNames.end(), std::string(
"slat" ) ) != dimNames.end() ) )
21 std::map< std::string, ReadNC::AttData >::iterator attIt = readNC->
globalAtts.find(
"source" );
22 if( attIt == readNC->
globalAtts.end() )
return false;
23 unsigned int sz = attIt->second.attLen;
25 att_data.resize( sz + 1 );
26 att_data[sz] =
'\000';
28 NCFUNC( get_att_text )( fileId, attIt->second.attVarId, attIt->second.attName.c_str(), &att_data[0] );
29 if( success )
return false;
30 if( att_data.find(
"CAM" ) == std::string::npos )
return false;
43 std::map< std::string, ReadNC::VarData >& varInfo =
_readNC->
varInfo;
51 std::vector< std::string >::iterator vit;
53 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"slon" ) ) != dimNames.end() )
54 idx = vit - dimNames.begin();
57 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'slon' variable" );
61 gDims[3] = dimLens[idx] - 1;
64 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"slat" ) ) != dimNames.end() )
65 idx = vit - dimNames.begin();
68 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'slat' variable" );
72 gDims[4] = dimLens[idx] - 1 + 2;
76 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"lon" ) ) != dimNames.end() )
77 idx = vit - dimNames.begin();
80 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lon' variable" );
84 gCDims[3] = dimLens[idx] - 1;
87 std::vector< double > til_vals( 2 );
89 if( std::fabs( 2 * til_vals[1] - til_vals[0] - 360 ) < 0.001 )
globallyPeriodic[0] = 1;
91 assert(
"Number of vertices and edges should be same" &&
gDims[3] ==
gCDims[3] );
93 assert(
"Number of vertices should equal to number of edges plus one" &&
gDims[3] ==
gCDims[3] + 1 );
96 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"lat" ) ) != dimNames.end() )
97 idx = vit - dimNames.begin();
100 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lat' dimension" );
104 gCDims[4] = dimLens[idx] - 1;
114 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"time" ) ) != dimNames.end() )
115 idx = vit - dimNames.begin();
116 else if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"t" ) ) != dimNames.end() )
117 idx = vit - dimNames.begin();
120 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'time' or 't' dimension" );
126 if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"lev" ) ) != dimNames.end() )
127 idx = vit - dimNames.begin();
128 else if( ( vit = std::find( dimNames.begin(), dimNames.end(),
"ilev" ) ) != dimNames.end() )
129 idx = vit - dimNames.begin();
132 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lev' or 'ilev' dimension" );
138 int rank = 0, procs = 1;
149 for(
int i = 0; i < 6; i++ )
151 for(
int i = 0; i < 3; i++ )
157 for(
int i = 0; i < 3; i++ )
158 parData.
pDims[i] = pdims[i];
163 dbgOut.
tprintf( 1,
"Contiguous chunks of size %d bytes.\n",
168 for(
int i = 0; i < 6; i++ )
199 std::map< std::string, ReadNC::VarData >::iterator vmit;
202 if( ( vmit = varInfo.find(
"lon" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
208 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lon' variable" );
214 if( ( vmit = varInfo.find(
"lat" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
220 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'lat' variable" );
226 if( ( vmit = varInfo.find(
"slon" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
232 std::vector< double > dummyVar(
lDims[3] -
lDims[0] );
234 double dif = dummyVar[1] - dummyVar[0];
236 for( i = 0; i != dummyVar.size(); i++ )
247 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'slon' variable" );
253 if( ( vmit = varInfo.find(
"slat" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
257 std::vector< double > dummyVar(
lDims[4] -
lDims[1] - 1 );
262 for( i = 1; i != dummyVar.size() + 1; i++ )
263 jlVals[i] = dummyVar[i - 1];
272 std::vector< double > dummyVar(
lDims[4] -
lDims[1] );
276 for(
int i = 1; i <
lDims[4] + 1; i++ )
277 jlVals[i] = dummyVar[i - 1];
282 std::vector< double > dummyVar(
lDims[4] -
lDims[1] );
286 for( i = 0; i != dummyVar.size(); i++ )
299 MB_SET_ERR( MB_FAILURE,
"Couldn't find 'slat' variable" );
306 if( ( vmit = varInfo.find(
"time" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
310 else if( ( vmit = varInfo.find(
"t" ) ) != varInfo.end() && ( *vmit ).second.varDims.size() == 1 )
318 tVals.push_back( (
double)t );
327 std::map< std::string, ReadNC::VarData >::iterator mit;
328 for( mit = varInfo.begin(); mit != varInfo.end(); ++mit )
350 std::vector< std::string > ijdimNames( 4 );
351 ijdimNames[0] =
"__slon";
352 ijdimNames[1] =
"__slat";
353 ijdimNames[2] =
"__lon";
354 ijdimNames[3] =
"__lat";
356 std::string tag_name;
360 for(
unsigned int i = 0; i != ijdimNames.size(); i++ )
362 std::vector< int > val( 2, 0 );
363 if( ijdimNames[i] ==
"__slon" )
368 else if( ijdimNames[i] ==
"__slat" )
373 else if( ijdimNames[i] ==
"__lon" )
378 else if( ijdimNames[i] ==
"__lat" )
383 std::stringstream ss_tag_name;
384 ss_tag_name << ijdimNames[i] <<
"_LOC_MINMAX";
385 tag_name = ss_tag_name.str();
388 if(
MB_SUCCESS == rval ) dbgOut.
tprintf( 2,
"Conventional tag %s is created.\n", tag_name.c_str() );
393 switch( varInfo[
"lon"].varDataType )
399 MB_SET_ERR( MB_FAILURE,
"Unexpected variable data type for 'lon'" );
402 for(
unsigned int i = 0; i != ijdimNames.size(); i++ )
406 if( ijdimNames[i] ==
"__slon" )
411 else if( ijdimNames[i] ==
"__slat" )
416 else if( ijdimNames[i] ==
"__lon" )
421 else if( ijdimNames[i] ==
"__lat" )
427 std::stringstream ss_tag_name;
428 ss_tag_name << ijdimNames[i] <<
"_LOC_VALS";
429 tag_name = ss_tag_name.str();
433 if(
MB_SUCCESS == rval ) dbgOut.
tprintf( 2,
"Conventional tag %s is created.\n", tag_name.c_str() );
437 for(
unsigned int i = 0; i != ijdimNames.size(); i++ )
439 std::vector< int > val( 2, 0 );
440 if( ijdimNames[i] ==
"__slon" )
445 else if( ijdimNames[i] ==
"__slat" )
450 else if( ijdimNames[i] ==
"__lon" )
455 else if( ijdimNames[i] ==
"__lat" )
460 std::stringstream ss_tag_name;
461 ss_tag_name << ijdimNames[i] <<
"_GLOBAL_MINMAX";
462 tag_name = ss_tag_name.str();
465 if(
MB_SUCCESS == rval ) dbgOut.
tprintf( 2,
"Conventional tag %s is created.\n", tag_name.c_str() );