[petsc-users] Set the directory of output file

Satish Balay balay at mcs.anl.gov
Tue May 27 15:40:27 CDT 2014


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