On Thu, 21 Jun 2001, Thomas Dick wrote:> Hello, > > I try to use a Windows DLL with FORTRAN routines in R. All routines work fine, > except those which exchange a character variable with R. > > The documentation "Writing R Extensions" says it''s compiler dependent whether > character string exchange works with FORTRAN routines or not. > > Why doesn''t it work with every compiler?Why should it? Why should the designer of a Fortran compiler anticipate that Thomas Dick would want to call subprograms from a C routine and pass in C character strings, and then spend time writing code to meet his wishes?> Does anyone know a FORTRAN90 compiler for windows that works?No. Not even the matching g77 works. *But* translation by f2c will work. Otherwise write a wrapper in Fortran that avoids having to pass character variables around. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, I try to use a Windows DLL with FORTRAN routines in R. All routines work fine, except those which exchange a character variable with R. The documentation "Writing R Extensions" says it''s compiler dependent whether character string exchange works with FORTRAN routines or not. Why doesn''t it work with every compiler? Does anyone know a FORTRAN90 compiler for windows that works? Thank you, Thomas Dick -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 21 Jun 2001 09:25:51 +0100 (BST), Prof Brian D Ripley <ripley at stats.ox.ac.uk> wrote:>Otherwise write a wrapper in Fortran that avoids having to pass character >variables around.More specifically: Thomas needs a routine to translate R character variables into Fortran character strings, and a routine to translate them back. R isn''t doing anything very strange, so the first of these is probably provided by a library routine for your compiler. Look in the manual under "Interfacing to C" or something similar. To translate strings back, you need to be sure to allocate the memory in the R memory space, using the R_alloc routine from R.dll. I doubt if this will help him much, but maybe it''ll help someone else: The translations you are talking about go like this in Delphi: 1. R character variables are arrays of pchar in Delphi. Delphi knows how to convert pchars to Delphi strings automatically. 2. The routine Rpchar translates Delphi strings to R character variables: function R_alloc(n,size:integer):pchar; cdecl; external ''R.dll''; function Rpchar(s:string):pchar; begin result := R_alloc(1,length(s)+1); strpcopy(result,s); end; Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._