Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
! Example program that shows how to create FORTRAN binding for PARI1module PARI2use ISO_C_BINDING, only : C_LONG, C_DOUBLE, C_PTR3interface4subroutine pari_init(parisize, maxprime) bind(C,name='pari_init')5import C_LONG6integer(kind=C_LONG), VALUE :: parisize7integer(kind=C_LONG), VALUE :: maxprime8end subroutine pari_init9!10subroutine pari_close() bind(C,name='pari_close')11end subroutine pari_close12!13type(C_PTR) function dbltor( r ) bind(C,name='dbltor')14import C_DOUBLE, C_PTR15real(kind=C_DOUBLE), VALUE :: r16end function dbltor17!18real(kind=C_DOUBLE) function rtodbl( x ) bind(C,name='rtodbl')19import C_DOUBLE, C_PTR20type(C_PTR), VALUE :: x21end function rtodbl22!23type(C_PTR) function gsqr( x ) bind(C,name='gsqr')24import C_PTR25type(C_PTR), VALUE :: x26end function gsqr27!28type(C_PTR) function gmul( x , y) bind(C,name='gmul')29import C_PTR30type(C_PTR), VALUE :: x31type(C_PTR), VALUE :: y32end function gmul33!34type(C_PTR) function gprec( x , d) bind(C,name='gprec')35import C_PTR, C_LONG36type(C_PTR), VALUE :: x37integer(kind=C_LONG), VALUE :: d38end function gprec39!40type(C_PTR) function gmod( x , y) bind(C,name='gmod')41import C_PTR42type(C_PTR), VALUE :: x43type(C_PTR), VALUE :: y44end function gmod45!46type(C_PTR) function glog( x , prec) bind(C,name='glog')47import C_PTR, C_LONG48type(C_PTR), VALUE :: x49integer(kind=C_LONG), VALUE :: prec50end function glog51!52type(C_PTR) function stoi(x) bind(C,name='stoi')53import C_PTR, C_LONG54integer(kind=C_LONG), VALUE :: x55end function stoi56!57integer(kind=C_LONG) function itos(x) bind(C,name='itos')58import C_PTR, C_LONG59type(C_PTR), VALUE :: x60end function itos61!62type(C_PTR) function Pi2n(x, prec) bind(C,name='Pi2n')63import C_PTR, C_LONG64integer(kind=C_LONG), VALUE :: x65integer(kind=C_LONG), VALUE :: prec66end function Pi2n67end interface68end module PARI69!70PROGRAM prog71use ISO_C_BINDING, only : C_PTR, C_DOUBLE72use PARI73implicit none74real(kind=C_DOUBLE) :: r = 1e3675type(C_PTR) :: p76integer(kind=C_LONG) :: prec = 20 ! 18 words77CALL pari_init(10000000_8,2_8)78p = glog(stoi(10000_8),prec)79p = gmod(p, Pi2n(1_8, prec))80r = rtodbl(p)81CALL pari_close()82PRINT '(a,f0.9)','log(10000)%(2*Pi) = ', r83END PROGRAM prog848586