Skip to content

Commit

Permalink
After long vacations
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Aug 5, 2015
1 parent d13e2a5 commit d915fc0
Show file tree
Hide file tree
Showing 56 changed files with 27,243 additions and 8,223 deletions.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
9 changes: 0 additions & 9 deletions include/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ class Base : public IObj
/*! If errCode>0 is provided, the program shall exit with this number.*/
void finally(int errCode=0, std::string s="");

//! Return the time value of record 'rec' out of the nc-file.
static double
getTime(NcAPI &, size_t rec, std::string, double offset=0.);

//! Put all the time values of record 'rec' to the Matval obj.
/*! This method gives access to time bound values.*/
static bool
getTime(NcAPI &, size_t rec, std::string, MtrxArr<double>&, double offset=0.);

//! Get the name of the variable indicated by 'varname=...', 'vname=...', 'variable=...', or 'v=...'
std::vector<std::string>
getVarname( std::string &s);
Expand Down
30 changes: 3 additions & 27 deletions include/cf.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,6 @@ class CF : public IObj
void applyOptions(void);
void attributeSpellCheck(void);

std::string
captAtt(std::string a);
std::string
captAtt(std::string v, std::string a);
std::string
captAtt(std::string v, std::string a, std::string&);
std::string
captAtt(std::string v, std::string a, std::string&, std::string&);
std::string
captAtt(std::string v, std::string a,
std::string&, std::string&, std::string&);
std::string
captAtt(std::string& v, std::string& a, bool colon, bool blank, bool isUpper);

std::string
captVal(std::string v, bool trailingBlank=true);

std::string
captVar(std::string v, bool is_colon=true, bool is_blank=true);
std::string
captVar(std::string v, std::string&);
std::string
captVar(std::string v, std::string&, std::string&);

void checkCoordinateValues(Variable&, bool isFormTermAux=false) ;
template <typename T>
void checkCoordinateValues(Variable&, bool, T);
Expand Down Expand Up @@ -251,8 +227,8 @@ template <typename T>
std::string tablePath;

std::string timeName; // the name of the unlimited/time variable
int timeIx;
int compressIx;
int time_ix;
int compress_ix;

// a few names of attributes used throughout the checks
std::string n_ancillary_variables;
Expand Down Expand Up @@ -300,7 +276,7 @@ template <typename T>

std::string blank;
std::string no_blank;
std::string no_colon;
std::string s_colon;
std::string s_empty;
std::string s_upper;
std::string s_lower;
Expand Down
6 changes: 4 additions & 2 deletions include/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ class Date

//! Get the julian date.
long double
getJulianDay(void) const { return jul.getJulianDay() ;}
getJulianDay(long double add=0.) const
{ return jul.getJulianDay() + add ;}
long double
getJulianDate(void) const { return jul.getJulianDay() ;}
getJulianDate(long double add=0.) const
{ return jul.getJulianDay() + add ;}

//! Get double representation of the integer minute.
double getMinute( void );
Expand Down
39 changes: 39 additions & 0 deletions include/hdhC.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ struct FieldDataMeta
size_t size;
};

struct FileComponent
{
bool is;
std::string file;
std::string filename;
std::string basename;
std::string extension;
std::string path;
};

