Did we come to a conclusion on this? Is it worthwhile adding macros for C and Fortran literals to make sure they match the PetscScalar type along with the appropriate configure tests?
Todd. > On Sep 3, 2016, at 3:18 PM, Lisandro Dalcin <[email protected]> wrote: > > > On 2 September 2016 at 00:46, Scott Kruger <[email protected]> wrote: > 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) > > I think you are wrong. The literal gets demoted to single precision, so you > loose digits. > > $ cat tmp.f90 > program main > real(kind=8) x > x = REAL(0.123456789123456789123456789,KIND=8) > write (*,'(F18.16)') x > x = 0.123456789123456789123456789_8 > write (*,'(F18.16)') x > end program main > > $ gfortran tmp.f90 > $ ./a.out > 0.1234567910432816 > 0.1234567891234568 > > > -- > 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
