00001 #include "EpetraExt_ConfigDefs.h"
00002 #ifdef HAVE_MPI
00003 #include "mpi.h"
00004 #include "Epetra_MpiComm.h"
00005 #else
00006 #include "Epetra_SerialComm.h"
00007 #endif
00008 #include <vector>
00009 #include "Epetra_Map.h"
00010 #include "Epetra_MultiVector.h"
00011 #include "Epetra_CrsMatrix.h"
00012 #include "EpetraExt_HDF5.h"
00013 #include "EpetraExt_Utils.h"
00014 #include "EpetraExt_Exception.h"
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 int main (int argc, char **argv)
00028 {
00029 #ifdef HAVE_MPI
00030 MPI_Init(&argc, &argv);
00031 Epetra_MpiComm Comm(MPI_COMM_WORLD);
00032 #else
00033 Epetra_SerialComm Comm;
00034 #endif
00035
00036 try
00037 {
00038
00039 EpetraExt::HDF5 HDF5(Comm);
00040
00041
00042
00043
00044
00045
00046
00047 HDF5.Open("matlab.h5");
00048
00049 if (Comm.MyPID() == 0)
00050 cout << endl;
00051 cout << "*) Reading Epetra_CrsMatrix from HDF5 file matlab.h5..." << endl;
00052 cout << endl;
00053
00054
00055 int NumGlobalRows, NumGlobalCols, NumGlobalNonzeros;
00056 int NumGlobalDiagonals, MaxNumEntries;
00057 double NormOne, NormInf;
00058
00059 HDF5.ReadCrsMatrixProperties("speye", NumGlobalRows, NumGlobalCols,
00060 NumGlobalNonzeros, NumGlobalDiagonals,
00061 MaxNumEntries, NormOne, NormInf);
00062
00063 if (Comm.MyPID() == 0)
00064 {
00065 cout << "Matrix information as given by ReadCrsMatrixProperties()";
00066 cout << endl << endl;
00067 cout << "NumGlobalRows = " << NumGlobalRows << endl;
00068 cout << "NumGlobalCols = " << NumGlobalCols << endl;
00069 cout << "NumGlobalNonzeros = " << NumGlobalNonzeros << endl;
00070 cout << "NumGlobalDiagonals = " << NumGlobalDiagonals << endl;
00071 cout << "MaxNumEntries = " << MaxNumEntries << endl;
00072 cout << "NormOne = " << NormOne << endl;
00073 cout << "NormInf = " << NormInf << endl;
00074 }
00075
00076
00077
00078 Epetra_CrsMatrix* Matrix = 0;
00079 HDF5.Read("speye", Matrix);
00080
00081 cout << *Matrix;
00082
00083 if (Comm.MyPID() == 0)
00084 {
00085 cout << endl;
00086 cout << "*) Reading Epetra_MultiVector from HDF5 file matlab.h5..." << endl;
00087 cout << endl;
00088 }
00089
00090 Epetra_MultiVector* x;
00091 HDF5.Read("x", x);
00092 cout << *x;
00093
00094 if (Comm.NumProc() == 2)
00095 {
00096 if (Comm.MyPID() == 0)
00097 {
00098 cout << endl;
00099 cout << "*) Reading Epetra_Map from HDF5 file matlab.h5..." << endl;
00100 cout << endl;
00101 }
00102
00103 Epetra_Map* Map;
00104 HDF5.Read("map-2", Map);
00105 cout << *Map;
00106 }
00107
00108
00109
00110
00111 HDF5.Close();
00112
00113
00114 if (Matrix) delete Matrix;
00115 }
00116 catch(EpetraExt::Exception& rhs)
00117 {
00118 rhs.Print();
00119 }
00120 catch (...)
00121 {
00122 cerr << "Caught generic exception" << endl;
00123 }
00124
00125 #ifdef HAVE_MPI
00126 MPI_Finalize();
00127 #endif
00128
00129 return(EXIT_SUCCESS);
00130 }