I have an R program, that calls two R functions, f1 and f2.
f1 calls stats::dnorm (which is an R wrapper for some C code, called C_dnorm).
f2 calls extraDistr::dgev (which is an R wrapper for some CPP code called cpp_dgev).
I’m thinking of rewriting f1 and f2 in a compiled language. Preferably Fortran, but could be C, CPP or Rust.
I’ve found instructions for that, so that sounds possible.
But I’d still like to call dnorm and dgev from within f1 and f2.
At that point, I’d like to call the C version of dnorm (C_dnorm) and the CPP version of dgev (cpp_dgev) directly from my Fortran.
Is that possible?
How would I tell me Fortran code where to find those routines?
Here’s a diagram for what I’d like to do:
main (in R) -> f1 (in Fortran, C or CPP) -> C_dnorm (in C)
main (in R) -> f2 (in Fortran, C or CPP) -> cpp_dgev (in CPP)
As a first step, I’ve tried to see if I can call the C_dnorm code directly from R, using:
.Call(C_dnorm(1))
But that doesn’t work.