//! Struct defining a point coordinate
struct Point
{
Expand Down Expand Up @@ -249,6 +259,9 @@ uint32_t
fletcher32_LE_clear( T *data, size_t sz, bool *reset, size_t clear=0);

//! Extract path, discard the filename.
struct FileComponent
splitFile(std::string&) ;

std::string
getPath(std::string&, bool isWithSlash=false );

Expand Down Expand Up @@ -398,6 +411,32 @@ double
string2Double( std::string s, size_t nr ,int *restIndex,
bool isRetNull=false) ;

//! formatting of attribute|variable name in combination with value etc.
static std::string s_blank(" ");
static std::string no_blank("no_blank");
static std::string s_colon(":");
static std::string no_colon("no_colon");
static std::string s_upper("upper");
static std::string s_empty("");
static std::string s_void("void_bool");

std::string
tf_att(std::string v=s_void, std::string a=s_void, std::string val=s_void,
std::string b1=s_void, std::string b2=s_void, std::string b3=s_void);

std::string
tf_att(std::vector<std::string*>& vs, bool colon, bool blank, bool isUpper);

std::string
tf_val(std::string v, std::string blnk="");

std::string
tf_var(std::string v,
std::string b1=s_void, std::string b2=s_void, std::string b3=s_void);

std::string
tf_var(std::string& v, bool colon, bool blank, bool isUpper);

//! Remove all characters from a str.
/*! By default, each character in 's' is removed. If isStr==true, then only
every occurrence of the string 's'.*/
Expand Down
4 changes: 2 additions & 2 deletions include/in_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InFile : public Base

//! Default constructor
InFile() ;
~InFile(){;}
~InFile(){nc.close();}

//! coresponding to virtual methods in IObj
bool entry(void);
Expand Down Expand Up @@ -58,7 +58,7 @@ class InFile : public Base
/*! If no unlimited variable is defined but time is provided, then
try for all variables, not depending on time.*/
std::vector<std::string>
getLimitedVarNames(void);
getLimitedVarName(void);

//! Get the number of records.
/*! If there is no unlimited variable, but time is defined, then
Expand Down
87 changes: 52 additions & 35 deletions include/matrix_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,25 +418,27 @@ ValueException<T>::testValueModesFull(T* arr, size_t arr_sz,

// portions of arr are mapped
size_t chunk=1024;
size_t stateArrSz= (arr_sz > chunk) ? chunk : arr_sz ;
bool *isInfNaN = new bool [stateArrSz];
if( chunk > arr_sz )
chunk = arr_sz;

size_t in_count=0;
bool *isInfNaN = new bool [chunk];

size_t nextStop=0;
size_t i=0 ; //arr index

size_t evSz=exceptionValue.size();

bool isLeg=false; // legs of valid data

while ( in_count < arr_sz )
while ( nextStop < arr_sz )
{
in_count += stateArrSz;
nextStop += chunk;

bool isAnyInvalid = testInfNaN(isInfNaN, stateArrSz, i, arr, arr_sz) ;
bool isAnyInvalid = testInfNaN(isInfNaN, chunk, i, arr, arr_sz) ;

for( ; i < arr_sz ; ++i)
{
if( i == stateArrSz )
if( i == nextStop )
break;

// test Inf and NaN block-wise; return true for any
Expand All @@ -449,10 +451,10 @@ ValueException<T>::testValueModesFull(T* arr, size_t arr_sz,
isLeg=false;
}

while( i < in_count && isInfNaN[i] )
while( i < nextStop && isInfNaN[i] )
++i;

if( i == in_count )
if( i == nextStop )
break; // no data point found in the entire block, try next

if(!isLeg)
Expand Down Expand Up @@ -547,23 +549,25 @@ ValueException<T>::testValueModesPoint(T* arr, size_t arr_sz,

// portions of arr are mapped
size_t chunk=1024;
size_t stateArrSz= (arr_sz > chunk) ? chunk : arr_sz ;
bool *isInfNaN = new bool [stateArrSz];
if( chunk > arr_sz )
chunk = arr_sz;

bool *isInfNaN = new bool [chunk];

size_t in_count=0;
size_t nextStop=0;
size_t i=0 ; //arr index

bool isLeg=false; // legs of valid data

while ( in_count < arr_sz )
while ( nextStop < arr_sz )
{
in_count += stateArrSz;
nextStop += chunk;

bool isAnyInvalid = testInfNaN(isInfNaN, stateArrSz, i, arr, arr_sz) ;
bool isAnyInvalid = testInfNaN(isInfNaN, chunk, i, arr, arr_sz) ;

for( ; i < arr_sz ; ++i)
{
if( i == stateArrSz )
if( i == nextStop )
break;

// test Inf and NaN block-wise; return true for any
Expand All @@ -576,10 +580,10 @@ ValueException<T>::testValueModesPoint(T* arr, size_t arr_sz,
isLeg=false;
}

while( i < in_count && isInfNaN[i] )
while( i < nextStop && isInfNaN[i] )
++i;

if( i == in_count )
if( i == nextStop )
break; // no data point found in the entire block, try next

if(!isLeg)
Expand Down Expand Up @@ -634,10 +638,12 @@ ValueException<T>::testValueModesPoints(T* arr, size_t arr_sz,

// portions of arr are mapped
size_t chunk=1024;
size_t stateArrSz= (arr_sz > chunk) ? chunk : arr_sz ;
bool *isInfNaN = new bool [stateArrSz];
if( chunk > arr_sz )
chunk = arr_sz;

size_t in_count=0;
bool *isInfNaN = new bool [chunk];

size_t nextStop=0;
size_t i=0 ; //arr index

size_t evSz=exceptionValue.size();
Expand All @@ -646,13 +652,13 @@ ValueException<T>::testValueModesPoints(T* arr, size_t arr_sz,

while ( i < arr_sz )
{
in_count += stateArrSz;
nextStop += chunk;

bool isAnyInvalid = testInfNaN(isInfNaN, stateArrSz, i, arr, arr_sz) ;
bool isAnyInvalid = testInfNaN(isInfNaN, chunk, i, arr, arr_sz) ;

for( ; i < arr_sz ; ++i)
{
if( i == stateArrSz )
if( i == nextStop )
break;

// test Inf and NaN block-wise; return true for any
Expand All @@ -665,10 +671,10 @@ ValueException<T>::testValueModesPoints(T* arr, size_t arr_sz,
isLeg=false;
}

while( i < in_count && isInfNaN[i] )
while( i < nextStop && isInfNaN[i] )
++i;

if( i == in_count )
if( i == nextStop )
break; // no data point found in the entire block, try next

if(!isLeg)
Expand Down Expand Up @@ -758,6 +764,7 @@ class MArep
size_t arr_sz;

T** m2D; //matrix access; initialised at 1st call
size_t m2D_dim0;

private: // prevent copying
MArep(const MArep&);
Expand All @@ -770,6 +777,8 @@ MArep<T>::MArep(const T* p, std::vector<size_t> &d )
{
// constructor with assignment for p>0
m2D=0;
m2D_dim0=0;

counter=1;
getDim(d);
arr=0 ;
Expand Down Expand Up @@ -837,11 +846,12 @@ template<typename T>
void
MArep<T>::clearM(void)
{
if ( static_cast<bool>(m2D) )
if( static_cast<bool>(m2D) )
{
delete [] m2D;
m2D=0;
}
m2D_dim0=0;
}

return;
}
Expand Down Expand Up @@ -988,15 +998,21 @@ template<typename T>
void
MArep<T>::setM(void)
{
if( m2D > 0 )
return;

// m2D is freed at a different location
if( m2D && m2D_dim0 != dim[0] )
{
delete [] m2D;
m2D=0;
m2D_dim0=0;
}

// allocate new mem for the 2D shape
if( dim.size() == 2 )
{ // m x n matrix
m2D = new T* [dim[0]];
if( m2D == 0 )
{
m2D = new T* [dim[0]];
m2D_dim0=dim[0];
}

for(size_t i0=0; i0 < dim[0]; ++i0)
m2D[i0] = arr + i0 * dim[1] ;
Expand Down Expand Up @@ -1174,7 +1190,8 @@ class MtrxArr : public MtrxArrB

std::vector<size_t>
getDimensions(void)const { return rep->dim;}

size_t getDimSize(){ return rep->dim.size(); }

size_t getExceptionCount(size_t i);
size_t getExceptionCount(std::string s="all");

Expand Down Expand Up @@ -1254,7 +1271,7 @@ class MtrxArr : public MtrxArrB
{ valExcp->testValueException(rep->arr, rep->arr_sz,
validRangeBegin, validRangeEnd); }

T *arr ; // points to &rep->(*pva)[0]
T* arr ; // points to &rep->(*pva)[0]
T zero ; // nomen est omen

// combine to index ranges of valid values
Expand Down

0 comments on commit d915fc0

Please sign in to comment.