question about VecLoad (pls disregard previous one)

Barry Smith bsmith at mcs.anl.gov
Wed May 14 20:28:51 CDT 2008


   Since PETSc is used from C or Fortran you are free to write any  
kind of code you want
that reads in ASCII files anyway you want. As you have done it is good  
to save the vectors
with a binary viewer because they are easy to read and write; but  
again you can write
whatever code you want.

    As to whether you code is wrong, no one can say, just run it and  
test it.

    Barry

On May 14, 2008, at 6:39 PM, tsjb00 wrote:

>
> Sorry the previous message is wrong
>
> Hi! I have a question about VecLoad. In my program, I need to read  
> in ordered data from an input file, which in an ordinary c program  
> would be as:
>  for (k=0; ky->z,ie  
> p(x0,y0,z0),p(x1,y0,z0),...,p(x0,y1,z0),p(x1,y1,z0),...*/
> 	fscanf(fp,"%f %f %f %f\n",&dumx,&dumy,&dumz,&var);
> 	i++;
> 	idx=i;
> 	AOApplicationToPetsc(ao,1,&idx);
> 	VecSetValue(v0,idx,var,INSERT_VALUES);
>      }
> then use VecView to output the binary file:
>       
> PetscViewerBinaryOpen 
> (PETSC_COMM_SELF,"out.dat",FILE_MODE_WRITE,&viewer);
>      VecView(v0,viewer);
>
> Please let me know if something is wrong.
>
> Many thanks!
>
> JB
>
> _________________________________________________________________
> MSN 中文网,最新时尚生活资讯,白领聚集门户。
> http://cn.msn.com
>
>




More information about the petsc-users mailing list