Skip to content

Commit

Permalink
CORDEX: cut of dates in filename's period
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Jan 12, 2016
1 parent b220805 commit 7b6e343
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
14 changes: 8 additions & 6 deletions include/readline.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ class ReadLine
size_t
size(void){ return split.size(); }

//! Discard Bash comments.
/*! From the first appearance to the end of the line.*/
void
skipBashComment( void ){ isSkipBashComment=true; }

//! Discard characters.
/*! From the first appearance to the end of the line.*/
void
Expand All @@ -228,6 +223,11 @@ class ReadLine
void
skipCharacter(std::string);

//! Discard comments indicated by character [default: #].
/*! From the first appearance to the end of the line.*/
void
skipComment(char c='#');

//! Skip the first int lines.
bool
skipLines( int ); // skip the first int lines
Expand All @@ -254,6 +254,8 @@ class ReadLine
std::string inFile ;
std::string line ;
std::string prevLine ;

char commentChar; // default #
char lineContinuation;
std::vector<char> vSkipChars;
std::vector<double> val ; //line: converted values
Expand All @@ -269,7 +271,7 @@ class ReadLine
bool isExternalStream;
bool isPutBackLine;
bool isReadFloat ;
bool isSkipBashComment;
bool isSkipComment;
bool isSkipCharacter;
bool isSkipWhiteLine;
bool isSwappedEof;
Expand Down
8 changes: 4 additions & 4 deletions src/QA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ QA::init(void)
pIn->excludeVars();

qaTime.init(optStr);

// DRS and CV specifications
drs_cv_table.read(table_DRS_CV);

Expand Down Expand Up @@ -1250,7 +1250,7 @@ DRS_CV_Table::read(hdhC::FileSplit& fs)
if( ! ifs.isOpen() )
{
std::string key("7_1");
if( pQA->notes->inq( key, pQA->fileStr) )
if( pQA->notes->inq( key) )
{
std::string capt("no path to a table, tried " + fs.getFile()) ;

Expand All @@ -1269,7 +1269,7 @@ DRS_CV_Table::read(hdhC::FileSplit& fs)

// parse table; trailing ':' indicates variable or 'global'
ifs.skipWhiteLines();
ifs.skipBashComment();
ifs.skipComment();
ifs.skipCharacter("<>");
ifs.clearSurroundingSpaces();

Expand Down Expand Up @@ -1380,7 +1380,7 @@ DRS_CV_Table::read(hdhC::FileSplit& fs)
if( attName.size() == 0 )
{
std::string key("7_2");
if( notes->inq( key, pQA->fileStr) )
if( notes->inq( key) )
{
std::string capt(
"Syntax fault in the DRS_CV table: orphaned attribute, found ");
Expand Down
14 changes: 9 additions & 5 deletions src/QA_CORDEX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ DRS_CV::checkModelName(std::string &aName, std::string &aValue,

// parse table; trailing ':' indicates variable or 'global'
ifs.skipWhiteLines();
ifs.skipBashComment();
ifs.skipComment();

bool isModel=false;
bool isInst=false;
Expand Down Expand Up @@ -1226,7 +1226,7 @@ DRS_CV::testPeriodCutRegular(std::vector<std::string> &sd,
if( ! (sd[0][3] == '1' || sd[0][3] == '6') )
text.push_back(": StartTime should begin with YYY1 or YYY6");

if( sd[0].substr(4,4) != "0101" )
if( sd[0].substr(4,4) != "0101" )
text.push_back(": StartTime should be YYYY0101");
}

Expand All @@ -1235,8 +1235,10 @@ DRS_CV::testPeriodCutRegular(std::vector<std::string> &sd,
if( ! (sd[1][3] == '0' || sd[1][3] == '5') )
text.push_back(": EndTime should begin with YYY0 or YYY5");

if( sd[1].substr(4,4) != "1231" )
text.push_back(": EndTime should be YYYY1231");
std::string numDec(hdhC::double2String(
pQA->qaTime.refDate.regularMonthDays[11]));
if( sd[1].substr(4,4) != "12"+numDec )
text.push_back(": EndTime should be YYYY12"+numDec);
}
}
else if( frequency == "mon" )
Expand Down Expand Up @@ -1264,8 +1266,10 @@ DRS_CV::testPeriodCutRegular(std::vector<std::string> &sd,
if( ! (sd[1][3] == '0' || sd[1][3] == '5') )
text.push_back(": EndTime should begin with YYY0");

std::string numDec(hdhC::double2String(
pQA->qaTime.refDate.regularMonthDays[11]));
if( sd[1].substr(4,4) != "12" )
text.push_back(": EndTime should be YYYY1231");
text.push_back(": EndTime should be YYYY12"+numDec);
}
}
else if( frequency == "sem" )
Expand Down
21 changes: 15 additions & 6 deletions src/ReadLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ ReadLine::init()
isClearSurroundingSpaces = false;
isEof=false;
isPutBackLine=false;
isSkipBashComment = false;
isSkipComment = false;
isSkipCharacter=false;
isSkipWhiteLine = false;
isRange = false ;
isReadFloat=false;
is_fopen=false;

lineContinuation='\\';
commentChar='#';

stream=0;
}
Expand Down Expand Up @@ -334,18 +335,18 @@ ReadLine::readLine(bool isVoid)

prevLine = line;
line.erase();

bool skip=false;
bool isSkip;

// variable number of columns
while( !(isEof = stream->eof()) )
{
cbuf = stream->get();

// skip fom #-char to the end of tzhe line
if( isSkipBashComment && cbuf == '#' )
skip=true;
if( skip )
if( isSkipComment && cbuf == commentChar )
isSkip=true;

if(isSkip)
{
if(cbuf == '\n' || cbuf == '\r')
{
Expand Down Expand Up @@ -513,6 +514,14 @@ ReadLine::skipCharacter(std::string s)
return;
}

void
ReadLine::skipComment(char c)
{
commentChar=c;
isSkipComment=true;
return;
}

bool
ReadLine::skipLines( int count )
{
Expand Down

0 comments on commit 7b6e343

Please sign in to comment.