Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
paullric committed Mar 11, 2021
2 parents 6eb9219 + 0be3f6e commit 31e51ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/netcdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ static const int ncGlobal = NC_GLOBAL;
// failure return for netCDF C interface
static const int ncBad = -1;

NcFile::NcFile()
{
the_id = -1;
the_fill_mode = Fill;
dimensions = 0;
variables = 0;
globalv = 0;
}

NcFile::~NcFile( void ) {
(void) close();
}
Expand Down
19 changes: 12 additions & 7 deletions src/netcdfcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class NcFile {
int id( void ) const; // id used by C interface

protected:
/* Let the derived class handle initializing all necessary data */
NcFile();

int the_id;
int in_define_mode;
FillMode the_fill_mode;
Expand Down Expand Up @@ -158,6 +161,7 @@ class NcDim {
int the_id;
char *the_name;

public:
NcDim(NcFile*, int num); // existing dimension
NcDim(NcFile*, NcToken name, long sz); // defines a new dim
virtual ~NcDim( void );
Expand Down Expand Up @@ -412,21 +416,22 @@ class NcVar : public NcTypedComponent {
int id( void ) const; // rarely needed, C interface id
NcBool sync( void );

private:
protected:
int dim_to_index(NcDim* rdim);
int the_id;
long* the_cur;
char* the_name;
long* cur_rec;

// private constructors because only an NcFile creates these
NcVar( void );
NcVar(NcFile*, int);

int attnum( NcToken attname ) const;
NcToken attname( int attnum ) const;
void init_cur( void );

public:
// Only an NcFile or derivatives create these with a valid handle
NcVar( void );
NcVar(NcFile*, int);

// to make variables, since constructor is private
friend class NcFile;
};
Expand All @@ -451,8 +456,8 @@ class NcAtt : public NcTypedComponent {
const NcVar* the_variable;
char* the_name;

// protected constructors because only NcVars and NcFiles create
// attributes
public:
// Only NcVars and NcFiles with a valid handle create attributes
NcAtt( NcFile*, const NcVar*, NcToken);
NcAtt( NcFile*, NcToken); // global attribute

Expand Down

0 comments on commit 31e51ff

Please sign in to comment.