Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::ReadNC Class Reference

Output Exodus File for VERDE. More...

#include <ReadNC.hpp>

+ Inheritance diagram for moab::ReadNC:
+ Collaboration diagram for moab::ReadNC:

Classes

class  AttData
 
class  VarData
 

Public Types

enum  NCFormatType {
  NC_FORMAT_UNKNOWN_TYPE = 0 , NC_FORMAT_MPAS = 1 , NC_FORMAT_SCRIP = 2 , NC_FORMAT_ESMF = 3 ,
  NC_FORMAT_DOMAIN = 4 , NC_FORMAT_HOMME = 5 , NC_FORMAT_GCRM = 6 , NC_FORMAT_EULER = 7 ,
  NC_FORMAT_FV = 8
}
 
enum  EntityLocation {
  ENTLOCVERT = 0 , ENTLOCNSEDGE , ENTLOCEWEDGE , ENTLOCFACE ,
  ENTLOCSET , ENTLOCEDGE , ENTLOCREGION
}
 ENTLOCNSEDGE for north/south edge ENTLOCWEEDGE for west/east edge. More...
 

Public Member Functions

ErrorCode load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=nullptr, const Tag *file_id_tag=nullptr)
 Load an NC file. More...
 
 ReadNC (Interface *impl=nullptr)
 Constructor. More...
 
virtual ~ReadNC ()
 Destructor. More...
 
virtual ErrorCode read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=nullptr)
 Read tag values from a file. More...
 
- Public Member Functions inherited from moab::ReaderIface
virtual ~ReaderIface ()
 

Static Public Member Functions

static ReaderIfacefactory (Interface *)
 

Private Member Functions

ErrorCode read_header ()
 Read the header information. More...
 
ErrorCode get_attributes (int var_id, int num_atts, std::map< std::string, AttData > &atts, const char *prefix="")
 Get all global attributes in the file. More...
 
ErrorCode get_dimensions (int file_id, std::vector< std::string > &dim_names, std::vector< int > &dim_lens)
 Get all dimensions in the file. More...
 
ErrorCode get_variables ()
 Get the variable names and other info defined for this file. More...
 
ErrorCode parse_options (const FileOptions &opts, std::vector< std::string > &var_names, std::vector< int > &tstep_nums, std::vector< double > &tstep_vals)
 

Private Attributes

ReadUtilIfacereadMeshIface
 
InterfacembImpl
 Interface instance. More...
 
std::string fileName
 File name. More...
 
int fileId
 File numbers assigned by netcdf. More...
 
std::vector< std::string > dimNames
 Dimension names. More...
 
std::vector< int > dimLens
 Dimension lengths. More...
 
std::map< std::string, AttDataglobalAtts
 Global attribs. More...
 
std::map< std::string, VarDatavarInfo
 Variable info. More...
 
Tag mGlobalIdTag
 Cached tags for reading. Note that all these tags are defined when the core is initialized. More...
 
const TagmpFileIdTag
 This is a pointer to the file id tag that is passed from ReadParallel it gets deleted at the end of resolve sharing, but it will have same data as the global id tag global id tag is preserved, and is needed later on. More...
 
DebugOutput dbgOut
 Debug stuff. More...
 
bool isParallel
 Are we reading in parallel? More...
 
int partMethod
 Partitioning method. More...
 
ScdInterfacescdi
 Scd interface. More...
 
ScdParData parData
 Parallel data object, to be cached with ScdBox. More...
 
bool noMesh
 Read options. More...
 
bool noVars
 
bool spectralMesh
 
bool noMixedElements
 
bool noEdges
 
bool culling
 
bool repartition
 
int gatherSetRank
 
int tStepBase
 
int trivialPartitionShift
 
NCHelpermyHelper
 Helper class instance. More...
 

Friends

class NCHelper
 
class ScdNCHelper
 
class UcdNCHelper
 
class NCHelperEuler
 
class NCHelperFV
 
class NCHelperDomain
 
class NCHelperScrip
 
class NCHelperHOMME
 
class NCHelperMPAS
 
class NCHelperESMF
 
class NCHelperGCRM
 

Detailed Description

Output Exodus File for VERDE.

Definition at line 62 of file ReadNC.hpp.

Member Enumeration Documentation

◆ EntityLocation

ENTLOCNSEDGE for north/south edge ENTLOCWEEDGE for west/east edge.

Enumerator
ENTLOCVERT 
ENTLOCNSEDGE 
ENTLOCEWEDGE 
ENTLOCFACE 
ENTLOCSET 
ENTLOCEDGE 
ENTLOCREGION 

Definition at line 113 of file ReadNC.hpp.

