[R] Graceful exit from fortran. (fwd)

Jari Oksanen jarioksa at cc.oulu.fi
Tue Oct 2 08:34:20 CEST 2001


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list