[petsc-users] Set the directory of output file

Likun Tan tlk0812 at hotmail.com
Tue May 27 15:57:44 CDT 2014


It works. Thank you very much.

> On May 27, 2014, at 1:40 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> 
>> On Tue, 27 May 2014, Likun Tan wrote:
>> 
>> Hello,
>> 
>> I want to create and write my simulation result in a binary file called result.dat, but I want to set my file in a different folder, say /home/username/output
>> 
>> I am using
>> 
>> PetscViewerBinaryOpen(PETSC_COMM_WORLD, result.dat, FILE_MODE_WRITE, & view)
>> 
>> But this will create the file in the current folder by default. How could I modify the command to set a new path? Thank you.
> 
> You should be able to do:
> 
> PetscViewerBinaryOpen(PETSC_COMM_WORLD, "/home/username/output/result.dat", FILE_MODE_WRITE, & view)
> 
> [or specify the path to the output file at runtime and use
> PetscOptionsGetString() to extract this string and use with
> PetscViewerBinaryOpen(). For ex: check '-f0' usage in
> src/ksp/ksp/examples/tutorials/ex10.c]
> 
> Satish
> 
> 


More information about the petsc-users mailing list