114  {
115  ENTLOCVERT = 0,
116  ENTLOCNSEDGE,
117  ENTLOCEWEDGE,
118  ENTLOCFACE,
119  ENTLOCSET,
120  ENTLOCEDGE,
122  };

◆ NCFormatType

Enumerator
NC_FORMAT_UNKNOWN_TYPE 
NC_FORMAT_MPAS 
NC_FORMAT_SCRIP 
NC_FORMAT_ESMF 
NC_FORMAT_DOMAIN 
NC_FORMAT_HOMME 
NC_FORMAT_GCRM 
NC_FORMAT_EULER 
NC_FORMAT_FV 

Definition at line 79 of file ReadNC.hpp.

80  {
82  NC_FORMAT_MPAS = 1,
83  NC_FORMAT_SCRIP = 2,
84  NC_FORMAT_ESMF = 3,
85  NC_FORMAT_DOMAIN = 4,
86  NC_FORMAT_HOMME = 5,
87  NC_FORMAT_GCRM = 6,
88  NC_FORMAT_EULER = 7,
89  NC_FORMAT_FV = 8
90  };

Constructor & Destructor Documentation

◆ ReadNC()

moab::ReadNC::ReadNC ( Interface impl = nullptr)
explicit

Constructor.

Definition at line 16 of file ReadNC.cpp.

17  : mbImpl( impl ), fileId( -1 ), mGlobalIdTag( 0 ), mpFileIdTag( NULL ), dbgOut( stderr ), isParallel( false ),
19 #ifdef MOAB_HAVE_MPI
20  myPcomm( NULL ),
21 #endif
22  noMesh( false ), noVars( false ), spectralMesh( false ), noMixedElements( false ), noEdges( false ), culling(true),
23  repartition(false), gatherSetRank( -1 ), tStepBase( -1 ), trivialPartitionShift( 0 ), myHelper( NULL )
24 {
25  assert( impl != NULL );
26  impl->query_interface( readMeshIface );
27 }

References moab::Interface::query_interface(), and readMeshIface.

Referenced by factory().

◆ ~ReadNC()

moab::ReadNC::~ReadNC ( )
virtual

Destructor.

Definition at line 29 of file ReadNC.cpp.

30 {
32  if( myHelper != NULL ) delete myHelper;
33 }

References mbImpl, myHelper, readMeshIface, and moab::Interface::release_interface().

Member Function Documentation

◆ factory()

ReaderIface * moab::ReadNC::factory ( Interface iface)
static

Definition at line 11 of file ReadNC.cpp.

12 {
13  return new ReadNC( iface );
14 }

References iface, and ReadNC().

Referenced by moab::ReaderWriterSet::ReaderWriterSet().

◆ get_attributes()

ErrorCode moab::ReadNC::get_attributes ( int  var_id,
int  num_atts,
std::map< std::string, AttData > &  atts,
const char *  prefix = "" 
)
private

Get all global attributes in the file.

Definition at line 343 of file ReadNC.cpp.

344 {
345  char dum_name[120];
346 
347  for( int i = 0; i < num_atts; i++ )
348  {
349  // Get the name
350  int success = NCFUNC( inq_attname )( fileId, var_id, i, dum_name );
351  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting attribute name" );
352 
353  AttData& data = atts[std::string( dum_name )];
354  data.attName = std::string( dum_name );
355  success = NCFUNC( inq_att )( fileId, var_id, dum_name, &data.attDataType, &data.attLen );
356  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting info for attribute " << data.attName );
357  data.attVarId = var_id;
358 
359  dbgOut.tprintf( 2, "%sAttribute %s: length=%u, varId=%d, type=%d\n", ( prefix ? prefix : "" ),
360  data.attName.c_str(), (unsigned int)data.attLen, data.attVarId, data.attDataType );
361  }
362 
363  return MB_SUCCESS;
364 }

References moab::ReadNC::AttData::attDataType, moab::ReadNC::AttData::attLen, moab::ReadNC::AttData::attName, moab::ReadNC::AttData::attVarId, dbgOut, fileId, MB_SET_ERR, MB_SUCCESS, NCFUNC, and moab::DebugOutput::tprintf().

Referenced by get_variables(), and read_header().

◆ get_dimensions()

ErrorCode moab::ReadNC::get_dimensions ( int  file_id,
std::vector< std::string > &  dim_names,
std::vector< int > &  dim_lens 
)
private

Get all dimensions in the file.

Definition at line 366 of file ReadNC.cpp.

