[petsc-users] Start logging with -info after PetscInitialize()

Jacob Faibussowitsch jacob.fai at gmail.com
Tue Jun 13 09:55:24 CDT 2023


> Perhaps the cleanup can be done automatically so as to not require the user to know they need to call the Destroy first? 

It is a question of guessing whether the user intended to do this. On the one hand, the PetscInfo() API is so esoteric that anybody manually calling it must surely know what they are doing. But on the other hand, it is useful to catch this.

I suppose I can add a note in the error message to call PetscInfoDestroy() if it is truly intended.

Best regards,

Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)

> On Jun 13, 2023, at 10:38, Barry Smith <bsmith at petsc.dev> wrote:
> 
> 
>   Jacob,
> 
>    Perhaps the cleanup can be done automatically so as to not require the user to know they need to call the Destroy first? The current API seems odd.
> 
> 
> 
>> On Jun 13, 2023, at 10:25 AM, Jacob Faibussowitsch <jacob.fai at gmail.com> wrote:
>> 
>> Call PetscInfoDestroy() first.
>> 
>> https://petsc.org/main/manualpages/Profiling/PetscInfoDestroy/
>> 
>> Best regards,
>> 
>> Jacob Faibussowitsch
>> (Jacob Fai - booss - oh - vitch)
>> 
>>> On Jun 13, 2023, at 10:16, Jeremy Theler (External) via petsc-users <petsc-users at mcs.anl.gov> wrote:
>>> 
>>> Hello all.
>>> 
>>> I've asked this question to Satish personally last week at the conference, but I'm stuck so any help would be appreciated.
>>> For some reason not worth explaining, I need to activate -info after PetscInitialize() has been already called.
>>> I'm trying something like this:
>>> 
>>> PetscOptionsSetValue(NULL, "-info", NULL);        
>>> PetscInfoSetFromOptions(NULL);
>>> 
>>> The second call fails with
>>> 
>>> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
>>> [0]PETSC ERROR: Object is in wrong state
>>> [0]PETSC ERROR: PetscInfoSetClasses() cannot be called after PetscInfoGetClass() or PetscInfoProcessClass()
>>> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
>>> [0]PETSC ERROR: Petsc Release Version 3.19.2, Jun 01, 2023
>>> [0]PETSC ERROR: reflexCLI on a double-int32-release named LIN54Z7SQ3 by jtheler Tue Jun 13 11:08:29 2023
>>> [0]PETSC ERROR: Configure options --download-eigen --download-hdf5 --download-hypre --download-metis --download-mumps --download-parmetis --download-pragmatic --download-scalapack --download-slepc --with-64-bit-indices=no --with-debugging=no --with-precision=double --with-scalar-type=real COPTFLAGS=-O3 CXXOPTFLAGS=-O3 FOPTFLAGS=-O3 --download-egads --download-opencascade --download-tetgen
>>> [0]PETSC ERROR: #1 PetscInfoSetClasses() at /home/jtheler/libs/petsc-3.19.2/src/sys/info/verboseinfo.c:182
>>> [0]PETSC ERROR: #2 PetscInfoSetFromOptions() at /home/jtheler/libs/petsc-3.19.2/src/sys/info/verboseinfo.c:407
>>> 
>>> But if I ignore the non-zero return value and I allow my program to continue, the required logging is enabled.
>>> I also tried using a local PetscOptions object but the result is the same.
>>> 
>>> Any ideas to avoid that wrong state error?
>>> 
>>> Thanks
>>> --
>>> jeremy
>> 
>> 
> 



More information about the petsc-users mailing list