[petsc-users] how to import an array from matlab?
Karl Rupp
rupp at iue.tuwien.ac.at
Fri Jan 30 02:58:23 CST 2015
Hi,
> i want read an array of 10000 scalars from
> /home/Desktop/project/psi.mat to petsc. i have called the following
> routines:
>
> ierr =
> PetscViewerBinaryOpen(PETSC_COMM_WORLD,"psi.mat",FILE_MODE_READ,&fd);CHKERRQ(ierr);
> PetscViewerBinaryGetDescriptor(fd,&REV);
> PetscBinaryRead(REV,trial,10000,PETSC_SCALAR);
I recommend
a) replacing "psi.mat" with "/home/Desktop/project/psi.mat"
b) checking the error codes of PetscViewerBinaryGetDescriptor() and
PetscBinaryRead() by using ierr and CHKERRQ(ierr);
To provide the filename at runtime, simply pass the appropriate string
instead of a hard-coded string to PetscViewerBinaryOpen(). This is a
basic C and you can find enough tutorials on the internet on how to use
e.g. command line parameters.
Best regards,
Karli
More information about the petsc-users
mailing list