367 {
368  // Get the number of dimensions
369  int num_dims;
370  int success = NCFUNC( inq_ndims )( file_id, &num_dims );
371  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting number of dimensions" );
372 
373  if( num_dims > NC_MAX_DIMS )
374  {
375  MB_SET_ERR( MB_FAILURE,
376  "ReadNC: File contains " << num_dims << " dims but NetCDF library supports only " << NC_MAX_DIMS );
377  }
378 
379  char dim_name[NC_MAX_NAME + 1];
380  NCDF_SIZE dim_len;
381  dim_names.resize( num_dims );
382  dim_lens.resize( num_dims );
383 
384  for( int i = 0; i < num_dims; i++ )
385  {
386  success = NCFUNC( inq_dim )( file_id, i, dim_name, &dim_len );
387  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting dimension info" );
388 
389  dim_names[i] = std::string( dim_name );
390  dim_lens[i] = dim_len;
391 
392  dbgOut.tprintf( 2, "Dimension %s, length=%u\n", dim_name, (unsigned int)dim_len );
393  }
394 
395  return MB_SUCCESS;
396 }

References dbgOut, MB_SET_ERR, MB_SUCCESS, NCDF_SIZE, NCFUNC, and moab::DebugOutput::tprintf().

Referenced by moab::NCHelperHOMME::create_mesh(), and read_header().

◆ get_variables()

ErrorCode moab::ReadNC::get_variables ( )
private

Get the variable names and other info defined for this file.

Definition at line 398 of file ReadNC.cpp.

399 {
400  // First cache the number of time steps
401  std::vector< std::string >::iterator vit = std::find( dimNames.begin(), dimNames.end(), "time" );
402  if( vit == dimNames.end() ) vit = std::find( dimNames.begin(), dimNames.end(), "t" );
403 
404  int ntimes = 0;
405  if( vit != dimNames.end() ) ntimes = dimLens[vit - dimNames.begin()];
406  if( !ntimes ) ntimes = 1;
407 
408  // Get the number of variables
409  int num_vars;
410  int success = NCFUNC( inq_nvars )( fileId, &num_vars );
411  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting number of variables" );
412 
413  if( num_vars > NC_MAX_VARS )
414  {
415  MB_SET_ERR( MB_FAILURE,
416  "ReadNC: File contains " << num_vars << " vars but NetCDF library supports only " << NC_MAX_VARS );
417  }
418 
419  char var_name[NC_MAX_NAME + 1];
420  int var_ndims;
421 
422  for( int i = 0; i < num_vars; i++ )
423  {
424  // Get the name first, so we can allocate a map iterate for this var
425  success = NCFUNC( inq_varname )( fileId, i, var_name );
426  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting variable name" );
427  VarData& data = varInfo[std::string( var_name )];
428  data.varName = std::string( var_name );
429  data.varId = i;
430  data.varTags.resize( ntimes, 0 );
431 
432  // Get the data type
433  success = NCFUNC( inq_vartype )( fileId, i, &data.varDataType );
434  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting data type for variable " << data.varName );
435 
436  // Get the number of dimensions, then the dimensions
437  success = NCFUNC( inq_varndims )( fileId, i, &var_ndims );
438  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting number of dims for variable " << data.varName );
439  data.varDims.resize( var_ndims );
440 
441  success = NCFUNC( inq_vardimid )( fileId, i, &data.varDims[0] );
442  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting dimensions for variable " << data.varName );
443 
444  // Finally, get the number of attributes, then the attributes
445  success = NCFUNC( inq_varnatts )( fileId, i, &data.numAtts );
446  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble getting number of dims for variable " << data.varName );
447 
448  // Print debug info here so attribute info comes afterwards
449  dbgOut.tprintf( 2, "Variable %s: Id=%d, numAtts=%d, datatype=%d, num_dims=%u\n", data.varName.c_str(),
450  data.varId, data.numAtts, data.varDataType, (unsigned int)data.varDims.size() );
451 
452  ErrorCode rval = get_attributes( i, data.numAtts, data.varAtts, " " );MB_CHK_SET_ERR( rval, "Trouble getting attributes for variable " << data.varName );
453  }
454 
455  return MB_SUCCESS;
456 }

