[petsc-users] how to import an array from matlab?

Barry Smith bsmith at mcs.anl.gov
Wed Jan 28 07:29:05 CST 2015


   You probably want to stick to just using binary files to move the data between PETSc and MATLAB and not use sockets.

    But if you want to use sockets the reason you get the error message is that you haven't called PetscBinaryWrite(5005) (or PetscBinaryRead(5005)) or PetscOpenSocket(5005) BEFORE running the PETSc program to receive the results.

   Barry


> On Jan 27, 2015, at 11:33 PM, siddhesh godbole <siddhesh4godbole at gmail.com> wrote:
> 
> Hello,
> 
> I have been trying to use the functions PetscSocketOpen but it gets stuck in this function shooting the following error
> 
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Error in system call
> [0]PETSC ERROR: Connection refused by remote host renoir port 5005
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.5.2, Sep, 08, 2014 
> [0]PETSC ERROR: ./10D on a arch-linux2-c-debug named renoir by hridya Wed Jan 28 10:45:49 2015
> [0]PETSC ERROR: Configure options --download-mpich
> [0]PETSC ERROR: #1 PetscOpenSocket() line 133 in /home/hridya/Downloads/petsc-3.5.2/src/sys/classes/viewer/impls/socket/send.c
> [0]PETSC ERROR: #2 PetscViewerSocketSetConnection() line 400 in /home/hridya/Downloads/petsc-3.5.2/src/sys/classes/viewer/impls/socket/send.c
> [0]PETSC ERROR: #3 PetscViewerSocketOpen() line 289 in /home/hridya/Downloads/petsc-3.5.2/src/sys/classes/viewer/impls/socket/send.c
> 
> i am using this for the first time. Please help !
> 
> Thanks a lot
> 
> 
> Siddhesh M Godbole
> 
> 5th year Dual Degree,
> Civil Eng & Applied Mech.
> IIT Madras
> 
> On Tue, Jan 27, 2015 at 6:54 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>   Use PetscBinaryWrite.m from MATLAB (documentation at the top of the file) to save the array into a file then in PETSc use VecLoad() to load the matrix.  PetscBinaryWrite.m is in $PETSC_DIR/bin/matlab or $PETSC_DIR/share/petsc/matlab depending on your version of PETSc.
> 
>    Barry
> 
> 
> 
> > On Jan 27, 2015, at 1:52 AM, siddhesh godbole <siddhesh4godbole at gmail.com> wrote:
> >
> > Hello,
> > i am trying to import an array of 10000 elements into petsc. interfacing fails when i try to use launch('./mycode',np,opt) in my matlab due to some incompatibility. Then i tried importing .mat file into petsc and i got stuck.
> > Can you please tell me how can i import an array from matlab into petsc and use it for my calculations?
> >  Thanks in advance!
> >
> > Siddhesh M Godbole
> >
> > 5th year Dual Degree,
> > Civil Eng & Applied Mech.
> > IIT Madras
> 
> 



More information about the petsc-users mailing list