[Rd] LOGICAL arguments in FORTRAN code

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 8 13:40:45 CEST 2010

On Thu, 8 Apr 2010, Berwin A Turlach wrote:

> G'day all,
> I just took over maintenance of the quadprog package from Kurt Hornik
> and noticed that one of the FORTRAN routines has an argument that is
> declared to be a LOGICAL.  The R code that calls this routine (via
> the .Fortran interface) passes the argument down wrapped in a call to
> as.logical().
> This was fine (and as documented) under S-Plus 3.4, for which this code
> was originally developed.  However, as far as I know, in R objects of
> storage mode logical were always supposed to be passed to FORTRAN
> arguments of type INTEGER; and that is what the current "Writing R
> extension manual states".
> Thus, given that the port of quadprog existed for quite some time, I
> am wondering whether it is o.k. to pass R objects with storage mode
> logical into FORTRAN code to arguments declared as LOGICAL?  Or should
> the FORTRAN code be corrected to declare the argument in question as

The second to be safe.  This is not a question on the S-PLUS/R side 
but on the Fortran side.  A Fortran compiler may or may not use the 
same storage for integer and logical (and it may depend on compiler 
flags, although not on the compilers I just checked, gfortran and 
SunStudio f95).  S-PLUS ran on only a few platforms and with specified 

> Cheers,
> 	Berwin
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-devel mailing list