Displaying 20 results from an estimated 4000 matches similar to: "Good practice for packages with Fortran and C code"
2024 Oct 25
1
Good practice for packages with Fortran and C code
? Fri, 25 Oct 2024 15:03:54 -0500
fh at fharrell.com ?????:
> Now I find that I can get rid of init.c, and change NAMESPACE to use
> useDynLib(package name, list of compiled routine names) (without
> .registration and .fixes) after making sure the Fortran and C
> routines are not named the same as the package name. The routines
> are called using .Fortran(binary module name,
2019 Feb 02
1
Set the number of threads using openmp with .Fortran?
I got this to work on Linux but it is not working on Windows. *My
understanding is that this should also work on windows, is that correct?*
If so, what should I do? differently?
To get it to work on Linux, I modified my R script as follows:
#' OpenMP Hello World
#'
#' @param nthreads The number of threads that you want to use
#' @example
#' hello(nthreads=2)
#' @export
2019 Feb 01
2
Set the number of threads using openmp with .Fortran?
Hi everybody,
I'm trying to develop an R package with Fortran and OpenMP. I wrote a
simple hello world but I'm not able to set the number of threads. I found this
old email chain
<http://r.789695.n4.nabble.com/Set-the-number-of-threads-using-openmp-with-C-td2284685.html>
and
I tried to set my compile instructions accordingly but i had no luck.
*This is my makevars:*
2009 Jun 24
2
loadNamespace and useDynLib
I am considering a package with a namespace (Rgraphviz from Bioc). I
essentially want to have some error handling for loading the dll,
something like wrapping it into tryCatch or similar (reason: see
below). Right now I am loading the dynamic libraries by useDynLib in
my NAMESPACE file. When I look at the code from loadNamespace, I have
the impression that what I want is impossible
2011 Apr 20
3
useDynLib in older versions e.g. (2.10)
Hi,
Has something changed regarding the useDynLib in the NAMESPACE file in
packages? I've written a package that works in e.g. 2.12/2.13 but simply
cannot find the dynamic library under windows. The version on CRAN is
older than the one I'm talking about and depends on a newer version of R
but I want to make the package available to people with older versions.
>
2004 Aug 04
1
installing package with version number using namespaces & dynamic library
Hi,
I wonder whether a package with namespace & dynamic library can be installed
with the version number attached, ie. with the argument --with-package-versions.
Is this currently possible?
Using R 1.9.1 on Debian 3.0 I encounter a problem when trying to load a package
installed with
R91 CMD INSTALL --with-package-versions -l /mnt/local/R/R-1.9.x-libs-EpiR RIO
in R started with
R91
2017 May 09
2
registering Fortran routines in R packages
Dear list,
I?m trying to register Fortran routines in randtoolbox (in srt/init.c file), see https://r-forge.r-project.org/scm/viewvc.php/pkg/randtoolbox/src/init.c?view=markup&root=rmetrics.
Reading https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines and looking at what is done in stats package, I first thought that the following code will do the job:
2004 Sep 19
1
Namespace problem
Now I try to add some C and Fortan code to my package, so the NAMESPACE
file is
useDynLib(eha)
importFrom(survival, Surv)
export(mlreg.fit, risksets)
but I get
.....
* checking R files for library.dynam ... OK
* checking S3 generic/method consistency ... WARNING
Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) :
2009 May 22
2
Step by step: Making an R package with Fortran 95
To all. I need your help. The big question is: How do I make an R library
with Fortran 95 files? You may assume that I am a pretty decent programmer
in both R and Fortran. I lay out a scenario and need your help!
I know how to make an ordinary R package and have dabbled with R + Fortran
95 *.dll linking. I do not have a great handle on the whole Makevars file
and whatever else I might need
2017 May 09
0
registering Fortran routines in R packages
> On 9 May 2017, at 13:44, Christophe Dutang <dutangc at gmail.com> wrote:
>
> Dear list,
>
> I?m trying to register Fortran routines in randtoolbox (in srt/init.c file), see https://r-forge.r-project.org/scm/viewvc.php/pkg/randtoolbox/src/init.c?view=markup&root=rmetrics.
>
> Reading
2006 Dec 19
1
precision when calling a C function; presence of Fortran call
I'm trying to figure out why the presence of a Fortran call affects the
result of a floating-point operation. I have C functions
void test1(int *n, double *f){
int outC;
double c0;
c0 = (double) *n * *f;
outC = floor(c0);
printf("when f computed by R, C says %d by itself\n",outC);
}
void test2(int *n, double *f){
extern int F77_NAME(ifloor)(double *);
int
2011 Jun 03
2
Checking and building package
Hello!
I am truing to compile an R-package having c-code. I put foo.c in src/
folder and useDynLib("foo") in NAMESPACE file. When trying R CMD check,
I got an error message that shared object 'foo' is not found. Then I did
R CMD SHLIB foo.c first. However, after that, I got warnings from R CMD
check that there is an object file in /src folder. Even worse is if I
run R CMD
2016 Jun 30
2
Calling C implementations of rnorm and friends
Hi all,
Looking at the body for the function rnorm, I see that the body of the
function is:
.Call(C_rnorm, n, mean, sd)
I want to implement functions that generate normal (and other) random
variables. Now, I understand that I can perfectly well just call the R
wrapper for these functions and that will be almost indistinguishable for
most purposes, but for whatever reason I wanted to try and
2010 Nov 12
1
unloading compiled code.
I have a package that I'm developing that I need to unload the
library. Long story short I figured out that the leaving the compiled
code loaded lead to a segmentation fault, but unloading the code will
fix it. I've read the documentation and it appears that there are
several ways to do this? What is the popper accepted current standard
for unloading compiled code?
The options as I
2017 May 10
3
registering Fortran routines in R packages
Thanks for your email.
I try to change the name in lowercase but it conflicts with a C implementation also named halton. So I rename the C function halton2() and sobol2() while the Fortran function are HALTON() and SOBOL() (I also try lower case in the Fortran code). Unfortunately, it does not help since I get
init.c:97:25: error: use of undeclared identifier 'halton_'; did you mean
2004 Jul 08
1
building packages with NAMESPACE
hi!
I tried to build a very simple package with NAMESPACE file,
such that datasets are loaded only dynamically.
> a2 <- function(x=a1) x+4
> a1 <- 1:10
> package.skeleton("aaa", list=c("a1", "a2"))
Then I modified the help files and added the file NAMESPACE with these
2 lines:
useDynLib(aaa)
export(a1, a2)
Then "R CMD BUILD aaa" works
2004 Jul 05
1
passing char's from C to Fortran (mac os x)
Hello All,
In some package I use a c-routine which calls a fortran routine which
expects a char-string as input.
As per the writing R-extensions manual,
the Fortran routine is declared in C as:
void F77_NAME (setoptions) (char **option);
and then it is calles as follows:
char **option;
option = new char*[1];
option[0] = new char[256];
option[0] = strcpy(option[0],"Iteration
2009 May 27
1
"Error: package/namespace load failed"
I am writing my first R package, and I have been getting the following series of errors when I run R CMD check:
* checking S3 generic/method consistency ... WARNING
Error: package/namespace load failed for 'REEMtree'
Call sequence:
2: stop(gettextf("package/namespace load failed for '%s'", libraryPkgName(package)),
call. = FALSE, domain = NA)
1: library(package,
2017 Feb 14
6
Registration of native routines
Registration of 'native routines' (entry points in compiled code loaded
into R) has been available for over 14 years, but few packages make use
of it (less than 10% of those on CRAN with compiled code).
Registration has similar benefits to name spaces in R code:
- it ensures that the routines used by .C, .Call etc are those in your
package (without needing a PACKAGE argument).
- it
2023 Feb 13
1
An interesting chat with ChatGPT
I was wondering which anchor would match in the regular expression
"(a)|(b)" if both "a" and "b" matches the target string. What appears
to happen is that the first match wins, and that's how it is documented
in Python, but I was looking for docs on this in R.
As far as I can see, the ?regex help page doesn't resolve this. So just
for fun, I decided to