kosa
kosa

Reputation: 66657

R calling Fortran subroutine

I understood that .Fortran from following code invokes Fortran subroutine, but why we are using C_ for subroutine name here? Few other subroutine calling examples I looked over internet are simply "stl", can someone please help me with why C_stl instead of stl?

 z <- .Fortran(C_stl, x, n,
          as.integer(period),
          as.integer(s.window),
          as.integer(t.window),
          as.integer(l.window),
          s.degree, t.degree, l.degree,
          nsjump = as.integer(s.jump),
          ntjump = as.integer(t.jump),
          nljump = as.integer(l.jump),
          ni = as.integer(inner),
          no = as.integer(outer),
          weights = double(n),
          seasonal = double(n),
          trend = double(n),
          double((n+2*period)*5))

Upvotes: 1

Views: 571

Answers (2)

Hong Ooi
Hong Ooi

Reputation: 57696

C_stl is an object in the stats package containing auxiliary information about the Fortran subroutine. It's not exported, so to see it you'll have to type stats:::C_stl.

> stats:::C_stl
$name
[1] "stl"

$address
<pointer: 0x000000000f87b950>
attr(,"class")
[1] "RegisteredNativeSymbol"

$dll
DLL name: stats
Filename: E:/apps/R/R-3.1.1/library/stats/libs/x64/stats.dll
Dynamic lookup: FALSE

$numParameters
[1] 18

attr(,"class")
[1] "FortranRoutine"   "NativeSymbolInfo"

Upvotes: 1

Bhas
Bhas

Reputation: 1834

After a lot of searching I believe I found the answer. Look in the the NAMESPACE file in the directory <path to R sources>/src/library/stats.

You'll see that all C/Fortran routines are referred to with names prefixed with C_, This appears to be done by useDynLib.

Upvotes: 1

Related Questions