[cig-commits] r7619 - in cs/cigma/branches/cigma-0.9b1: src tmc
luis at geodynamics.org
luis at geodynamics.org
Mon Jul 9 12:51:06 PDT 2007
Author: luis
Date: 2007-07-09 12:51:06 -0700 (Mon, 09 Jul 2007)
New Revision: 7619
Modified:
cs/cigma/branches/cigma-0.9b1/src/cigma-compare.cpp
cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.cpp
cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.hpp
Log:
Added more explicit error messages (TODO: how to disable traceback?)
Modified: cs/cigma/branches/cigma-0.9b1/src/cigma-compare.cpp
===================================================================
--- cs/cigma/branches/cigma-0.9b1/src/cigma-compare.cpp 2007-07-09 18:50:27 UTC (rev 7618)
+++ cs/cigma/branches/cigma-0.9b1/src/cigma-compare.cpp 2007-07-09 19:51:06 UTC (rev 7619)
@@ -148,10 +148,20 @@
const char *secondfile = path2[0].c_str();
const char *second_loc = path2[1].c_str();
- reader.get_time_series(firstfile, first_loc, &sts1, &vts1, &its1);
+ int ierr;
+
+ ierr = reader.get_time_series(firstfile, first_loc, &sts1, &vts1, &its1);
+ if (ierr < 0)
+ {
+ return -3;
+ }
print_mesh_info(its1);
- reader.get_time_series(secondfile, second_loc, &sts2, &vts2, &its2);
+ ierr = reader.get_time_series(secondfile, second_loc, &sts2, &vts2, &its2);
+ if (ierr < 0)
+ {
+ return -4;
+ }
print_mesh_info(its2);
if (((sts1 != NULL) && (vts2 != NULL)) ||
@@ -160,7 +170,7 @@
cerr << "Error: Incompatible fields: "
<< "Cannot compare scalar and vector fields "
<< endl;
- return -3;
+ return -5;
}
std::vector<float> residuals;
@@ -178,13 +188,20 @@
}
else
{
- return -4;
+ cerr << "Error: Failed to initialize one of the fields" << endl;
+ return -6;
}
- residuals_write_vtk(output,
- its1->get_vertices(),
- its1->get_tetrahedra(),
- residuals);
+ ierr = residuals_write_vtk(output,
+ its1->get_vertices(),
+ its1->get_tetrahedra(),
+ residuals);
+ if (ierr < 0)
+ {
+ cerr << "Error: Could not write to " << output << endl;
+ return -7;
+ }
+
return 0;
}
Modified: cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.cpp
===================================================================
--- cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.cpp 2007-07-09 18:50:27 UTC (rev 7618)
+++ cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.cpp 2007-07-09 19:51:06 UTC (rev 7619)
@@ -16,6 +16,8 @@
#include "../libcigma/dataset.h"
#include "../libcigma/mesh.h"
+#include <iostream>
+
GTB_BEGIN_NAMESPACE
HDF5_Reader::HDF5_Reader()
@@ -23,11 +25,11 @@
}
-void HDF5_Reader::get_time_series(const char *filename,
- const char *field_location,
- Scalar_time_series **out_sts,
- Vector_time_series **out_vts,
- Indexed_tetra_set **out_its)
+int HDF5_Reader::get_time_series(const char *filename,
+ const char *field_location,
+ Scalar_time_series **out_sts,
+ Vector_time_series **out_vts,
+ Indexed_tetra_set **out_its)
{
*out_sts = NULL;
*out_vts = NULL;
@@ -44,16 +46,21 @@
dataset_id = H5Dopen(field_file_id, field_location);
if (dataset_id < 0)
{
+ std::cerr << "Error: Could not open dataset " << field_location
+ << " in file " << filename << std::endl;
H5Fclose(field_file_id);
- return;
+ return -1;
}
char *mesh_location;
status = get_str_attr(dataset_id, "MeshLocation", &mesh_location);
if (status < 0)
{
+ std::cerr << "Error: Could not find metadata attribute 'MeshLocation'"
+ << " in dataset " << field_location
+ << " in file " << filename << std::endl;
H5Fclose(field_file_id);
- return;
+ return -2;
}
status = H5Dclose(dataset_id);
@@ -65,8 +72,10 @@
if (ierr < 0)
{
+ std::cerr << "Error: Could not read dataset " << field_location
+ << " from " << filename << std::endl;
status = H5Fclose(field_file_id);
- return;
+ return -3;
}
std::vector<float> scalars;
@@ -93,10 +102,29 @@
hid_t mesh_group_id;
mesh_group_id = h5_group_open(field_file_id, mesh_location);
+ if (mesh_group_id < 0)
+ {
+ std::cerr << "Error: Could not find " << mesh_location
+ << " in file " << filename << std::endl;
+ return -4;
+ }
mesh_t mesh;
ierr = mesh_read_coords(&mesh, mesh_group_id, "coordinates");
+ if (ierr < 0)
+ {
+ std::cerr << "Error: Could not open coordinates dataset in group "
+ << mesh_location << " from file " << filename << std::endl;
+ return -5;
+ }
+
ierr = mesh_read_connect(&mesh, mesh_group_id, "connectivity");
+ if (ierr < 0)
+ {
+ std::cerr << "Error: Could not open connectivity dataset in group "
+ << mesh_location << " from file " << filename << std::endl;
+ return -6;
+ }
free(mesh_location);
@@ -123,6 +151,8 @@
mesh_free(&mesh);
*out_its = new Indexed_tetra_set(m_vertices, m_tetrahedra);
+
+ return 0;
}
GTB_END_NAMESPACE
Modified: cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.hpp
===================================================================
--- cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.hpp 2007-07-09 18:50:27 UTC (rev 7618)
+++ cs/cigma/branches/cigma-0.9b1/tmc/HDF5_Reader.hpp 2007-07-09 19:51:06 UTC (rev 7619)
@@ -30,7 +30,7 @@
public:
HDF5_Reader();
- void get_time_series(const char *filename,
+ int get_time_series(const char *filename,
const char *field_location,
Scalar_time_series **out_sts,
Vector_time_series **out_vts,
More information about the cig-commits
mailing list