[petsc-users] Check the precision for real numbers
Barry Smith
bsmith at petsc.dev
Tue Oct 29 07:47:13 CDT 2024
Do you mean inside Fortran source code, you want to determine if single or double is being used?
1) The PETSc preprocess C macros are also included in Petsc's Fortran include files, so either
PETSC_USE_REAL_SINGLE or PETSC_USE_REAL_DOUBLE is always defined, you can then use
preprocessor macros to check: for example
#if defined(PETSC_USE_REAL_SINGLE)
xxxx
#else
xxxx
#endif
2) you can apply the Fortran kind() function to PetscReal to determine what type it is.
I hope this helps,
Barry
> On Oct 28, 2024, at 10:44 PM, Runjian Wu <wurunjian at gmail.com> wrote:
>
> Hi all,
>
> I have a question about how to return the precision for real number in Fortran code?
>
> Thanks,
>
> Runjian
More information about the petsc-users
mailing list