References dbgOut, dimLens, dimNames, ErrorCode, fileId, get_attributes(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, NCFUNC, moab::ReadNC::VarData::numAtts, moab::DebugOutput::tprintf(), moab::ReadNC::VarData::varAtts, moab::ReadNC::VarData::varDataType, moab::ReadNC::VarData::varDims, moab::ReadNC::VarData::varId, varInfo, moab::ReadNC::VarData::varName, and moab::ReadNC::VarData::varTags.

Referenced by read_header().

◆ load_file()

ErrorCode moab::ReadNC::load_file ( const char *  file_name,
const EntityHandle file_set,
const FileOptions opts,
const SubsetList subset_list = nullptr,
const Tag file_id_tag = nullptr 
)
virtual

Load an NC file.

Implements moab::ReaderIface.

Definition at line 35 of file ReadNC.cpp.

40 {
41  // See if opts has variable(s) specified
42  std::vector< std::string > var_names;
43  std::vector< int > tstep_nums;
44  std::vector< double > tstep_vals;
45 
46  // Get and cache predefined tag handles
48  // Store the pointer to the tag; if not null, set when global id tag
49  // is set too, with the same data, duplicated
50  mpFileIdTag = file_id_tag;
51 
52  ErrorCode rval = parse_options( opts, var_names, tstep_nums, tstep_vals );MB_CHK_SET_ERR( rval, "Trouble parsing option string" );
53 
54  // Open the file
55  dbgOut.tprintf( 1, "Opening file %s\n", file_name );
56  fileName = std::string( file_name );
57  int success;
58 
59 #ifdef MOAB_HAVE_PNETCDF
60  if( isParallel )
61  success = NCFUNC( open )( myPcomm->proc_config().proc_comm(), file_name, 0, MPI_INFO_NULL, &fileId );
62  else
63  success = NCFUNC( open )( MPI_COMM_SELF, file_name, 0, MPI_INFO_NULL, &fileId );
64 #else
65  success = NCFUNC( open )( file_name, 0, &fileId );
66 #endif
67  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble opening file " << file_name );
68 
69  // Read the header (num dimensions, dimensions, num variables, global attribs)
70  rval = read_header();MB_CHK_SET_ERR( rval, "Trouble reading file header" );
71 
72  // Make sure there's a file set to put things in
73  EntityHandle tmp_set;
74  if( noMesh && !file_set )
75  {
76  MB_SET_ERR( MB_FAILURE, "NOMESH option requires non-NULL file set on input" );
77  }
78  else if( !file_set || ( file_set && *file_set == 0 ) )
79  {
80  rval = mbImpl->create_meshset( MESHSET_SET, tmp_set );MB_CHK_SET_ERR( rval, "Trouble creating file set" );
81  }
82  else
83  tmp_set = *file_set;
84 
85  // Get the scd interface
86  scdi = NULL;
87  rval = mbImpl->query_interface( scdi );
88  if( NULL == scdi ) return MB_FAILURE;
89 
90  if( NULL != myHelper ) delete myHelper;
91 
92  // Get appropriate NC helper instance based on information read from the header
93  myHelper = NCHelper::get_nc_helper( this, fileId, opts, tmp_set );
94  if( NULL == myHelper )
95  {
96  MB_SET_ERR( MB_FAILURE, "Failed to get NCHelper class instance" );
97  }
98 
99  // Initialize mesh values
100  rval = myHelper->init_mesh_vals();MB_CHK_SET_ERR( rval, "Trouble initializing mesh values" );
101 
102  // Check existing mesh from last read
103  if( noMesh && !noVars )
104  {
105  rval = myHelper->check_existing_mesh();MB_CHK_SET_ERR( rval, "Trouble checking mesh from last read" );
106  }
107 
108  // Create some conventional tags, e.g. __NUM_DIMS
109  // For multiple reads to a specified file set, we assume a single file, or a series of
110  // files with separated timesteps. Keep a flag on the file set to prevent conventional
111  // tags from being created again on a second read
112  Tag convTagsCreated = 0;
113  int def_val = 0;
114  rval = mbImpl->tag_get_handle( "__CONV_TAGS_CREATED", 1, MB_TYPE_INTEGER, convTagsCreated,
115  MB_TAG_SPARSE | MB_TAG_CREAT, &def_val );MB_CHK_SET_ERR( rval, "Trouble getting _CONV_TAGS_CREATED tag" );
116  int create_conv_tags_flag = 0;
117  rval = mbImpl->tag_get_data( convTagsCreated, &tmp_set, 1, &create_conv_tags_flag );
118  // The first read to the file set
119  if( 0 == create_conv_tags_flag )
120  {
121  // Read dimensions (coordinate variables) by default to create tags like __<var_name>_DIMS
122  // This is done only once (assume that all files read to the file set have the same
123  // dimensions)
124  rval = myHelper->read_variables( dimNames, tstep_nums );MB_CHK_SET_ERR( rval, "Trouble reading dimensions" );
125 
126  rval = myHelper->create_conventional_tags( tstep_nums );MB_CHK_SET_ERR( rval, "Trouble creating NC conventional tags" );
127 
128  create_conv_tags_flag = 1;
129  rval = mbImpl->tag_set_data( convTagsCreated, &tmp_set, 1, &create_conv_tags_flag );MB_CHK_SET_ERR( rval, "Trouble setting data to _CONV_TAGS_CREATED tag" );
130  }
131  // Another read to the file set
132  else
133  {
134  if( tStepBase > -1 )
135  {
136  // If timesteps spread across files, merge time values read
137  // from current file to existing time tag
138  rval = myHelper->update_time_tag_vals();MB_CHK_SET_ERR( rval, "Trouble updating time tag values" );
139  }
140  }
141 
142  // Create mesh vertex/edge/face sequences
143  Range faces;
144  if( !noMesh )
145  {
146  rval = myHelper->create_mesh( faces );MB_CHK_SET_ERR( rval, "Trouble creating mesh" );
147  }
148 
149  // Read specified variables onto grid
150  if( !noVars )
151  {
152  if( var_names.empty() )
153  {
154  // If VARIABLE option is missing, read all variables
155  rval = myHelper->read_variables( var_names, tstep_nums );MB_CHK_SET_ERR( rval, "Trouble reading all variables" );
156  }
157  else
158  {
159  // Exclude dimensions that are read to the file set by default
160  std::vector< std::string > non_dim_var_names;
161  for( unsigned int i = 0; i < var_names.size(); i++ )
162  {
163  if( std::find( dimNames.begin(), dimNames.end(), var_names[i] ) == dimNames.end() )
164  non_dim_var_names.push_back( var_names[i] );
165  }
166 
167  if( !non_dim_var_names.empty() )
168  {
169  rval = myHelper->read_variables( non_dim_var_names, tstep_nums );MB_CHK_SET_ERR( rval, "Trouble reading specified variables" );
170  }
171  }
172  }
173 
174 #ifdef MOAB_HAVE_MPI
175  // Create partition set, and populate with elements
176  if( isParallel )
177  {
178  // Write partition tag name on partition set
179  Tag part_tag = myPcomm->partition_tag();
180  int dum_rank = myPcomm->proc_config().proc_rank();
181  // the tmp_set is the file_set
182  rval = mbImpl->tag_set_data( part_tag, &tmp_set, 1, &dum_rank );MB_CHK_SET_ERR( rval, "Trouble writing partition tag name on partition set" );
183  }
184 #endif
185 
187  scdi = NULL;
188 
189  // Close the file
190  success = NCFUNC( close )( fileId );
191  if( success ) MB_SET_ERR( MB_FAILURE, "Trouble closing file" );
192 
193  return MB_SUCCESS;
194 }

References moab::NCHelper::check_existing_mesh(), moab::NCHelper::create_conventional_tags(), moab::NCHelper::create_mesh(), moab::Interface::create_meshset(), dbgOut, dimNames, ErrorCode, fileId, fileName, moab::NCHelper::get_nc_helper(), moab::Interface::globalId_tag(), moab::NCHelper::init_mesh_vals(), isParallel, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, mbImpl, MESHSET_SET, mGlobalIdTag, mpFileIdTag, myHelper, NCFUNC, noMesh, noVars, parse_options(), moab::Interface::query_interface(), read_header(), moab::NCHelper::read_variables(), moab::Interface::release_interface(), scdi, moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), moab::DebugOutput::tprintf(), tStepBase, and moab::NCHelper::update_time_tag_vals().

