rolf at math.unb.ca said:> If I say something like > if(x .gt. 42.d0) stop > then indeed everything stops, i.e. R falls over. I'd ***like*** to be > able to print out an informative error message (which I guess could be > done -In Fortran: subroutine foo(..., ier) integer ier ier=0 ... if (x .gt. 42.d0) then ier=1 return endif ... return end In R: foo <- .Fortran("foo", ..., ier=integer(1)) if(foo$ier) stop("error: x > 42") By the way, is the following allowed in Windows with mignw32 g77: subroutine topen(filename) character*255 filename open(unit=1, file=filename, status='old') return end subroutine tread(line) character*255 line read(1, *) line return end This seems to work magically when linked to R in Linux (RH7.1, gcc "2.96" g77), but one friend of mine told it crashes R when linked to Windows R. I don't have Windows R with building tools anywhere I know, so I am not sure if this is the cause of the failure. cheers, jari oksanen - -- Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland Ph. +358 8 5531526, cell +358 40 5136529, fax +358 8 5531061 email jari.oksanen at oulu.fi, homepage http://cc.oulu.fi/~jarioksa/ ------- End of Forwarded Message -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 Tue, 2 Oct 2001, Jari Oksanen wrote:> > rolf at math.unb.ca said: > > If I say something like > > if(x .gt. 42.d0) stop > > then indeed everything stops, i.e. R falls over. I'd ***like*** to be > > able to print out an informative error message (which I guess could be > > done - > > > In Fortran: > > subroutine foo(..., ier) > integer ier > ier=0 > ... > if (x .gt. 42.d0) then > ier=1 > return > endif > ... > return > end > > In R: > > foo <- .Fortran("foo", ..., ier=integer(1)) > if(foo$ier) stop("error: x > 42")(Rolf wanted it from a deeply nested subroutine. This is now solved in R-devel: see its NEWS file.)> By the way, is the following allowed in Windows with mignw32 g77: > > subroutine topen(filename) > character*255 filename > open(unit=1, file=filename, status='old') > return > end > > subroutine tread(line) > character*255 line > read(1, *) line > return > end > > This seems to work magically when linked to R in Linux (RH7.1, gcc > "2.96" g77), but one friend of mine told it crashes R when linked to > Windows R. I don't have Windows R with building tools anywhere I know, > so I am not sure if this is the cause of the failure.The cause of the failure is that you declared a fixed-length 255 character string and did not pass one! You were lucky it worked anywhere. It is more correct Fortran (and more portable) to declare character*(*) in your examples. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._