[petsc-users] KSPComputeOperator Fortran API

Jose E. Roman jroman at dsic.upv.es
Thu Jun 18 08:12:17 CDT 2026


It will probably also work for 3.22 and later.
Upgrading to the latest version will help usage from Fortran, since the new Fortran bindings are designed to enable type checking by the compiler. You may do an incremental update of your code, one version at a time, by checking the list of changes, e.g. https://urldefense.us/v3/__https://petsc.org/release/changes/322/__;!!G_uCfscf7eWS!apoyGEr1WFS7fn3YzsGiyHDOxtDOTTutNjxT4nGTvPTK-oHMxq1LnpZ9ERGZAuS3KbejDNo4Y5g12anqjbRhgEoM$  

Jose


> El 18 jun 2026, a las 14:57, Edoardo Centofanti <edoardo.centofanti01 at universitadipavia.it> escribió:
> 
> Thank you for your answer. So, there is no way to access it from previous versions? My codebase is quite old and changing PETSc version would imply updating also other calls to other routines, which may become time consuming.
> 
> Best,
> Edoardo
> 
> Il giorno gio 18 giu 2026 alle ore 12:40 Jose E. Roman <jroman at dsic.upv.es> ha scritto:
> I would suggest upgrading to the most recent version (3.25) since the new Fortran bindings cover most of the functionality, including this one.
> Jose
> 
> 
> > El 18 jun 2026, a las 10:14, Edoardo Centofanti <edoardo.centofanti01 at universitadipavia.it> escribió:
> > 
> > Dear users,
> > 
> > I am working on a finite element Fortran code and I would like to extract the preconditioned operator to explore its spectral properties. I know that the KSPComputeOperator routine exists in C. 
> > How can I call it from Fortran? I am currently using PETSc 3.20.2. 
> > 
> > So far I have tried
> > call KSPComputeOperator(ksp,MATMPIAIJ,AAprec,ierr)
> > 
> > and also its old/deprecated version
> > call KSPComputeExplicitOperator(ksp,AAprec,ierr)
> > 
> > But in both cases I got 
> > undefined reference to `kspcomputeoperator_'/`kspcomputeexplicitoperator_'
> > when compiling
> > 
> > Thanks in advance, 
> > Edoardo
> 
> 
> 
> -- 
> Edoardo Centofanti
> Dipartimento di Matematica 'Felice Casorati'
> Università degli Studi di Pavia
> Tel. 0382985608  |  Ufficio A14  |  Via Ferrata 5, 27100 Pavia, Italy



More information about the petsc-users mailing list