Adding extra wrappers for functions in ncFile and ncVar

This commit is contained in:
Aodhan Sweeney 2019-07-02 13:36:44 -06:00
parent c117727931
commit 475b8d9c5b
7 changed files with 98 additions and 26 deletions

View File

@ -167,12 +167,19 @@ void NcFile::open(const string& filePath, const FileMode fMode, const FileFormat
void NcFile::sync(){
ncCheck(nc_sync(myId),__FILE__,__LINE__);
}
//Aodhan adding fill functionality
void NcFile::set_Fill(int fillmode, int *old_modep){
cout<<"\n+++++++++++++++++++++ \n inside set_Fill() \n+++++++++++++++++++++\n";
ncCheck(nc_set_fill(myId, fillmode, old_modep),__FILE__,__LINE__);
cout<<"completed nc Check for set_Fill()";
}
// Aodhan adding a redef() function
void NcFile::redef(){
cout<<"\n+++++++++++++++++++++ \n inside redef() \n+++++++++++++++++++++\n";
ncCheck(nc_redef(myId),__FILE__,__LINE__);
cout<<"completed nc Check";
cout<<"completed nc Check for redef()";
}
// Leave define mode, used for classic model

View File

@ -111,6 +111,9 @@ namespace netCDF
//! Synchronize an open netcdf dataset to disk
void sync();
//! Aodhan adding setFill
void set_Fill(int fillmode, int *old_modep);
//! Aodhan adding in the redef function declaration
void redef();

View File

@ -632,25 +632,67 @@ void NcVar::getCompressionParameters(bool& shuffleFilterEnabled, bool& deflateFi
////////////////////
//set filter details
void NcVar::setFilter( unsigned int id, size_t nparams,
const unsigned int* parms) const
{
cout<<"BZIP2_ID: " << id <<"\nBZIP2_NPARAMS: "<< nparams << "\n&level: "<< parms;
cout<<"\nBZIP2_ID: " << id <<"\nBZIP2_NPARAMS: "<< nparams << "\n&level: "<< parms;
cout<<"\ngoupID: "<< groupId <<"\nmyId"<< myId <<"\nnparams"<< nparams << "\nparms" <<parms;
ncCheck(nc_def_var_filter(groupId,myId,id,nparams,parms),__FILE__,__LINE__);
cout<< "filtering completed"<<endl;
cout<< "\n setFilter filtering completed"<<endl;
//above is returning error because of definition outside of enddef
//To fix we will be adding enddef() wrapper to ncFile and trying again
}
//retrieve filter details
void NcVar::getFilter( unsigned int* idp, size_t* nparamsp, unsigned int* params) const
{
cout<<"\n++++++++++++\n inside getFilter() \n++++++++++++\n";
cout<<"\nidp: " << idp << "\n nparamsp: " << nparamsp << "\n params: " << params;
ncCheck(nc_inq_var_filter(groupId, myId, idp, nparamsp, params),__FILE__,__LINE__);
cout<<"\n++++++++++++\n getFilter() completed \n++++++++++++\n";
}
void NcVar::getTypeLen(nc_type type) const
{
ncCheck(nctypelen(type),__FILE__,__LINE__);
}
void NcVar::freeString(size_t len, char **data) const
{
ncCheck(nc_free_string(len, data),__FILE__,__LINE__);
}
void NcVar::setChunkCache(size_t size, size_t nelems, float preemption) const
{
ncCheck(nc_set_var_chunk_cache(groupId, myId, size, nelems, preemption),__FILE__,__LINE__);
}
/*void NcVar::getShape(int ndims, size_t* shape) const
{
ncCheck(NC_getshape(groupId, myId, ndims, shape),__FILE__,__LINE__);
}*/
/*
//NOT CURRENTLY Working
//query whether a variable has a record dimension
void NcVar::is_recvar(size_t* nrecs)
{
ncCheck(NC_is_recvar(groupId, myId, nrecs),__FILE__,__LINE__);
}*/
/*
//retrieve the actual number of record dimensions for a variable
void NcVar::inq_recvar(int* nrecdimsp, int* is_recdim) const
{
ncCheck(NC_inq_recvar(groupId, myId, nrecdimsp, is_recdim),__FILE__,__LINE__);
}
*/
////////////////////
//End of Aodhan adding stuff
////////////////////
////////////////////
// Endianness details

View File

@ -113,8 +113,20 @@ namespace netCDF
void getFilter(unsigned int* idp, size_t* nparamsp, unsigned int* params) const;
//Now returning to the stuff that was here before
void getTypeLen(nc_type type) const;
void freeString(size_t len, char **data) const;
void setChunkCache(size_t size, size_t nelems, float preemption) const;
//void getShape(int ndims, size_t* shape) const;
//void is_recvar(size_t* nrecs);
//void inq_recvar(int* nrecdimsp, int* is_recdim) const;
//Now returning to the stuff that was here before
/*! Get the variable id. */

View File

@ -8,13 +8,13 @@ using namespace std;
namespace netCDF {
// Global comparator operator ==============
// comparator operator
// comparator operator
bool operator<(const NcVarAtt& lhs,const NcVarAtt& rhs)
{
return false;
}
// comparator operator
// comparator operator
bool operator>(const NcVarAtt& lhs,const NcVarAtt& rhs)
{
return true;
@ -33,7 +33,7 @@ NcVarAtt& NcVarAtt::operator=(const NcVarAtt & rhs)
}
//! The copy constructor.
NcVarAtt::NcVarAtt(const NcVarAtt& rhs):
NcVarAtt::NcVarAtt(const NcVarAtt& rhs):
NcAtt(rhs) // invoke base class copy constructor
{}
@ -57,6 +57,16 @@ NcVarAtt::NcVarAtt(const NcGroup& grp, const NcVar& ncVar, const int index):
myName = attName;
}
//Aodhan Entry
//Finds the type of an attribute.
void NcVarAtt::inq_atttype(const char *name, nc_type *xtypep) const
{
ncCheck(nc_inq_atttype(groupId, varId, name, xtypep),__FILE__,__LINE__);
}
// Returns the NcVar parent object.
NcVar NcVarAtt::getParentVar() const {
return NcVar(groupId,varId);

View File

@ -13,35 +13,38 @@ namespace netCDF
class NcVarAtt : public NcAtt
{
public:
/*! assignment operator */
NcVarAtt& operator= (const NcVarAtt& rhs);
/*! Constructor generates a \ref isNull "null object". */
NcVarAtt ();
void inq_atttype(const char *name, nc_type *xtypep) const;
/*! The copy constructor. */
NcVarAtt(const NcVarAtt& rhs) ;
/*!
/*!
Constructor for an existing local attribute.
\param grp Parent Group object.
\param NcVar Parent NcVar object.
\param index The index (id) of the attribute.
*/
NcVarAtt(const NcGroup& grp, const NcVar& ncVar, const int index);
/*! Returns the NcVar parent object. */
NcVar getParentVar() const;
/*! comparator operator */
friend bool operator<(const NcVarAtt& lhs,const NcVarAtt& rhs);
/*! comparator operator */
friend bool operator>(const NcVarAtt& lhs,const NcVarAtt& rhs);
};
}
#endif

View File

@ -145,21 +145,16 @@ int main()
//Testing the filter ability in a write function
cout<<"hey \n";
cout<<"BZIP2_ID: " << BZIP2_ID <<"BZIP2_NPARAMS: "<< BZIP2_NPARAMS << " &level: "<< &level;
latVar.setFilter(BZIP2_ID,BZIP2_NPARAMS,&level);
latVar.putVar(lats);
cout<<"hey2"; //this one doesnt show up, something is happening in setFilter
cout<<"idp* " << &idp;
latVar.getFilter(&idp,&nparamsp, &level);
<<<<<<< HEAD
=======
//<<<<<<< HEAD
//=======
latVar.putVar(lats);
lonVar.putVar(lons);
>>>>>>> e404ec174e8de27e10b846a6122e84d975de3c77
//>>>>>>> e404ec174e8de27e10b846a6122e84d975de3c77
// Write the pretend data. This will write our surface pressure and
// surface temperature data. The arrays only hold one timestep