◆ parse_options()

ErrorCode moab::ReadNC::parse_options ( const FileOptions opts,
std::vector< std::string > &  var_names,
std::vector< int > &  tstep_nums,
std::vector< double > &  tstep_vals 
)
private

Definition at line 196 of file ReadNC.cpp.

200 {
201  int tmpval;
202  if( MB_SUCCESS == opts.get_int_option( "DEBUG_IO", 1, tmpval ) )
203  {
204  dbgOut.set_verbosity( tmpval );
205  dbgOut.set_prefix( "NC " );
206  }
207 
208  ErrorCode rval = opts.get_strs_option( "VARIABLE", var_names );
209  if( MB_TYPE_OUT_OF_RANGE == rval )
210  noVars = true;
211  else
212  noVars = false;
213 
214  opts.get_ints_option( "TIMESTEP", tstep_nums );
215  opts.get_reals_option( "TIMEVAL", tstep_vals );
216 
217  rval = opts.get_null_option( "NOMESH" );
218  if( MB_SUCCESS == rval ) noMesh = true;
219 
220  rval = opts.get_null_option( "SPECTRAL_MESH" );
221  if( MB_SUCCESS == rval ) spectralMesh = true;
222 
223  rval = opts.get_null_option( "NO_MIXED_ELEMENTS" );
224  if( MB_SUCCESS == rval ) noMixedElements = true;
225 
226  rval = opts.get_null_option( "NO_EDGES" );
227  if( MB_SUCCESS == rval ) noEdges = true;
228 
229  rval = opts.get_null_option( "NO_CULLING" ); // used now only for domain nc convention
230  if( MB_SUCCESS == rval ) culling = false;
231 
232  rval = opts.get_null_option( "REPARTITION" ); // used now only for domain nc, to repartition with zoltan
233  if( MB_SUCCESS == rval ) repartition = true;
234 
235  if( 2 <= dbgOut.get_verbosity() )
236  {
237  if( !var_names.empty() )
238  {
239  std::cerr << "Variables requested: ";
240  for( unsigned int i = 0; i < var_names.size(); i++ )
241  std::cerr << var_names[i];
242  std::cerr << std::endl;
243  }
244 
245  if( !tstep_nums.empty() )
246  {
247  std::cerr << "Timesteps requested: ";
248  for( unsigned int i = 0; i < tstep_nums.size(); i++ )
249  std::cerr << tstep_nums[i];
250  std::cerr << std::endl;
251  }
252 
253  if( !tstep_vals.empty() )
254  {
255  std::cerr << "Time vals requested: ";
256  for( unsigned int i = 0; i < tstep_vals.size(); i++ )
257  std::cerr << tstep_vals[i];
258  std::cerr << std::endl;
259  }
260  }
261 
262  rval = opts.get_int_option( "GATHER_SET", 0, gatherSetRank );
263  if( MB_TYPE_OUT_OF_RANGE == rval )
264  {
265  MB_SET_ERR( rval, "Invalid value for GATHER_SET option" );
266  }
267 
268  rval = opts.get_int_option( "TIMESTEPBASE", 0, tStepBase );
269  if( MB_TYPE_OUT_OF_RANGE == rval )
270  {
271  MB_SET_ERR( rval, "Invalid value for TIMESTEPBASE option" );
272  }
273 
274  rval = opts.get_int_option( "TRIVIAL_PARTITION_SHIFT", 1, trivialPartitionShift );
275  if( MB_TYPE_OUT_OF_RANGE == rval )
276  {
277  MB_SET_ERR( rval, "Invalid value for TRIVIAL_PARTITION_SHIFT option" );
278  }
279 
280 #ifdef MOAB_HAVE_MPI
281  isParallel = ( opts.match_option( "PARALLEL", "READ_PART" ) != MB_ENTITY_NOT_FOUND );
282 
283  if( !isParallel )
284  // Return success here, since rval still has _NOT_FOUND from not finding option
285  // in this case, myPcomm will be NULL, so it can never be used; always check for isParallel
286  // before any use for myPcomm
287  return MB_SUCCESS;
288 
289  int pcomm_no = 0;
290  rval = opts.get_int_option( "PARALLEL_COMM", pcomm_no );
291  if( MB_TYPE_OUT_OF_RANGE == rval )
292  {
293  MB_SET_ERR( rval, "Invalid value for PARALLEL_COMM option" );
294  }
295  myPcomm = ParallelComm::get_pcomm( mbImpl, pcomm_no );
296  if( 0 == myPcomm )
297  {
298  myPcomm = new ParallelComm( mbImpl, MPI_COMM_WORLD );
299  }
300  const int rank = myPcomm->proc_config().proc_rank();
301  dbgOut.set_rank( rank );
302 
303  int dum;
304  rval = opts.match_option( "PARTITION_METHOD", ScdParData::PartitionMethodNames, dum );
305  if( MB_FAILURE == rval )
306  {
307  MB_SET_ERR( rval, "Unknown partition method specified" );
308  }
309  else if( MB_ENTITY_NOT_FOUND == rval )
311  else
312  partMethod = dum;
313 #endif
314 
315  return MB_SUCCESS;
316 }

