G'day Dominick, On Mon, 5 Mar 2012 19:21:01 -0500 Dominick Samperi <djsamp...@gmail.com> wrote:
> Section 5.2 of the R manual (on Extending R) says that only > FORTRAN subroutines can be called (not functions), probably > because of the non-standard way the compilers map FORTRAN > function names to symbols in the DLL. Section 5.2 deals with calling C/FORTRAN code from R via .C() or .Fortran(), and is not directly relevant to the question on how to call FORTRAN code from C code. :) > This is consistent with the interface prototype for the BLAS > routine zdotc contained in <R>/include/R_ext/BLAS.h, namely, > > BLAS_extern Rcomplex > F77_NAME(zdotc)(Rcomplex * ret_val, int *n, > Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); > >[...] > > On the other hand, this is not consistent with the standard > FORTRAN definition for zdotc that is contained in > <R>/src/extra/blas/cmplxblas.f, where the first argument is > n, not ret_val. This seems to be indeed inconsistent and, presumably, a bug. Applying the attach patch to R's development version (compiles, installs and passes all checks with this patch), and changing in your code the line F77_CALL(zdotc)(&ret_val, &n, zx, &incx, zy, &incy); to ret_val = F77_CALL(zdotc)(&n, zx, &incx, zy, &incy); produces the expected output. > Consequently, it is not clear where the wrapper > is defined that is called via the prototype. The F77_xxxx macros seem to be defined in <R>/include/R_ext/RS.h, and their sole purpose seems to be to append a _ to the argument if needed. Cheers, Berwin
Index: src/include/R_ext/BLAS.h =================================================================== --- src/include/R_ext/BLAS.h (revision 58604) +++ src/include/R_ext/BLAS.h (working copy) @@ -245,10 +245,10 @@ F77_NAME(zcopy)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); BLAS_extern Rcomplex - F77_NAME(zdotc)(Rcomplex * ret_val, int *n, + F77_NAME(zdotc)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); BLAS_extern Rcomplex - F77_NAME(zdotu)(Rcomplex * ret_val, int *n, + F77_NAME(zdotu)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); BLAS_extern void F77_NAME(zdrot)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, Index: doc/manual/R-exts.texi =================================================================== --- doc/manual/R-exts.texi (revision 58604) +++ doc/manual/R-exts.texi (working copy) @@ -12229,7 +12229,7 @@ The @R{} for Windows installers have for a long time allowed the value of @code{R_HOME} to be recorded in the Windows Registry: this is -optional but selected by default. @emph{Where} is it is recorded has +optional but selected by default. @emph{Where} it is recorded has changed over the years to allow for multiple versions of @R{} to be installed at once, and to allow 32- and 64-bit versions of @R{} to be installed on the same machine.
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel