[PETSC #19080] Re: reading matlab binary files

Barry Smith bsmith at mcs.anl.gov
Sat Feb 21 13:19:55 CST 2009


   OK, I just downloaded petsc-3.0.0-p3 from the web:

barry-smiths-macbook-pro:~/Datafiles/Matrices] barrysmith% setenv  
MATLABPATH /Users/barrysmith/Src/petsc-3.0.0-p3/bin/matlab
[barry-smiths-macbook-pro:~/Datafiles/Matrices] barrysmith% matlab - 
nojvm -nodisplay
                                                 < M A T L A B (R) >
                                       Copyright 1984-2008 The  
MathWorks, Inc.
                                              Version 7.7.0.471 (R2008b)
                                                  September 17, 2008


   To get started, type one of these: helpwin, helpdesk, or demo.
   For product information, visit www.mathworks.com.

 >> a = PetscBinaryRead('matrix.m');
 >>

I think you do not have the correct PETSc installed. Please DELETE any  
PETSc you have installed and get petsc-3.0.0-p3 then do what I have  
done above
to load the matrix. You do NOT have to first run config and make on  
PETSc to try the load.

Make sure your MATLABPATH doesn't have some old PETSc in its path.


    Barry


I On Feb 20, 2009, at 1:33 PM, Khan, Irfan wrote:

> I installed the latest petsc code and tried binary matlab output and  
> read again. It did not work, I get the same error message. I have  
> attached the binary file with this email. The .info files were empty  
> and as I mentioned I did not get any error messages.
> The matlab version I am using is 7.4.0.287 (R2007a).
>
> Thanks for the help
> Regards
> Irfan
>
>
> ----- Original Message -----
> From: "Barry Smith" <bsmith at mcs.anl.gov>
> To: "PETSc users list" <petsc-users at mcs.anl.gov>
> Sent: Friday, February 20, 2009 12:27:18 PM GMT -05:00 US/Canada  
> Eastern
> Subject: Re: reading matlab binary files
>
>
>   Irfan,
>
>    Make sure you use the absolutely latest PETSc patches version.
> There were some problems that we just recently fixed.
> If that does not solve the problem send the binary file to petsc-maint at mcs.anl.gov
>
>    Barry
>
> On Feb 20, 2009, at 10:51 AM, Khan, Irfan wrote:
>
>> Hi
>>
>> In an earlier email to the group Barry mentioned that if the matrix
>> sizes are large, the output should be done in binary format and bin/
>> matlab/PetscBinaryRead.m should be used to read the matrix into
>> matlab.
>>
>> I have output the matrix in the following manner.
>>
>>      ierr   =  PetscViewerBinaryOpen(PETSC_COMM_WORLD, fname,
>> FILE_MODE_WRITE, &viewer);
>>      ierr   =
>> PetscObjectSetName((PetscObject)obj.Amat,"Stiffness_matrix");
>>      ierr   =  MatView(obj.Amat,viewer);
>>
>> I don't get any error messages during execution. However, when I
>> have not been successful reading the matrix into matlab. Presently I
>> get the following error messages.
>>
>>
>>
>> ??? Error using ==> fread
>> Invalid file identifier.  Use fopen to generate a valid file
>> identifier.
>>
>> Error in ==> PetscOpenFile.read at 5
>> d = fread(freader.fd,count,datatype);
>>
>> Error in ==> PetscBinaryRead at 49
>> header = read(fd,1,'int32');
>>
>>
>> Any suggestions to solve the problem?
>>
>> Thanks
>> Irfan
>
> <matrix.m>



More information about the petsc-users mailing list