Dear petsc-expert!

I am having trouble loading the contents of my hdf5 dataset - "Vp" - into the Mat object Vp using MatLoad. When I try to do this, I get the error message displayed below.

The hdf5 file I am trying to read, was originally created in Matlab with their built in function h5write. I am wondering whether this is the source of the problem? Nonetheless, a screendump of the file's structure can be seen here:

I have tried following a few of your examples as inspiration, however there may of course still be a problem in my code. I have appended the code below here (it is a short program, so I hope it is ok! - and please disregard the red error-squiggles - these are not true).

I hope you are able to help with my problem.

Best regards,

Martin

staticcharhelp[]= "Reads a HDF5 into a PETSC matrix.\n\n";
#include"../../petsc/include/petscsys.h"
#include"../../petsc/include/petscmat.h"
#include"../../petsc/include/petscviewerhdf5.h"
intmain(intargc, char**argv)
{
MatVp;
PetscViewerviewer;
charfile[PETSC_MAX_PATH_LEN]="../../Desktop/OnewaySimulations/Realization_1.h5";
charVp_name[128]="Vp";
PetscBoolflg;
PetscInitialize(&argc, &argv, (char*)0, help);
// Determine from which file we read the matrix
PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg);
// Read
PetscViewerHDF5Open(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer);
// Load matrix
MatCreate(PETSC_COMM_WORLD, &Vp);
PetscObjectSetName((PetscObject)Vp, Vp_name);
MatSetFromOptions(Vp);
MatLoad(Vp,viewer);
// Destroy
PetscViewerDestroy(&viewer);
MatDestroy(&Vp);
PetscFinalize();
return0;
}

Reply via email to