[R] .Fortran()

Jari Oksanen jarioksa at cc.oulu.fi
Wed Oct 10 08:46:48 CEST 2001

I have had a related conversation about .Fortran with Brian Ripley 
(undercover), and I have learnt some valuable things, for instance 
about English language. As a non-English speaking person I had hastily 
assumed that `may' in ?.Fortran is more or less synonymous with `can', 
but it seems that it rather is synonymous with `may not'. Now I have 
two new valuable pieces of information:

ripley at stats.ox.ac.uk said:
> A properly working version of g77 should work on some platforms
> (including Linux), but not others (including Windows).

This explains why my plug-in Fortran library worked in Linux (RH7.1, 
with gcc updates), but not when my mate tried that in Windows.

And this is the second piece:

ripley at stats.ox.ac.uk said:
> BTW, no one said Fortran I/O would work, and it sometimes is a
> problem.

This means that I have a problem. Does anybody here have a solution?

My problem is that there are plenty of legacy files in our field which 
are written with so-called Cornell Ecology Programs (CEP) formats. 
These are Fortran formatted files, and the actual format used is 
written in the file (on its second line, or, I should say, `card'). I 
thought that a nice solution was to write a Fortran program[me] to read 
these files and pass the data and row and column names back to R which 
then makes these into a data.frame. It was surprisingly easy and worked 
beautifully in Linux, but crashed R in Windows. I made a small test 
package in Fortran which made nothing but opened a file and read a 
line. This crashed in Windows (I don't have access to Windows, so these 
tests were made in Florida, and I never saw what happened). So it seems 
that this is not portable. Now comes the question (finally, I hope 
somebody got this far): Is there a R pluggable module to interpret 
Fortran format (which may be tricky), so that I could read these lines 
with plain C or plain R? (I once made a similar program[me] using 
Scientific Python module in Python, but that was much more tricky than 
using direct Fortran, and failed in some test files).

Another alternative is to let it be and make a separate stand-alone 
program to change these files into, say, csv and then read them into R. 
However, it was so nice when I suddenly had access to tens of my old 
files within an R session, and I would like other people to share my 
joy (sounds like a cheap thrill). Naturally, this works now in my 
system, so my concern is rather abstract.

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/

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