Skip to content

Commit

Permalink
interim
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Aug 10, 2015
1 parent f5ccd62 commit a9ab8ab
Show file tree
Hide file tree
Showing 14 changed files with 5,213 additions and 4,771 deletions.
34 changes: 12 additions & 22 deletions src/Annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ Annotation::parse(void)
continue;
}

if( str0 == "ST" )
if( str0 == "VR" )
{
isST=true;
continue;
Expand Down Expand Up @@ -850,7 +850,7 @@ Annotation::parse(void)
if( isPT )
table.push_back("PT") ;
else if( isST )
table.push_back("ST") ;
table.push_back("VR") ;
else
table.push_back("*") ;

Expand Down Expand Up @@ -960,8 +960,8 @@ Annotation::printFlags(void)

if( isOutputPASS )
{
out += "path: " + path;
out += "\nfile: " + filename;
out += "path: " + filenameItems.path;
out += "\nfile: " + filenameItems.filename;
if( mp.begin() == mp.end() )
{
out += ":\tPASS\n" ;
Expand Down Expand Up @@ -1063,9 +1063,9 @@ Annotation::printHeader(std::ofstream *ofs)
// std::string str( where ) ;
std::string str;
str +="\nPath: " ;
str += path ;
str += filenameItems.path ;
str += "\nFile: " ;
str += filename;
str += filenameItems.filename;

*ofs << str << std::endl ;

Expand All @@ -1082,16 +1082,14 @@ Annotation::printNotes(std::string &tag, std::string &caption,
// But, the calling program unit is due to exit.
if( ofsNotes == 0 )
{
if( path.size() == 0 )
path = "undefined_path" ;
if( filename.size() == 0 )
filename = "undefined_filename" ;
if( filenameItems.path.size() == 0 )
filenameItems.path = "undefined_path" ;
if( filenameItems.filename.size() == 0 )
filenameItems.filename = "undefined_filename" ;

// compose the header of issued messages
std::string strNotes = "qa_note_" ;
size_t pos = filename.rfind( ".nc" );
strNotes += filename.substr(0, pos) ;
strNotes += ".txt";
strNotes += filenameItems.filename + ".txt";

// open file for writing
if( ! ofsNotes )
Expand Down Expand Up @@ -1330,15 +1328,7 @@ Annotation::setConfVector(std::string txt, std::string str0)
void
Annotation::setFilename(std::string f)
{
size_t pos;
if( (pos = f.rfind('/')) < std::string::npos )
{
path = f.substr(0,pos) ;
filename = f.substr(pos+1) ;
}
else
filename = f; // path is served separately

filenameItems = hdhC::setFilename(f);
return;
}

Expand Down
17 changes: 12 additions & 5 deletions src/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Base::copy(const Base &b)
{
objName = b.objName;
thisID=b.thisID;
filename=b.filename;
filenameItems=b.filenameItems;

srcStr.clear();
for( size_t i=0 ; i < b.srcStr.size() ; ++i)
Expand Down Expand Up @@ -231,10 +231,10 @@ Base::exceptionError(std::string str)
xcptn.strError += "_error" ;

// base-name if available, i.e. after initialisation of the InFile obj
if( filename.size() > 0 )
if( filenameItems.is )
{
xcptn.strError += "_";
xcptn.strError += hdhC::getBasename(filename) ;
xcptn.strError += filenameItems.basename ;
}
xcptn.strError += ".txt";

Expand Down Expand Up @@ -265,10 +265,10 @@ Base::exceptionWarning(std::string str)
xcptn.strWarning = getObjName() ;
xcptn.strWarning += "_warning" ;

if( filename.size() > 0 )
if( filenameItems.is )
{
xcptn.strWarning += "_";
xcptn.strWarning += hdhC::getBasename(filename) ;
xcptn.strWarning += filenameItems.basename ;
}
xcptn.strWarning += ".txt";

Expand Down Expand Up @@ -495,6 +495,13 @@ Base::makeVariable (NcAPI *pnc, std::string name, int id)
return;
}

void
Base::setFilename(std::string f)
{
filenameItems = hdhC::setFilename(f);
return;
}

void
Base::setSrcVariable(Variable &var, Base *p)
{
Expand Down
9 changes: 8 additions & 1 deletion src/CF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2959,6 +2959,13 @@ CF::setCheck(std::string &s)
return;
}

void
CF::setFilename(std::string f)
{
filenameItems = hdhC::setFilename(f);
return;
}

bool
CF::timeUnitsFormat(Variable& var, bool isAnnot)
{
Expand Down Expand Up @@ -3600,7 +3607,7 @@ CF::chap2_1(void)
return;

// filename extension
if( pIn->filename.substr( pIn->filename.size() - 3) != ".nc" )
if( pIn->filenameItems.extension != ".nc" )
{
if( notes->inq(bKey + "21a") )
{
Expand Down
41 changes: 23 additions & 18 deletions src/FD_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ FD_interface::applyOptions(void)
if( split[0][0] == 's' || split[0][0] == 'S' )
{
isSaveBuild=true;
filename=split[1];
setFilename( split[1] );
continue;
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ FD_interface::applyOptions(void)
if( rebuildFilename.size() && ! isSaveBuild )
{
isSaveBuild=true;
filename=rebuildFilename.substr(0,rebuildFilename.size()-6);
setFilename(rebuildFilename.substr(0,rebuildFilename.size()-6));
}

return;
Expand Down Expand Up @@ -207,10 +207,10 @@ FD_interface::exceptionError(std::string str)
xcptn.strError = "fd_error" ;

// base name if available, i.e. after the initialisation of the InFile obj
if( filename.size() > 0 )
if( filenameItems.is )
{
xcptn.strError += "_";
xcptn.strError += hdhC::getBasename(filename) ;
xcptn.strError += filenameItems.basename ;
}
xcptn.strError += ".txt";

Expand Down Expand Up @@ -238,10 +238,10 @@ FD_interface::exceptionWarning(std::string str)

xcptn.strWarning = "fd_warning" ;

if( filename.size() > 0 )
if( filenameItems.is )
{
xcptn.strWarning += "_";
xcptn.strWarning += hdhC::getBasename(filename) ;
xcptn.strWarning += filenameItems.basename ;
}
xcptn.strWarning += ".txt";

Expand Down Expand Up @@ -380,23 +380,20 @@ FD_interface::init(void)
// varnames in a request (or by default) and using stdout
// will result in a mess, because several obj write to stdout.

vName = pIn->variable[0].name ;
if( filenameItems.is )
setFilename( filenameItems.file + "." + pIn->variable[0].name ) ;
// pGM = pIn->variable[0].pGM;

std::string str(".");
str += vName;

if( filename.size() > 0 )
if( filename.find(vName) == std::string::npos )
filename += str;
std::string str;

// A freqDist for the total domain (by default) or
// any specified number of regions.
// Index == 0 indicates the total domain.
for( size_t i=0 ; i <= regioStr.size() ; ++i)
{
fD.push_back( FreqDist<float>() );
fD.back().setOutputFilename( filename) ;
fD.back().setOutputFilename( filenameItems.filename) ;
if( isReadProperties )
fD.back().setReadOnlyProperties();
}
Expand Down Expand Up @@ -458,7 +455,7 @@ FD_interface::init(void)
for(size_t i=0 ; i < fD.size() ; ++i)
{
str = "#FILE=" ;
str += pIn->filename;
str += pIn->filenameItems.filename;
fD[i].setInfo(str);

str ="#VARIABLE=";
Expand Down Expand Up @@ -545,7 +542,7 @@ FD_interface::initTimeWindow(void)
beginDateStr = beginDate.getDate();
endDateStr = endDate.getDate() ;

str = hdhC::getBasename( filename);
str = filenameItems.basename;
str = str.substr(3); // ignore leading three; no extension.

// ++++++ Looking for a file +++++++++++++++++++++++
Expand Down Expand Up @@ -637,7 +634,7 @@ FD_interface::initTimeWindow(void)

// compose output filename; use only integer years
// ranging from year A inclusively and year B exclusively.
str = hdhC::getBasename( filename);
str = filenameItems.basename;
str += "_" ;

str += beginDateStr.substr(0,4);
Expand Down Expand Up @@ -716,8 +713,8 @@ FD_interface::print(std::string fromDate,

std::string str;

if( filename.size() > 0 )
str=filename;
if( filenameItems.is )
str=filenameItems.filename;
else
str="frequencyDist." + vName;

Expand Down Expand Up @@ -817,3 +814,11 @@ FD_interface::rebuild( std::string f)

return false; // no rebuild
}

void
FD_interface::setFilename(std::string f)
{
filenameItems = hdhC::setFilename(f);
return;
}

42 changes: 9 additions & 33 deletions src/InFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,7 @@ InFile::excludeVars(void)
std::string
InFile::getAbsoluteFilename(void)
{
std::string s;
if( path.size() > 0 )
s = path + "/" ;
if( filename.size() > 0 )
s += filename;

return s;
return filenameItems.file ;
}

void
Expand Down Expand Up @@ -448,7 +442,10 @@ InFile::getVariable(void)
ds = nc.getDimName( var.name );

for( size_t j=0 ; j < ds.size() ; ++j)
{
var.dimName.push_back( ds[j] );
var.dim_ix.push_back(j);
}

// get meta data of variables.
getVariableMeta(var);
Expand Down Expand Up @@ -556,7 +553,7 @@ InFile::init(void)
isTime=false;

if( notes )
notes->setFilename(filename);
notes->setFilename(filenameItems.filename);

if( openNc() )
{
Expand Down Expand Up @@ -588,7 +585,7 @@ InFile::init(void)
{
std::ostringstream ostr(std::ios::app);
ostr << "InFile::init()\n";
ostr << "Could not open NetCDF file " << filename;
ostr << "Could not open NetCDF file " << filenameItems.file;
exceptionError( ostr.str() );

finally(3, ostr.str());
Expand Down Expand Up @@ -742,7 +739,7 @@ InFile::openNc(bool isNew)
{
if( path.size() > 0 )
nc.setPath(str);
if( ! nc.open(filename.c_str()) )
if( ! nc.open(filenameItems.file.c_str()) )
throw "Exception";
}
catch (char const*)
Expand Down Expand Up @@ -808,33 +805,12 @@ InFile::openNc(bool isNew)
}

void
InFile::setFilename(std::string fn)
InFile::setFilename(std::string f)
{
// filename with path
if( fn.find('/') == std::string::npos )
{
if( path.size() )
fn = path + "/" + fn;
}

filename=fn;

filenameItems = hdhC::setFilename(f);
return;
}

void
InFile::setFilePath(std::string pth)
{
size_t sz = pth.size();

if( sz && pth[ sz-1] == '/' )
path = pth.substr(0,sz-1);
else
path = pth;

return ;
}

void
InFile::setGeoCellShape(Variable &var)
{
Expand Down

0 comments on commit a9ab8ab

Please sign in to comment.