Commit fb9ef8c2 authored by fogal1's avatar fogal1

Merge from 1.12RC.

Mostly build fixes, some extra error checking, and some changes to
prevent reading from uninitialized memory.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@7123 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6ce9f455
......@@ -47,9 +47,12 @@
#include <cstring>
#include <string>
#include <vector>
#include <vector>
#include <visitstream.h>
#include <sys/stat.h>
#include <visitstream.h>
#include <avtDatabase.h>
#include <avtDatabaseMetaData.h>
#include <avtGenericDatabase.h>
......
......@@ -43,6 +43,8 @@
#include <avtCurveExpression.h>
#include <cstring>
#include <snprintf.h>
#include <DebugStream.h>
#include <ExpressionException.h>
......
......@@ -268,6 +268,14 @@ protected:
// Dave Pugmire, Wed Aug 13 10:58:32 EDT 2008
// Added distSqrVecVec and distVecVec functions.
//
// Tom Fogal, Wed Apr 29 19:34:01 MDT 2009
// . Create a 1-elem array if needed in the copy ctor; `new x[0]' is
// invalid.
// . Add a parameter to the data & size constructor to detail how many
// elements to copy from the source array. The source array is allowed
// (and is, in some code -- see pad()) to be smaller than the destination
// array.
//
//*****************************************************************************
class avtVec: public avtVecRef
......@@ -286,20 +294,22 @@ public:
std::fill( begin(), end(), 0.0 );
}
avtVec( const_pointer data, const size_type& n ) :
avtVec( const_pointer data, const size_type& n, const size_type& ncopy ) :
avtVecRef( new double[n], n )
{
std::copy( data, data+n, begin() );
std::copy( data, data+ncopy, begin() );
}
avtVec( const avtVecRef& other ) :
avtVecRef( new double[other.dim()], other.dim() )
avtVecRef( new double[other.dim() ? other.dim() : 1],
other.dim() ? other.dim() : 1 )
{
std::copy( other.begin(), other.end(), begin() );
}
avtVec( const avtVec& other ) :
avtVecRef( new double[other.dim()], other.dim() )
avtVecRef( new double[other.dim() > 0 ? other.dim() : 1],
other.dim() > 0 ? other.dim() : 1 )
{
std::copy( other.begin(), other.end(), begin() );
}
......@@ -548,9 +558,14 @@ inline double norm_inf( const avtVecRef& v )
return max( abs(v) );
}
// Modifications:
//
// Tom Fogal, Wed Apr 29 19:35:57 MDT 2009
// Use new size parameter to detail size of source array.
//
inline avtVec pad( const avtVecRef& v, const double& a )
{
avtVec result( v.begin(), v.dim()+1 );
avtVec result( v.begin(), v.dim()+1, v.dim() );
result[v.dim()] = a;
return result;
......
......@@ -480,7 +480,7 @@ main(int argc, char *argv[])
else
{
char *argv0 = (char *)malloc(strlen(visitpath) + 100);
sprintf(argv0, "\"%s\\%\"s", visitpath, component);
sprintf(argv0, "\"%s\\%s\"", visitpath, component);
strcpy(command, argv0);
strcpy(printCommand, argv0);
......@@ -570,7 +570,7 @@ main(int argc, char *argv[])
* It's not perfect but we might want to consider cleaning it up and
* switching.
*/
#if 0
#if 1
printf("=============\n%s\n", spawnargs[0]);
for(i = 1; i < nspawnargs; ++i)
printf("\t%s\n", spawnargs[i]);
......
......@@ -118,6 +118,9 @@ struct PARSER_API ParseElem
// START, which doesn't make much sense. Instead, we just store it in
// a new data member, which is more direct and more clear.
//
// Tom Fogal, Wed Apr 29 15:36:42 MDT 2009
// Check for empty `elems' so we don't deref an empty vector.
//
// ****************************************************************************
class PARSER_API Parser
{
......@@ -128,7 +131,12 @@ public:
void ParseOneToken(Token *);
bool Accept() { return accept; }
virtual ParseTreeNode *Parse(const std::string &) = 0;
ParseTreeNode *GetParseTree() { return parseTree; }
ParseTreeNode *GetParseTree() {
if(elems.empty()) {
return NULL;
}
return elems[0].node;
}
void SetGrammar(Grammar * g) { G = g; }
protected:
......
......@@ -49,10 +49,19 @@
#include <map>
#include <vector>
#include <visit-config.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include <DebugStream.h>
#include <InvalidDirectoryException.h>
#include <InvalidPluginException.h>
#include <InstallationFunctions.h>
#include <Utility.h>
#include <visitstream.h>
#if __APPLE__
......
......@@ -68,6 +68,44 @@ std::string;
using
std::vector;
// ****************************************************************************
// Function: dbg_string_attrib
//
// Purpose:
// Look up a string attribute from within the hdf5 file. Echo it's value to
// our debug logs.
//
// Arguments:
// id hdf5 identifier; should be the return value from an H5GOpen call.
// str string to both lookup and include in the debug line.
//
// Programmer: Tom Fogal
// Creation: Wed Apr 29 15:59:41 MDT 2009
//
// Modifications:
//
// ****************************************************************************
static void dbg_string_attrib(hid_t id, const std::string &str)
{
char *attrib = NULL;
int h5err = H5NIMROD_read_string_attrib(id, str.c_str(), &attrib);
if(h5err == H5NIMROD_ERR)
{
debug1 << "Reading '" << str << "' string in H5Nimrod gave an error!"
<< " Is this attribute guaranteed to exist for all H5Nimrod "
"files?" << std::endl;
}
// The read_string_attrib call can fail, but failure doesn't give any
// information about whether or not the string given in the 3rd argument
// was actually allocated. Thus we set the string to NULL and check if it
// got changed during the call.
if(NULL != attrib)
{
debug5 << str << ": " << attrib << std::endl;
free(attrib);
}
}
// ****************************************************************************
// Method: avtH5Nimrod constructor
......@@ -79,6 +117,9 @@ std::vector;
// Kathleen Bonnell, Wed Jul 2 08:43:22 PDT 2008
// Removed unreferenced variables.
//
// Tom Fogal, Wed Apr 29 16:11:41 MDT 2009
// Handle errors when reading string attributes.
//
// ****************************************************************************
avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
......@@ -95,28 +136,35 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
if (file < 0)
EXCEPTION1 (InvalidFilesException, filename);
hsize_t i, j, npoints;
hsize_t i, npoints;
// Read attributes
root_id = H5Gopen (file, "/");
H5NIMROD_read_string_attrib (root_id, "Description", &string_attrib);
debug5 << "Description: " << string_attrib << std::endl;
free (string_attrib);
H5NIMROD_read_string_attrib (root_id, "Source", &string_attrib);
debug5 << "Source: " << string_attrib << std::endl;
free (string_attrib);
dbg_string_attrib(root_id, "Description");
dbg_string_attrib(root_id, "Source");
H5NIMROD_read_attrib (root_id, "time", &time);
debug5 << "time: " << time << std::endl;
hid_t grid_id = H5Gopen (file, "/GRID");
string_attrib = NULL;
H5NIMROD_read_string_attrib (grid_id, "Coordinate System", &string_attrib);
debug5 << "Coordinate System: " << string_attrib << std::endl;
if (strstr(string_attrib, "Cartesian - XYZ") == NULL)
if(string_attrib != NULL)
{
debug5 << "Cannot handle non cartesian coordinates" << std::endl;
EXCEPTION2 (UnexpectedValueException, "Cartesian - XYZ", string_attrib);
debug5 << "Coordinate System: " << string_attrib << std::endl;
if (strstr(string_attrib, "Cartesian - XYZ") == NULL)
{
debug5 << "Cannot handle non cartesian coordinates" << std::endl;
EXCEPTION2(UnexpectedValueException, "Cartesian - XYZ",
string_attrib);
}
free(string_attrib);
}
string_attrib = NULL;
H5NIMROD_read_string_attrib (grid_id, "Topology", &string_attrib);
if (strstr (string_attrib, "Structured") != NULL)
if (string_attrib && strstr(string_attrib, "Structured") != NULL)
{
structured = 1;
debug5 << "Grid is structured!" << std::endl;
......@@ -127,10 +175,13 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
debug5 << "Cannot handle unstructured mesh" << std::endl;
EXCEPTION2 (UnexpectedValueException, "Structured", string_attrib);
}
free (string_attrib);
H5NIMROD_read_string_attrib (grid_id, "Geometry", &string_attrib);
debug5 << "Geometry: " << string_attrib << std::endl;
free (string_attrib);
if(string_attrib)
{
free (string_attrib);
}
dbg_string_attrib(grid_id, "Geometry");
H5NIMROD_read_dims (grid_id, "X", &ndims, grid_dims);
if (ndims != 3)
{
......@@ -258,13 +309,17 @@ avtH5NimrodFileFormat::FreeUpResources (void)
// Programmer: cristina -- generated by xml2avt
// Creation: Fri Feb 9 08:26:27 PDT 2007
//
// Modifications:
//
// Tom Fogal, Wed Apr 29 16:09:52 MDT 2009
// Removed an unused variable.
//
// ****************************************************************************
void
avtH5NimrodFileFormat::PopulateDatabaseMetaData (avtDatabaseMetaData * md,
int timeState)
{
avtMeshType mt = AVT_CURVILINEAR_MESH;
int nblocks = 1; // <-- this must be 1 for MTSD
int block_origin = 0;
int spatial_dimension = ndims;
......
......@@ -826,11 +826,12 @@ avtHDF_UCFileFormat::ConstructHistogram(avtHistogramSpecification *spec)
for (int i=0; i<variables.size(); i++) {
begins[i] = spec->GetBounds()[i][0];
ends[i] = spec->GetBounds()[i][spec->GetBounds()[i].size()-1];
debug4<<"boundsSpecified to be "<< begins[i] <<", "<<ends[i]<<std::endl;
}
}
//if bounds are not specified than ask the reader for the extents
else{
debug4<< plugin << func << "Detected that bounds are not set.. setting them to..";
debug4<< plugin << func << "Detected that bounds are not set.. setting them to.."<<std::endl;
for(int i=0; i<variables.size() ; i++){
......@@ -862,7 +863,7 @@ avtHDF_UCFileFormat::ConstructHistogram(avtHistogramSpecification *spec)
debug4<< "\t HDF-FQ/FastBit calculated " << variables[i] << " bounds to be.. "
<< begins[i] << ", "<< ends[i] << endl<<endl;
<< begins[i] << ", "<< ends[i] << endl<<endl;
}
}
......@@ -895,8 +896,8 @@ avtHDF_UCFileFormat::ConstructHistogram(avtHistogramSpecification *spec)
double begin2 = begins[1];
double end2 = ends[1];
// debug4 << "BEGIN1 = " << begin1 << ", END1 " << end1 << ", begin2 " << begin2 << ", end2 = " << end2 << endl;
// debug4 << "numbins1 = " << numBins[0] << ", numBins2 = " << numBins[1] << endl;
debug4 << "BEGIN1 = " << begin1 << ", END1 " << end1 << ", begin2 " << begin2 << ", end2 = " << end2 << endl;
debug4 << "numbins1 = " << numBins[0] << ", numBins2 = " << numBins[1] << endl;
if( regularBinning ){ //if regular binning should be used
reader.get2DHistogram((int64_t)0,
......@@ -934,7 +935,9 @@ avtHDF_UCFileFormat::ConstructHistogram(avtHistogramSpecification *spec)
//debug4<<"**********************HDF_UC*************"<<spec->GetBounds().size()<<" "<<spec->GetBounds()[0].size()<<" "<<spec->GetBounds()[1].size()<<endl;
spec->SetBoundsSpecified();
spec->SetCounts( count ); //Copy the counts into the specification
spec->SetCounts( count ); //Copy the counts into the
//specification
//debug4<<"**********************HDF_UC*************"<<spec->GetNumberOfBins()[0]<<" "<<spec->GetNumberOfBins()[1]<<endl;
......
......@@ -152,8 +152,8 @@ void HDF5_FQ::getPointData(const std::string & variableName,
const std::vector<int32_t>& indices) {
bool retval = dataSets->getPointData(variableName,time,data, indices);
if (!retval)
std::cout<<"getPointData failed"<<std::endl;
//if (!retval)
//std::cout<<"getPointData failed"<<std::endl;
}
......@@ -280,7 +280,7 @@ void HDF5_FQ::getDataMinMax_Double(const std::string& variableName,
min = range[0];
max = range[1];
//std::cout<<"getDataMinMax_Double returned " << min << ", "<< max << " for "<< variableName<<std::endl;
}
void HDF5_FQ::getDataMinMax_Float(const std::string& variableName,
......@@ -299,6 +299,7 @@ void HDF5_FQ::getDataMinMax_Float(const std::string& variableName,
min = range[0];
max = range[1];
//std::cout<<"getDataMinMax_Float returned " << min << ", "<< max << " for "<< variableName<<std::endl;
}
......
......@@ -192,6 +192,110 @@ array_t<double>* H5_FQ_Variable::selectDoubles(const ibis::bitvector& mask) co
return array;
} // H5_FQ_Variable::selectDoubles
array_t<float>* H5_FQ_Variable::selectFloats(const ibis::bitvector& mask) const {
array_t<float>* array = new array_t<float>;
array_t<float> prop;
uint32_t i = 0;
uint32_t tot = mask.cnt();
ibis::horometer timer;
if (ibis::gVerbose > 3) {
LOGGER(ibis::gVerbose > 4)
<< "H5_FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
<< "." << name() << "]::selectFloats starting timer..";
timer.start();
}
#ifdef DEBUG
LOGGER(1) << "DEBUG -- reading " << name() << ", mask.cnt() = " << tot
<< ", mask.bytes() = " << mask.bytes()
<< ", mask.size()*8/pagesize = "
<< mask.size()*8/ibis::fileManager::pageSize()
<< ", read all = "
<< (mask.bytes()/4 > mask.size()/ibis::fileManager::pageSize() ?
"yes" : "no");
#endif
if (mask.size() < 1048576 || tot+tot > mask.size() ||
mask.bytes()/4 > mask.size()/ibis::fileManager::pageSize()) {
// read all values than extract the ones marked with 1 in mask
getValues(prop); // retrieving all values of this variable
array->resize(tot);
if (tot > prop.size()) tot = prop.size();
const uint32_t nprop = prop.size();
ibis::bitvector::indexSet index = mask.firstIndexSet();
if (nprop >= mask.size()) {
while (index.nIndices() > 0) {
const ibis::bitvector::word_t *idx0 = index.indices();
if (index.isRange()) {
for (uint32_t j = *idx0; j<idx0[1]; ++j, ++i) {
(*array)[i] = (prop[j]);
}
}
else {
for (uint32_t j = 0; j<index.nIndices(); ++j, ++i) {
(*array)[i] = (prop[idx0[j]]);
}
}
++ index;
}
}
else {
while (index.nIndices() > 0) {
const ibis::bitvector::word_t *idx0 = index.indices();
if (*idx0 >= nprop) break;
if (index.isRange()) {
for (uint32_t j = *idx0;
j<(idx0[1]<=nprop ? idx0[1] : nprop);
++j, ++i) {
(*array)[i] = (prop[j]);
}
}
else {
for (uint32_t j = 0; j<index.nIndices(); ++j, ++i) {
if (idx0[j] < nprop)
(*array)[i] = (prop[idx0[j]]);
else
break;
}
}
++ index;
}
}
}
else {
// generate the coordinates and ask HDF5 function to extract them
std::vector<int32_t> coord;
coord.reserve(tot);
for (ibis::bitvector::indexSet ix = mask.firstIndexSet();
ix.nIndices() > 0; ++ ix) {
const ibis::bitvector::word_t *ind = ix.indices();
if (ix.isRange()) {
for (unsigned int j = ind[0]; j < ind[1]; ++ j)
coord.push_back(static_cast<int32_t>(j));
}
else {
for (unsigned int j = 0; j < ix.nIndices(); ++j)
coord.push_back(static_cast<int32_t>(ind[j]));
}
}
i = getPointValues(*array, coord);
}
if (i != tot) {
array->resize(i);
logWarning("selectFloats", "expects to retrieve %lu elements "
"but only got %lu", static_cast<long unsigned>(tot),
static_cast<long unsigned>(i));
}
else if (ibis::gVerbose > 3) {
timer.stop();
LOGGER(ibis::gVerbose >= 0)
<< "H5_FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
<< "." << name() << "]::selectFloats extracted " << tot << " value"
<< (tot > 1 ? "s" : "") << " out of " << mask.size() << " took "
<< timer.CPUTime() << " sec (CPU) and " << timer.realTime()
<< " sec (elapsed) time";
}
return array;
} // H5_FQ_Variable::selectFloats
void H5_FQ_Variable::loadIndex(const char*) const throw () {
writeLock lock(this, "loadIndex");
......
......@@ -142,6 +142,7 @@ public:
int getPointValues(array_t<E>& arr,
const std::vector<int32_t>& coords) const;
virtual array_t<double>* selectDoubles(const ibis::bitvector& mask) const;
virtual array_t<float>* selectFloats(const ibis::bitvector& mask) const;
/// Return the H5_Index object containing this variable.
H5_Index& getH5Index() const {return h5file_;}
......
......@@ -156,6 +156,9 @@
# Eric Brugger, Tue Dec 9 17:37:27 PST 2008
# Added MultiCurve plot.
#
# Tom Fogal, Wed Apr 29 15:15:19 MDT 2009
# Added the Poincare plot to the `built by default' list.
#
##############################################################################
@SET_MAKE@
......@@ -167,8 +170,9 @@ all: message
OPTIONAL=Topology
REQUIRED=Boundary Contour Curve FilledBoundary Histogram Label Mesh Molecule \
MultiCurve ParallelCoordinates Pseudocolor Scatter Spreadsheet \
Streamline Subset Surface Tensor Truecolor Vector Volume WellBore
MultiCurve Poincare ParallelCoordinates Pseudocolor Scatter \
Spreadsheet Streamline Subset Surface Tensor Truecolor Vector \
Volume WellBore
# The following is a minimal subset of the OPTIONAL/REQUIRED plugins
MINIMAL=Curve Mesh Pseudocolor
......
......@@ -40,6 +40,7 @@
#include <StreamlineAnalyzerLib.h>
#include <algorithm>
#include <float.h>
#include <iostream>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment