[petsc-users] Set the options NOT from argc and argv

Satish Balay balay at mcs.anl.gov
Tue May 21 09:48:48 CDT 2013


If PetscInitialize() is called from fortran - command line should work.

An easy alternative is to have a file 'petscrc' in the executable run
dir - with the command line options listed [one option per line]

Satish

On Tue, 21 May 2013, Matthew Knepley wrote:

> On Mon, May 20, 2013 at 11:01 PM, Longxiang Chen <suifengls at gmail.com>wrote:
> 
> > The fortran program is too long (several files with more than 10,000
> > lines).
> > And I just want to insert the P_solve inside one of the subroutine to
> > solve Ax=b.
> > Or it can only use argc and argv?
> >
> 
> Barry is correct that you can use PetscOptionsSetValue(), however I think
> you are
> still missing the point.
> 
> Command line options are processed in PetscInitialize(). You do not have to
> do anything
> else. You do not have to change your huge Fortran code. You just use the
> command line.
> It is much better than hard coding a solver type since you can use ALL
> solver types. There
> is no reason not to use it.
> 
>   Thanks,
> 
>      Matt
> 
> 
> > Thanks.
> > Longxiang
> >
> > Best regards,
> > Longxiang Chen
> >
> > Do something every day that gets you closer to being done.
> > --------------------------------------------------------------
> > 465 Winston Chung Hall
> > Computer Science Engineering
> > University of California, Riverside
> >
> >
> >
> > On Mon, May 20, 2013 at 8:52 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >>
> >> On May 20, 2013, at 10:38 PM, Longxiang Chen <suifengls at gmail.com> wrote:
> >>
> >> > To whom it may concern,
> >> >
> >> > I am using KSP to solve Ax=b.
> >> > The main() is in Fortran, and it calls a function I write in C.The
> >> parameter is array A, x, b.
> >> >
> >> > void P_solve(double x[ ], double b[ ], double A[ ], int size);
> >> >
> >> > In the function, I should call PetscInitialize() before I create the
> >> matrix and vectors for A, x, b, and also call MatSetFromOptions() and
> >> VecSetFromOptions().
> >> >
> >> > But I don't have the argc and argv from main function.
> >>
> >>     If Fortran is the main program the options database still has access
> >> to the command line arguments. You should still be able to use command line
> >> arguments and not need to set them in the program.
> >>
> >>      Does this not work? Can you send a sample program where it does not
> >> work?
> >>
> >>    Barry
> >>
> >> >
> >> > I just want to fix the KSP type to bcgs and the PC type.
> >> > Is there another way that I can set the options not through argc and
> >> argv, just set them in the program.
> >> >
> >> > e.g. options[] = {"-ksp_type", "bcgs"}.
> >> >
> >> > Thanks,
> >> > Longxiang
> >>
> >>
> >
> 
> 
> 



More information about the petsc-users mailing list