Is it possible in R to call a fortran routine that sets variables in a common block and expect the values to persist when a call is made from R to a second routine that uses the common block? If not (as I suspect), is it possible to use a common block in a group of routines that are used together, for as long the routines do not return to R? Paul =================================================================================== La version française suit le texte anglais. ------------------------------------------------------------------------------------ This email may contain privileged and/or confidential information, and the Bank of Canada does not waive any related rights. Any distribution, use, or copying of this email or the information it contains by other than the intended recipient is unauthorized. If you received this email in error please delete it immediately from your system and notify the sender promptly by email that you have done so. ------------------------------------------------------------------------------------ Le présent courriel peut contenir de l'information privilégiée ou confidentielle. La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion, utilisation ou copie de ce courriel ou des renseignements qu'il contient par une personne autre que le ou les destinataires désignés est interdite. Si vous recevez ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre ordinateur toute copie du courriel reçu. [[alternative HTML version deleted]]
On 06/05/2011 11:04 AM, Paul Gilbert wrote:> Is it possible in R to call a fortran routine that sets variables in a common block and expect the values to persist when a call is made from R to a second routine that uses the common block?I think the stats package does this; see src/library/stats/src/ppr.f. The Fortran functions don't "know" that R is doing the calling, so they'll set and read values as if they were called from a Fortran main program. Duncan Murdoch> If not (as I suspect), is it possible to use a common block in a group of routines that are used together, for as long the routines do not return to R? > > Paul > ===================================================================================> > La version fran??aise suit le texte anglais. > > ------------------------------------------------------------------------------------ > > This email may contain privileged and/or confidential information, and the Bank of > Canada does not waive any related rights. Any distribution, use, or copying of this > email or the information it contains by other than the intended recipient is > unauthorized. If you received this email in error please delete it immediately from > your system and notify the sender promptly by email that you have done so. > > ------------------------------------------------------------------------------------ > > Le pr??sent courriel peut contenir de l'information privil??gi??e ou confidentielle. > La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion, > utilisation ou copie de ce courriel ou des renseignements qu'il contient par une > personne autre que le ou les destinataires d??sign??s est interdite. Si vous recevez > ce courriel par erreur, veuillez le supprimer imm??diatement et envoyer sans d??lai ? > l'exp??diteur un message ??lectronique pour l'aviser que vous avez ??limin?? de votre > ordinateur toute copie du courriel re??u. > > [[alternative HTML version deleted]] > > > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Paul Gilbert wrote:> > Is it possible in R to call a fortran routine that sets variables in a > common block and expect the values to persist when a call is made from R > to a second routine that uses the common block? > > If not (as I suspect), is it possible to use a common block in a group of > routines that are used together, for as long the routines do not return to > R? > > Paul >Don't see why not--should be pretty easy to test. Personally, I would use variables in a Fortran 90 module over a common block. -Charlie ----- Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/fortan-common-block-tp3503204p3506373.html Sent from the R devel mailing list archive at Nabble.com.
On Fri, May 6, 2011 at 4:04 PM, Paul Gilbert <pgilbert at bank-banque-canada.ca> wrote:> Is it possible in R to call a fortran routine that sets variables in a common block and expect the values to persist when a call is made from R to a second routine that uses the common block? > > If not (as I suspect), ?is it possible to use a common block in a group of routines that are used together, for as long the routines do not return to R?Simple test seems to confirm it. Here's some 'tran with a setter and a getter: comchk.f: subroutine bar(n) common /c/ i i=n end subroutine geti(j) common /c/ i j = i end R CMD SHLIB comchk.f > dyn.load("comchk.so") > .Fortran("bar",as.integer(9)) [[1]] [1] 9 > .Fortran("geti",as.integer(-1)) [[1]] [1] 9 Barry