References moab::ScdParData::ALLJORKORI, culling, dbgOut, moab::dum, ErrorCode, gatherSetRank, moab::FileOptions::get_int_option(), moab::FileOptions::get_ints_option(), moab::FileOptions::get_null_option(), moab::ParallelComm::get_pcomm(), moab::FileOptions::get_reals_option(), moab::FileOptions::get_strs_option(), moab::DebugOutput::get_verbosity(), isParallel, moab::FileOptions::match_option(), MB_ENTITY_NOT_FOUND, MB_SET_ERR, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, mbImpl, noEdges, noMesh, noMixedElements, noVars, moab::ScdParData::PartitionMethodNames, partMethod, repartition, moab::DebugOutput::set_prefix(), moab::DebugOutput::set_rank(), moab::DebugOutput::set_verbosity(), spectralMesh, trivialPartitionShift, and tStepBase.

Referenced by load_file().

◆ read_header()

ErrorCode moab::ReadNC::read_header ( )
private

Read the header information.

Definition at line 318 of file ReadNC.cpp.

319 {
320  dbgOut.tprint( 1, "Reading header...\n" );
321 
322  // Get the global attributes
323  int numgatts;
324  int success;
325  success = NCFUNC( inq_natts )( fileId, &numgatts );
326  if( success ) MB_SET_ERR( MB_FAILURE, "Couldn't get number of global attributes" );
327 
328  // Read attributes into globalAtts
329  ErrorCode result = get_attributes( NC_GLOBAL, numgatts, globalAtts );MB_CHK_SET_ERR( result, "Trouble getting global attributes" );
330  dbgOut.tprintf( 1, "Read %u attributes\n", (unsigned int)globalAtts.size() );
331 
332  // Read in dimensions into dimNames and dimLens
333  result = get_dimensions( fileId, dimNames, dimLens );MB_CHK_SET_ERR( result, "Trouble getting dimensions" );
334  dbgOut.tprintf( 1, "Read %u dimensions\n", (unsigned int)dimNames.size() );
335 
336  // Read in variables into varInfo
337  result = get_variables();MB_CHK_SET_ERR( result, "Trouble getting variables" );
338  dbgOut.tprintf( 1, "Read %u variables\n", (unsigned int)varInfo.size() );
339 
340  return MB_SUCCESS;
341 }

