[petsc-users] petsc4py & GPU

Francesco Caimmi francesco.caimmi at polimi.it
Thu Apr 20 12:15:33 CDT 2017


Hi Damian,

You can use the "parse_known_args" method of the ArgumentParser class; it will create a Namespace with the args you defined and return the uknown ones  as a list of strings you can pass to petsc4py.init.
See:
https://docs.python.org/3.6/library/argparse.html
section 16.4.5.7.

I used it successfully in the past. Hope this helps.

Best,
--
Francesco Caimmi

Laboratorio di Ingegneria dei Polimeri
http://www.chem.polimi.it/polyenglab/

Politecnico di Milano - Dipartimento di Chimica,
Materiali e Ingegneria Chimica “Giulio Natta”

P.zza Leonardo da Vinci, 32
I-20133 Milano
Tel. +39.02.2399.4711
Fax +39.02.7063.8173

francesco.caimmi at polimi.it
Skype: fmglcaimmi

________________________________________
From: petsc-users-bounces at mcs.anl.gov <petsc-users-bounces at mcs.anl.gov> on behalf of Damian Kaliszan <damian at man.poznan.pl>
Sent: Thursday, April 20, 2017 6:26 PM
To: Lisandro Dalcin
Cc: PETSc
Subject: Re: [petsc-users] petsc4py & GPU

Hi,
There might be the problem because I'm using ArgumentParser class to catch complex command line arguments. In this case is there any chance to make both to cooperate or the only solution is to pass everything through argument to init method of petsc4py?
Best,
Damian
W dniu 20 kwi 2017, o 17:37, użytkownik Lisandro Dalcin <dalcinl at gmail.com<mailto:dalcinl at gmail.com>> napisał:

On 20 April 2017 at 17:09, Damian Kaliszan <damian at man.poznan.pl<mailto:damian at man.poznan.pl>> wrote:
Thank you for reply:) Sorry for maybe stupid question in the scope of setting petsc(4py) options.
Should the following calls (somewhere before creating matrix & vectors):

PETSc.Options().setValue("ksp_view", "")
PETSc.Options().setValue("log_view", "")

Unfortunately, no. There are a few options (-log_view ?) that you should set before calling PetscInitialize() (which happens automatically at import time), otherwise things do not work as expected. To pass things from the command line and set them before PetscInitialize() the usual idiom is:

import sys, petsc4py
petsc4py.init(sys.argv)
from petsc4py import PETSc



--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459


More information about the petsc-users mailing list