Commit af04477b authored by allens's avatar allens

for each FileFormat added NonCompliantException to most of the error...

for each FileFormat added NonCompliantException to most of the error messagingto gives users more information, minor clean up of other files.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12839 18c085ea-50e0-402c-830e-de6fd14e8384
parent bac1fbd0
......@@ -49,10 +49,11 @@
#include <vtkFloatArray.h>
#include <vtkUnstructuredGrid.h>
#include <avtDatabaseMetaData.h>
#include <InvalidDBTypeException.h>
#include <InvalidDBTypeException.h>
#include <InvalidVariableException.h>
#include <InvalidFilesException.h>
#include <NonCompliantException.h>
// Define this symbol BEFORE including hdf5.h to indicate the HDF5 code
// in this file uses version 1.6 of the HDF5 API. This is harmless for
......@@ -149,6 +150,9 @@ avtGTCFileFormat::Initialize()
if(initialized)
return true;
if( H5Fis_hdf5( GetFilename() ) < 0 )
EXCEPTION1( InvalidFilesException, GetFilename() );
// Turn off error message printing.
H5Eset_auto(0,0);
debug4 << mName << "Opening " << GetFilename() << endl;
......@@ -157,8 +161,10 @@ avtGTCFileFormat::Initialize()
if (fileHandle < 0)
{
debug4 << mName << "Could not open " << GetFilename() << endl;
EXCEPTION1(InvalidDBTypeException, "Cannot be a GTC file since it is not even an HDF5 file.");
debug4 << mName << "Could not open " << GetFilename() << endl;
EXCEPTION2( NonCompliantException, "GTC File Open",
"File '" + string(GetFilename()) + "' can not be opened" );
}
particleHandle = H5Dopen(fileHandle, "particle_data");
......@@ -166,8 +172,8 @@ avtGTCFileFormat::Initialize()
{
debug4 << mName << "Could not open particle_data" << endl;
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "Cannot be a GTC file, "
"since it is does not contain the dataset \"particle_data\"");
EXCEPTION2( NonCompliantException, "GTC Dataset Open",
"Dataset 'particle_data' can not be opened" );
}
//Check variable's size.
......@@ -181,7 +187,8 @@ avtGTCFileFormat::Initialize()
H5Sclose(sid);
H5Dclose(particleHandle);
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "The GTC file has an invalid number of dimensions");
EXCEPTION2( NonCompliantException, "GTC Dataset Extents",
"Dataset 'particle_data' has an invalid extents");
}
debug4 << mName << "Determining variable size" << endl;
......@@ -193,7 +200,8 @@ avtGTCFileFormat::Initialize()
H5Sclose(sid);
H5Dclose(particleHandle);
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "The GTC file has an insufficient number of variables");
EXCEPTION2( NonCompliantException, "GTC Dataset Extents",
"Dataset 'particle_data' has an insufficient number of variables");
}
H5Sclose(dataspace);
......@@ -902,6 +910,3 @@ parallelBuffer::AddElement( float *data )
}
#endif
......@@ -51,10 +51,8 @@
#include <avtDatabaseMetaData.h>
#include <Expression.h>
#include <BadIndexException.h>
#include <NonCompliantException.h>
#include <InvalidFilesException.h>
#include <InvalidVariableException.h>
#include <UnexpectedValueException.h>
#include <vtkStructuredGrid.h>
#include <vtkPoints.h>
#include <vtkCellType.h>
......@@ -128,22 +126,36 @@ static void dbg_string_attrib(hid_t id, const std::string &str)
avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
avtMTSDFileFormat (&filename, 1)
{
if( H5Fis_hdf5( filename ) < 0 )
EXCEPTION1( InvalidFilesException, filename );
// INITIALIZE DATA MEMBERS
fname = filename;
hid_t file;
hid_t root_id, group_id;
char *string_attrib;
float time;
file = H5Fopen (filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, filename);
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + string(filename) + "' can not be opened" );
}
hsize_t i, npoints;
// Read attributes
root_id = H5Gopen (file, "/");
if ( root_id < 0 )
{
H5Fclose(file);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The root group '/' was not found" );
}
dbg_string_attrib(root_id, "Description");
dbg_string_attrib(root_id, "Source");
......@@ -151,7 +163,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(root_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or was the wrong type." );
}
debug5 << "time: " << time << std::endl;
......@@ -160,7 +173,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(root_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The group '/GRID' was not found" );
}
string_attrib = NULL;
......@@ -174,8 +188,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose(file);
EXCEPTION2(UnexpectedValueException, "Cartesian - XYZ",
string_attrib);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Cartesian - XYZ' was not found or was the wrong type." );
}
free(string_attrib);
}
......@@ -194,8 +208,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
EXCEPTION2 (UnexpectedValueException, "Structured",
string_attrib ? string_attrib : "NULL");
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Topology' was not found or not 'Structured'" );
}
if(string_attrib)
{
......@@ -211,7 +225,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
EXCEPTION2 (UnexpectedValueException, 3, ndims);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Dimensions",
"Grid dataset 'X' does not have three dimensions" );
}
// points
for (i = 0, npoints = 1; i < ndims; i++)
......@@ -253,7 +268,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(group_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Step number' was not found or wrong type" );
}
cycles.push_back( atoi(stepnumber) );
......@@ -264,7 +280,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(group_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or wrong type" );
}
times.push_back( time );
......@@ -448,7 +465,10 @@ avtH5NimrodFileFormat::GetMesh (int timestate, const char *meshname)
hid_t file;
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t grid_id = H5Gopen (file, "/GRID");
vtkpoints->SetNumberOfPoints (npoints);
......@@ -513,7 +533,10 @@ avtH5NimrodFileFormat::GetVar (int timestate, const char *varname)
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t root_id, group_id;
root_id = H5Gopen (file, "/");
......@@ -570,7 +593,10 @@ avtH5NimrodFileFormat::GetVectorVar (int timestate, const char *varname)
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t root_id, group_id;
root_id = H5Gopen (file, "/");
......@@ -652,14 +678,9 @@ avtH5NimrodFileFormat::GetVectorVar (int timestate, const char *varname)
void avtH5NimrodFileFormat::GetCycles(std::vector<int> &c)
{
c = cycles;
metadata->SetCyclesAreAccurate(true);
metadata->SetCycles( cycles );
metadata->SetTimesAreAccurate(true);
metadata->SetTimes( times );
}
// ****************************************************************************
// Method: avtH5NimrodFileFormat::GetTimes
//
......@@ -677,10 +698,4 @@ void avtH5NimrodFileFormat::GetCycles(std::vector<int> &c)
void avtH5NimrodFileFormat::GetTimes(std::vector<double> &t)
{
t = times;
metadata->SetCyclesAreAccurate(true);
metadata->SetCycles( cycles );
metadata->SetTimesAreAccurate(true);
metadata->SetTimes( times );
}
......@@ -1170,6 +1170,7 @@ avtH5PartFileFormat::GetFieldMesh(int timestate, const char *meshname)
coords[2]->Delete();
visitTimer->StopTimer(t1, "H5PartFileFormat::GetFieldMesh()");
return rgrid;
}
......
......@@ -93,7 +93,7 @@ avtM3DC1Field::~avtM3DC1Field()
// ****************************************************************************
// Method: findElementNeighbors
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -192,7 +192,7 @@ void avtM3DC1Field::findElementNeighbors()
// ****************************************************************************
// Method: register_vert
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -221,7 +221,7 @@ void avtM3DC1Field::register_vert(v_entry *vlist, int *len,
// ****************************************************************************
// Method: add_edge
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -254,7 +254,7 @@ void avtM3DC1Field::add_edge(edge *list, int *tri,
// ****************************************************************************
// Method: get_tri_coords2D
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -282,7 +282,7 @@ int avtM3DC1Field::get_tri_coords2D(double *xin, int el, double *xout)
// ****************************************************************************
// Method: get_tri_coords2D
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -367,7 +367,7 @@ int avtM3DC1Field::get_tri_coords2D(double *xin, double *xout)
// ****************************************************************************
// Method: interp basic interpolation
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -386,7 +386,7 @@ float avtM3DC1Field::interp(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR interpolation in dR
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -411,7 +411,7 @@ float avtM3DC1Field::interpdR(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdz interpolation in dz
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -437,7 +437,7 @@ float avtM3DC1Field::interpdz(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR2 interpolation in dR2
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -467,7 +467,7 @@ float avtM3DC1Field::interpdR2(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdz2 interpolation in dz2
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -497,7 +497,7 @@ float avtM3DC1Field::interpdz2(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR interpolation in dR
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -528,9 +528,10 @@ float avtM3DC1Field::interpdRdz(float *var, int el, double *lcoords)
// Method: interpBcomps
//
// Simultaneously interpolate all three cylindrical components of
// magnetic field
// magnetic field - should not be used for calculating integral
// curves.
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......
This diff is collapsed.
......@@ -123,7 +123,7 @@ class avtM3DC1FileFormat : public avtMTSDFileFormat
std::vector<int> m_cycles;
std::vector<double> m_times;
public:
public:
std::vector<std::string> m_scalarVarNames;
std::vector<std::string> m_fieldVarNames;
......
......@@ -15,8 +15,8 @@ MDSplusMDServerPluginInfo.C
${COMMON_SOURCES}
avtMDSplusFileFormat.C
avtMDSplusOptions.C
mdsPlusAPI.C
#mdsPlusReader.cc
mdsPlusAPI.c
)
SET(LIBE_SOURCES
......@@ -24,8 +24,8 @@ MDSplusEnginePluginInfo.C
${COMMON_SOURCES}
avtMDSplusFileFormat.C
avtMDSplusOptions.C
mdsPlusAPI.C
#mdsPlusReader.cc
mdsPlusAPI.c
)
INCLUDE_DIRECTORIES(
......
This diff is collapsed.
......@@ -173,7 +173,7 @@ int get_dims( const char *signal, int **dims ) {
int rank = get_rank( signal );
if( rank > 0 ) {
*dims = malloc( rank * sizeof( int ) );
*dims = (int *) malloc( rank * sizeof( int ) );
/* Fetch the dimensions of the signal. */
for( i=0; i<rank; i++ ) {
......@@ -187,7 +187,18 @@ int get_dims( const char *signal, int **dims ) {
}
/* Query the long value of the node - as in the number of slices. */
/* Query the value of the node. */
void* get_value( const char *prefix, const char *signal, int dtype ) {
/* Local vars */
char buf[1024]; /* Buffer for MDS+ exp */
sprintf(buf, "%s(%s)", prefix, signal);
return (void*) get_value( buf, dtype );
}
/* Query the value of the node - as in the number of slices. */
void* get_value( const char *signal, int dtype ) {
/* Local vars */
......@@ -230,13 +241,15 @@ void* get_value( const char *signal, int dtype ) {
memset(buf, 0, sizeof(buf));
sprintf( buf, "SIZEOF(%s)", signal );
value = (void*) get_value( buf, DTYPE_LONG );
int *length = (int*) get_value( buf, DTYPE_LONG );
if( value )
size = (int) (*(int*) value) + 1;
if( length )
size = (int) (*(int*) length) + 1;
else
return NULL;
free( length);
dtype = DTYPE_CSTRING;
value = (void*) malloc( size * sizeof( char ) );
break;
......@@ -267,7 +280,7 @@ void* get_value( const char *signal, int dtype ) {
/* Trim the white spaces off of the strings. */
if( value ) {
char *name = value;
char *name = (char *) value;
int i = size - 1;
while (name[i] == ' ')
......@@ -370,7 +383,7 @@ void* get_values( const char *signal, int dtype ) {
/* Trim the white spaces off of the strings. */
cc = 0;
char *names = values;
char *names = (char *) values;
for( n=0; n<size; n++ ) {
char *name = (char*) &(names[n*max_str]);
......@@ -486,7 +499,8 @@ double *get_slice_data( const char *name,
/* Query the server for the child names of a signal. */
unsigned int
get_names( const char *signal, char **names, char recurse, char absolute, char type )
get_names( const char *signal, char **names,
bool recurse, bool absolute, bool type )
{
char buf[1024]; /* buffer for MDS+ exp */
......
......@@ -39,10 +39,6 @@
#define MDS_PLUS_API
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DTYPE_FS
#undef DTYPE_FS
#endif
......@@ -67,6 +63,7 @@ int get_type( const char *signal );
int get_dims( const char *signal, int **dims );
char *get_name( const int nid );
void *get_value( const char *prefix, const char *signal, int dtype);
void *get_value( const char *signal, int dtype);
void *get_values( const char *signal, int dtype );
......@@ -79,12 +76,8 @@ double *get_slice_data( const char *name,
const char *node,
int **dims );
unsigned int get_names( const char *signal, char **names,
char recurse, char absolute, char type );
bool recurse, bool absolute, bool type );
unsigned int get_nids ( const char *signal, int **nids );
#ifdef __cplusplus
} // extern "C"
#endif
#endif // MDS_PLUS_API
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