References dbgOut, dimLens, dimNames, ErrorCode, fileId, get_attributes(), get_dimensions(), get_variables(), globalAtts, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, NCFUNC, moab::DebugOutput::tprint(), moab::DebugOutput::tprintf(), and varInfo.

Referenced by load_file().

◆ read_tag_values()

ErrorCode moab::ReadNC::read_tag_values ( const char *  file_name,
const char *  tag_name,
const FileOptions opts,
std::vector< int > &  tag_values_out,
const SubsetList subset_list = nullptr 
)
virtual

Read tag values from a file.

Read the list if all integer tag values from the file for a tag that is a single integer value per entity.

Parameters
file_nameThe file to read.
tag_nameThe tag for which to read values
tag_values_outOutput: The list of tag values.
subset_listAn array of tag name and value sets specifying the subset of the file to read. If multiple tags are specified, the sets that match all tags (intersection) should be read.
subset_list_lengthThe length of the 'subset_list' array.

Implements moab::ReaderIface.

Definition at line 458 of file ReadNC.cpp.

463 {
464  return MB_FAILURE;
465 }

Friends And Related Function Documentation

◆ NCHelper

friend class NCHelper
friend

Definition at line 64 of file ReadNC.hpp.

◆ NCHelperDomain

friend class NCHelperDomain
friend

Definition at line 69 of file ReadNC.hpp.

◆ NCHelperESMF

friend class NCHelperESMF
friend

Definition at line 73 of file ReadNC.hpp.

◆ NCHelperEuler

friend class NCHelperEuler
friend

Definition at line 67 of file ReadNC.hpp.

◆ NCHelperFV

friend class NCHelperFV
friend

Definition at line 68 of file ReadNC.hpp.

◆ NCHelperGCRM

friend class NCHelperGCRM
friend

Definition at line 74 of file ReadNC.hpp.

◆ NCHelperHOMME

friend class NCHelperHOMME
friend

Definition at line 71 of file ReadNC.hpp.

◆ NCHelperMPAS

friend class NCHelperMPAS
friend

Definition at line 72 of file ReadNC.hpp.

◆ NCHelperScrip

friend class NCHelperScrip
friend

Definition at line 70 of file ReadNC.hpp.

◆ ScdNCHelper

friend class ScdNCHelper
friend

Definition at line 65 of file ReadNC.hpp.

◆ UcdNCHelper

friend class UcdNCHelper
friend

Definition at line 66 of file ReadNC.hpp.

Member Data Documentation

◆ culling

bool moab::ReadNC::culling
private

Definition at line 236 of file ReadNC.hpp.

Referenced by moab::NCHelperDomain::create_mesh(), and parse_options().

◆ dbgOut

◆ dimLens

◆ dimNames

◆ fileId

int moab::ReadNC::fileId
private

File numbers assigned by netcdf.

Definition at line 187 of file ReadNC.hpp.

Referenced by moab::NCHelperHOMME::create_mesh(), get_attributes(), get_variables(), load_file(), moab::NCHelperHOMME::NCHelperHOMME(), and read_header().

◆ fileName

std::string moab::ReadNC::fileName
private

File name.

Definition at line 184 of file ReadNC.hpp.

Referenced by moab::NCHelperHOMME::create_mesh(), and load_file().

◆ gatherSetRank

int moab::ReadNC::gatherSetRank
private

◆ globalAtts

◆ isParallel

◆ mbImpl

Interface* moab::ReadNC::mbImpl
private

Interface instance.

Definition at line 181 of file ReadNC.hpp.

