[Rd] LOGICAL arguments in FORTRAN code

Berwin A Turlach berwin at maths.uwa.edu.au
Thu Apr 8 15:11:32 CEST 2010


G'day Brian, 



On Thu, 8 Apr 2010 12:40:45 +0100 (BST)
Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

> On Thu, 8 Apr 2010, Berwin A Turlach wrote:
[...]
> > 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 INTEGER?
> 
> The second to be safe.  [...]

Thanks for the quick and informative response.  I will make the
necessary changes.

BTW, can I assume that if R passes down TRUE to the FORTRAN routine the
corresponding integer argument will be set to 1, and that it will be
set to zero if FALSE is passed down?  Likewise, can I assume that if at
the end of the FORTRAN routine the integer holds a value of zero, then
FALSE is passed back to R and if the integer holds any other value then
TRUE is passed back?  I don't remember ever reading any documentation
about this; and most documentation that I would search is not at hand
but back on the bookshelves of my office.....

Cheers,
	
	Berwin



More information about the R-devel mailing list