Commit 9c6211cf authored by allens's avatar allens

added reader specific check for making sure the reader and file are correct

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12840 18c085ea-50e0-402c-830e-de6fd14e8384
parent af04477b
......@@ -150,15 +150,36 @@ avtGTCFileFormat::Initialize()
if(initialized)
return true;
// Turn off error message printing.
H5Eset_auto(0,0);
bool err = false;
// Check for a valid GTC file
if( H5Fis_hdf5( GetFilename() ) < 0 )
EXCEPTION1( InvalidFilesException, GetFilename() );
// Turn off error message printing.
H5Eset_auto(0,0);
if ((fileHandle = H5Fopen(GetFilename(), H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
EXCEPTION1( InvalidFilesException, GetFilename() );
particleHandle = H5Dopen(fileHandle, "particle_data");
if (particleHandle < 0)
{
H5Fclose(fileHandle);
EXCEPTION1( InvalidFilesException, GetFilename() );
}
H5Dclose(particleHandle);
H5Fclose(fileHandle);
fileHandle = -1;
particleHandle = -1;
// Open as normal
debug4 << mName << "Opening " << GetFilename() << endl;
bool err = false;
fileHandle = H5Fopen(GetFilename(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (fileHandle < 0)
{
debug4 << mName << "Could not open " << GetFilename() << endl;
......@@ -176,6 +197,8 @@ avtGTCFileFormat::Initialize()
"Dataset 'particle_data' can not be opened" );
}
//Check variable's size.
hid_t dataspace = H5Dget_space(particleHandle);
hsize_t dims[3];
......
......@@ -126,19 +126,37 @@ 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;
hid_t file_id, root_id, group_id;
char *string_attrib;
float time;
file = H5Fopen (filename, H5F_ACC_RDONLY, H5P_DEFAULT);
// Check for a valid H5NIMROD file
if( H5Fis_hdf5( filename ) < 0 )
EXCEPTION1( InvalidFilesException, filename );
if (file < 0)
if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
EXCEPTION1( InvalidFilesException, filename );
group_id = H5Gopen(file_id, "/GRID");
if (group_id < 0)
{
H5Fclose(file_id);
EXCEPTION1( InvalidFilesException, filename );
}
H5Gclose(group_id);
H5Fclose(file_id);
file_id = -1;
group_id = -1;
// Open as normal
file_id = H5Fopen (filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if (file_id < 0)
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + string(filename) + "' can not be opened" );
......@@ -147,11 +165,11 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
hsize_t i, npoints;
// Read attributes
root_id = H5Gopen (file, "/");
root_id = H5Gopen (file_id, "/");
if ( root_id < 0 )
{
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The root group '/' was not found" );
}
......@@ -162,17 +180,17 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
if (H5NIMROD_read_attrib (root_id, "time", &time) == H5NIMROD_ERR)
{
H5Gclose(root_id);
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or was the wrong type." );
}
debug5 << "time: " << time << std::endl;
hid_t grid_id = H5Gopen (file, "/GRID");
hid_t grid_id = H5Gopen (file_id, "/GRID");
if (grid_id < 0)
{
H5Gclose(root_id);
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The group '/GRID' was not found" );
}
......@@ -187,7 +205,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
debug5 << "Cannot handle non cartesian coordinates" << std::endl;
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Cartesian - XYZ' was not found or was the wrong type." );
}
......@@ -207,7 +225,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
debug5 << "Cannot handle unstructured mesh" << std::endl;
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
H5Fclose (file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Topology' was not found or not 'Structured'" );
}
......@@ -224,7 +242,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
debug5 << "Cannot handle other than 3 dimensional data" << std::endl;
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
H5Fclose (file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Dimensions",
"Grid dataset 'X' does not have three dimensions" );
}
......@@ -267,7 +285,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
if (H5NIMROD_read_attrib (group_id, "Step number", &stepnumber) == H5NIMROD_ERR)
{
H5Gclose(group_id);
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Step number' was not found or wrong type" );
}
......@@ -279,7 +297,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
if (H5NIMROD_read_attrib (group_id, "time", &time) == H5NIMROD_ERR)
{
H5Gclose(group_id);
H5Fclose(file);
H5Fclose(file_id);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or wrong type" );
}
......@@ -327,7 +345,7 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose (group_id);
H5Gclose (grid_id);
H5Gclose (root_id);
H5Fclose (file);
H5Fclose (file_id);
}
......
......@@ -1463,11 +1463,28 @@ avtM3DC1FileFormat::LoadFile()
H5open();
H5Eset_auto( NULL, NULL, NULL );
// Check for a valid M3D C1 file
if( H5Fis_hdf5( m_filename.c_str() ) < 0 )
EXCEPTION1( InvalidFilesException, m_filename.c_str() );
m_fileID = H5Fopen( m_filename.c_str(), H5P_DEFAULT, H5P_DEFAULT );
if ( (m_fileID = H5Fopen( m_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
EXCEPTION1( InvalidFilesException, m_filename.c_str() );
hid_t tempID = H5Gopen( m_fileID, "/equilibrium/mesh", H5P_DEFAULT);
if( tempID < 0 )
{
H5Fclose(m_fileID);
EXCEPTION1( InvalidFilesException, m_filename.c_str() );
}
H5Gclose(tempID);
H5Fclose(m_fileID);
m_fileID = -1;
// Open as normal
m_fileID = H5Fopen( m_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if ( m_fileID < 0 )
{
EXCEPTION2( NonCompliantException, "M3DC1 File Open",
......
......@@ -213,7 +213,7 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
if( (m_socket = MDS_Connect( m_host.c_str() )) < 0 )
{
EXCEPTION1( NonCompliantException, "MDSplus server connection",
EXCEPTION2( NonCompliantException, "MDSplus server connection",
"Unable to connect to MDS server " + m_host );
}
......@@ -403,7 +403,7 @@ avtMDSplusFileFormat::GetVar(int timestate, const char *varname)
if( (m_socket = MDS_Connect( m_host.c_str() )) < 0 )
{
EXCEPTION1( NonCompliantException, "MDSplus server connection",
EXCEPTION2( NonCompliantException, "MDSplus server connection",
"Unable to connect to MDS server " + m_host );
}
......@@ -536,7 +536,7 @@ avtMDSplusFileFormat::LoadFile()
if( (m_socket = MDS_Connect( m_host.c_str() )) < 0 )
{
EXCEPTION1( NonCompliantException, "MDSplus server connection",
EXCEPTION2( NonCompliantException, "MDSplus server connection",
"Unable to connect to MDS server " + m_host );
}
......
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