Bill Allombert on Fri, 18 Sep 2020 19:49:39 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Fortran compatibility


On Fri, Sep 18, 2020 at 04:39:47PM +0200, Bill Allombert wrote:
> PROGRAM prog
>   use ISO_C_BINDING, only : C_PTR, C_DOUBLE
>   use PARI
>   implicit none
>   real(kind=C_DOUBLE) :: r      = 1e36
>   type(C_PTR)         :: p
>   CALL pari_init(10000000_8,2_8)
>   p = gmul(gprec(dbltor(r),1000_8),glog(stoi(10000_8),20_8))
>   !p = gmod(p, Pi2n(1_8,20_8))
>   r = rtodbl(p)
>   CALL pari_close()
>   PRINT '(a,f0.9)','1e36*log(10000)%(2*Pi)  = ', r
> END PROGRAM prog

Sorry my mailer sent the wrong file, the correct version is 

PROGRAM prog
  use ISO_C_BINDING, only : C_PTR, C_DOUBLE
  use PARI
  implicit none
  real(kind=C_DOUBLE) :: r      = 1e36
  type(C_PTR)         :: p
  integer(kind=C_LONG) :: prec = 20 ! 18 words
  CALL pari_init(10000000_8,2_8)
  p = glog(stoi(10000_8),prec)
  p = gmod(p, Pi2n(1_8, prec))
  r = rtodbl(p)
  CALL pari_close()
  PRINT '(a,f0.9)','log(10000)%(2*Pi)  = ', r
END PROGRAM prog

Cheers,
Bill