From berwin at maths.uwa.edu.au  Thu Apr  8 15:11:32 2010
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Thu, 8 Apr 2010 21:11:32 +0800
Subject: [Rd] LOGICAL arguments in FORTRAN code
In-Reply-To: <alpine.LFD.2.00.1004081231530.21500@gannet.stats.ox.ac.uk>
References: <20100408183235.4185aa65@bossiaea>
	<alpine.LFD.2.00.1004081231530.21500@gannet.stats.ox.ac.uk>
Message-ID: <20100408211132.7a2ca4fd@absentia>

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



[Rd] LOGICAL arguments in FORTRAN code
Berwin A Turlach