Lisandro's description is the most natural way for a modern fortran programmer.

But for completeness, this is equivalent:
   x=REAL(0.123456789123456789123456789,KIND=PETSC_REAL_KIND)

Similarly, for complex numbers we have:
  xc=(0.1_PETSC_REAL_KIND,0.2_PETSC_REAL_KIND)
or
  xc=CMPLX(0.1,0.2,KIND=PETSC_REAL_KIND)


If you do not want to use the selected_real_kind
as Lisandro shows, you can also use the intrinsics
which are generally compiler independent:
https://gcc.gnu.org/onlinedocs/gcc-3.4.4/g77/Kind-Notation.html

That is,
  x=REAL(0.1,KIND=2)
or equivalently
  x=DBLE(0.1)
if you always want double precision regardless
of how PETSC_REAL_KIND is defined.

Scott


On 9/1/16 3:13 PM, Lisandro Dalcin wrote:

On 1 September 2016 at 23:05, Barry Smith <[email protected]
<mailto:[email protected]>> wrote:

       I didn't have a solution to this


! These lines should be added to
$PETSC_DIR/include/petsc/finclude/petscsysdef.h
#if defined(PETSC_USE_REAL_SINGLE)
integer, parameter :: PETSC_REAL_KIND = selected_real_kind(5)
#elif defined(PETSC_USE_REAL_DOUBLE)
integer, parameter :: PETSC_REAL_KIND = selected_real_kind(10)
#elif defined(PETSC_USE_REAL___FLOAT128)
integer, parameter :: PETSC_REAL_KIND = selected_real_kind(20)
#endif

! User code should write literals this way
PetscReal x
x = 0.123456789123456789123456789_PETSC_REAL_KIND



--
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

--
Tech-X Corporation               [email protected]
5621 Arapahoe Ave, Suite A       Phone: (720) 974-1841
Boulder, CO 80303                Fax:   (303) 448-7756

Reply via email to