[petsc-users] Matlab socket connection

Barry Smith bsmith at mcs.anl.gov
Thu Apr 16 07:28:50 CDT 2015


> On Apr 16, 2015, at 2:47 AM, siddhesh godbole <siddhesh4godbole at gmail.com> wrote:
> 
> Hello Barry
> 
> sorry for the same doubt again but i have tried everything i could to send data across matlab from petsc via socket. matlab paths to ${PETSC_DIR}/share/petsc/matlab and ${PETSC_DIR}/${PETSC_ARCH}/lib/matlab are added properly, petsc was configured with --with matlab option, and it has successfully generated mex files corresponding to sopen etc too. i have a file named sopen.mexa64 in ${PETSC_ARCH}/lib/matlab.
> 
> everytime the petsc program is lauched from matlab with Launch('./program',np,opt) it gives an error in the line p = PetscOpenSocket; in which the error is specifically in S = struct('fd', sopen());

  Please always cut and paste the entire error message.

   Does src/ksp/ksp/examples/tutorials/ex41.m work? 

  You can attempt to debug by manually opening Matlab and entering

launch('./ex41  ',1,' ');

p = PetscOpenSocket;

etc.


> i have made sure that previous sopen belonging to some other package as u said does not exist in the path. 
> can you tell me why i would be getting this error?
> 
> extract from my code in c
> PetscViewerSocketOpen(PETSC_COMM_WORLD,"server",PETSC_NULL,&fd);
> ierr = MatCreate(PETSC_COMM_WORLD,&mmtop);CHKERRQ(ierr);
>       ierr = MatLoad(mmtop,fd);CHKERRQ(ierr);
> 
> ierr = MatCreate(PETSC_COMM_WORLD,&kktop);CHKERRQ(ierr);
>       ierr = MatLoad(kktop,fd);CHKERRQ(ierr);
> 
> ierr = MatView(Phi,fd);CHKERRQ(ierr);
> 
> 
> extract from my matlab code interfacing with petsc
> 
> mmtop=zeros(15,15);
> kktop=zeros(15,15);
> for i=1:15;
>     for j=1:15;
>             mmtop(i,j)=(i+j)+(i+1)*(j+2);
>                 kktop(i,j)=(i+j+5)+(i+2)*(j+2);
>     end
> end
> if (nargin < 1)
>   np = 1;
> end
> if (nargin < 2) 
>   opt = ' ';
> end
> launch('./eps13D  ',np,opt);
> 
> fd=PetscOpenSocket();
> 
> 
> PetscBinaryWrite(fd,mmtop);
> PetscBinaryWrite(fd,kktop);
> phi = PetscBinaryRead(fd);
> 
> close(socket);
> 
> 
> thank you
> 
> 
> 
> 
> 
> 
> Siddhesh M Godbole
> 
> 5th year Dual Degree,
> Civil Eng & Applied Mech.
> IIT Madras
> 
> On Fri, Apr 10, 2015 at 10:39 PM, siddhesh godbole <siddhesh4godbole at gmail.com> wrote:
> Oh...I found that! Sorry for the silly doubt!
> 
> Thank you so much Barry!
> 
> On Apr 10, 2015 6:23 PM, "Barry Smith" <bsmith at mcs.anl.gov> wrote:
> 
>   Ahh, bad name spacing. PETSc has an sopen  mex file for opening socket connections, some completely different other package has an sopen.m which is being found first. Make sure the PETSc sopen mex file is in the MATLABPATH before the other one or better yet make sure the other sopen.m is not in the MATLABPATH
> 
>   Barry
> 
> > On Apr 10, 2015, at 6:46 AM, siddhesh godbole <siddhesh4godbole at gmail.com> wrote:
> >
> > Hello,
> >
> > I am having difficulty in launching petsc program from matlab. According to the error the problem is with the sopen function. error given in the matlab command window is that there are not enough arguments for sopen in the line 75. i am attaching sopen.m file with mail. can you help me out with this as there is no one to solve my doubt in this area. i am also attaching my program file eps13D.m
> > the sopen call is made by the function PetscOpenSocket in which line 10 subsequently also shoots an error.
> >
> > Thanks a lot
> >
> >
> > Siddhesh M Godbole
> >
> > 5th year Dual Degree,
> > Civil Eng & Applied Mech.
> > IIT Madras
> > <eps13D.m><sopen.m><PetscOpenSocket.m>
> 
> 



More information about the petsc-users mailing list