as there's a bunch of good fortran code out there, i've been fiddling on 
wrapping fortran 77 subroutines, it's as simple as with C but compatible real & 
double precision must generated with gfortran, i.e.:
    
    
    @gfortran -Ofast -c -fdefault-real-8 -fdefault-double-8 493.f
    
    
    Run

this ensures nim::float (==float64) compatibility,

generated fortran objects are lowercase with a trailing '_': 
'[rpoly](https://forum.nim-lang.org/postActivity.xml#rpoly)' in this case:

so nim interface is: 
    
    
    proc poly_root_f(op: ptr cdouble, degree: ptr cint, zeror, zeroi: ptr 
cdouble, fail: ptr cint) {.importc: "rpoly_".}
    
    
    Run

final linking with -lm -lgfortran -lquadmath does the trick

full code for polynomial roots:

<https://github.com/rforcen/nim/blob/main/rpoly.nim> 
<https://github.com/rforcen/nim/blob/main/493.f>

Reply via email to