I have recently started using SLEPc for diagonalizing large sparse matrices, taking advantage of MPI. Everything works fine, except at the end when I want to write the eigenvectors to a file. I do this:
PetscViewerASCIIOpen(PETSC_COMM_WORLD, "./data/eigvecs.txt", &viewer);
PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_PYTHON);
EPSVectorsView(eps, viewer);
I run my code with mpiexec -n 3 ./app. The generated file eigvecs.txt looks like this:
Vec Object: Xr0_EPS_0x84000004_0 3 MPI processes
type: mpi
Process [0]
-0.909229
0.415619
Process [1]
-0.00206267
0.00410161
Process [2]
0.0145993
0.01813
Vec Object: Xi0_EPS_0x84000004_0 3 MPI processes
type: mpi
Process [0]
0.
0.
Process [1]
0.
0.
Process [2]
0.
0.
So the components of each eigenvector are printed in parallel and different eigenvectors are separated by a string of 0s, also printed in parallel.
My question: Is there no better way to do this? Because later I would want to read this file in python or julia and do some computations. If not, what's the best way to read this file in python or julia?
Thanks!
regexto extract the floating-point values from the file and store it as a matrix, rather than banging my head over finding another way to write the eigenvectors. So for me, the problem is solved!