[petsc-users] Why PETSc needs PetscScalar datatype?

Appel, Thibaut t.appel17 at imperial.ac.uk
Sat Aug 4 12:33:35 CDT 2018


Hi,

I can’t speak from a design point of view since I didn’t write PETSc myself but I assume it was to have more compact source files and to avoid copying routines twice (with one version for real and one version for complex).

I am also using Fortran and it is actually flexible, as it allows you to write a unique version of your application code that works for both arithmetic types. If you need to write different pieces of code at some point, you can include preprocessed directives through the use of the PETSC_USE_COMPLEX boolean that is known at compilation time.

Thibaut

> Hi all,
> 
> I am just wondering why PETSc introduces PetscScalar datatype in addition
> to the PetscReal and PetscComplex.
> Could someone help clarify the rationale behind this design?
> I am primarily a Fortran guy. The additional datatype PetscScalar seems to
> only confuse me rather than provide me any flexibility.
> Cheers,
> Youjun Hu



More information about the petsc-users mailing list