Referenced by moab::ScdNCHelper::check_existing_mesh(), moab::NCHelperGCRM::check_existing_mesh(), moab::NCHelperHOMME::check_existing_mesh(), moab::NCHelperMPAS::check_existing_mesh(), moab::NCHelper::create_conventional_tags(), moab::NCHelper::create_dummy_variables(), moab::NCHelperMPAS::create_gather_set_cells(), moab::NCHelperGCRM::create_gather_set_edges(), moab::NCHelperMPAS::create_gather_set_edges(), moab::NCHelperGCRM::create_gather_set_vertices(), moab::NCHelperMPAS::create_gather_set_vertices(), moab::NCHelperESMF::create_local_cells(), moab::NCHelperMPAS::create_local_cells(), moab::NCHelperGCRM::create_local_edges(), moab::NCHelperMPAS::create_local_edges(), moab::NCHelperESMF::create_local_vertices(), moab::NCHelperGCRM::create_local_vertices(), moab::NCHelperMPAS::create_local_vertices(), moab::ScdNCHelper::create_mesh(), moab::NCHelperDomain::create_mesh(), moab::NCHelperHOMME::create_mesh(), moab::NCHelperMPAS::create_mesh(), moab::NCHelperScrip::create_mesh(), moab::NCHelperGCRM::create_padded_gather_set_cells(), moab::NCHelperMPAS::create_padded_gather_set_cells(), moab::NCHelperESMF::create_padded_local_cells(), moab::NCHelperGCRM::create_padded_local_cells(), moab::NCHelperMPAS::create_padded_local_cells(), moab::ScdNCHelper::create_quad_coordinate_tag(), moab::NCHelper::get_tag_to_nonset(), moab::NCHelper::get_tag_to_set(), moab::NCHelperDomain::init_mesh_vals(), moab::NCHelperEuler::init_mesh_vals(), moab::NCHelperFV::init_mesh_vals(), moab::NCHelperScrip::init_mesh_vals(), load_file(), parse_options(), moab::ScdNCHelper::read_scd_variables_to_nonset_allocate(), moab::NCHelperMPAS::read_ucd_variables_to_nonset(), moab::NCHelperGCRM::read_ucd_variables_to_nonset_allocate(), moab::NCHelperHOMME::read_ucd_variables_to_nonset_allocate(), moab::NCHelperMPAS::read_ucd_variables_to_nonset_allocate(), moab::NCHelper::read_variables_to_set(), moab::NCHelper::update_time_tag_vals(), and ~ReadNC().

◆ mGlobalIdTag

◆ mpFileIdTag

const Tag* moab::ReadNC::mpFileIdTag
private

This is a pointer to the file id tag that is passed from ReadParallel it gets deleted at the end of resolve sharing, but it will have same data as the global id tag global id tag is preserved, and is needed later on.

Definition at line 209 of file ReadNC.hpp.

Referenced by moab::NCHelperGCRM::create_gather_set_vertices(), moab::NCHelperMPAS::create_gather_set_vertices(), moab::NCHelperESMF::create_local_vertices(), moab::NCHelperGCRM::create_local_vertices(), moab::NCHelperMPAS::create_local_vertices(), moab::ScdNCHelper::create_mesh(), moab::NCHelperHOMME::create_mesh(), and load_file().

◆ myHelper

NCHelper* moab::ReadNC::myHelper
private

Helper class instance.

Definition at line 243 of file ReadNC.hpp.

Referenced by load_file(), and ~ReadNC().

◆ noEdges

◆ noMesh

◆ noMixedElements

bool moab::ReadNC::noMixedElements
private

◆ noVars

bool moab::ReadNC::noVars
private

Definition at line 232 of file ReadNC.hpp.

Referenced by load_file(), and parse_options().

◆ parData

ScdParData moab::ReadNC::parData
private

◆ partMethod

◆ readMeshIface

◆ repartition

bool moab::ReadNC::repartition
private

Definition at line 237 of file ReadNC.hpp.

Referenced by moab::NCHelperDomain::create_mesh(), and parse_options().

◆ scdi

ScdInterface* moab::ReadNC::scdi
private

Scd interface.

Definition at line 221 of file ReadNC.hpp.

Referenced by moab::NCHelper::create_conventional_tags(), moab::ScdNCHelper::create_mesh(), and load_file().

◆ spectralMesh

bool moab::ReadNC::spectralMesh
private

Definition at line 233 of file ReadNC.hpp.

Referenced by moab::NCHelperHOMME::create_mesh(), and parse_options().

◆ trivialPartitionShift

◆ tStepBase

int moab::ReadNC::tStepBase
private

◆ varInfo


The documentation for this class was generated from the following files: