Hello Duncan,  

Thanks for the reply. I tried your command, and I got "raw(0)" in response…

However, your response that I was on the right track was in fact very helpful, since I went back to my "header" file and found that the problem was the transfer from the Ubuntu instrument to my Mac. Now, my "header" file has a logical size (larger than 0), and I'm seeing output from readBin.

So, thanks so much! : )

Cheers,

Jooil  

--  
Jooil Kim
Postdoc Fellow
Scripps Institution of Oceanography, UC San Diego
Mailing address:
9500 Gilman Drive # 0244
La Jolla, CA 92093-0244, USA
For FedEx/UPS:
8675 Discovery Way, Vaughan Hall Rm. 447
La Jolla, CA 92037, USA



On Wednesday, February 15, 2012 at 2:41 AM, Duncan Murdoch wrote:

> On 12-02-14 10:58 PM, Jooil Kim wrote:
> > Hello,
> >  
> > I'm wondering if I can get some help with reading Fortran binary "unformatted" output files into R.
> >  
> > The Fortran output files were generated in Ubuntu 10.04 LTS using gfortran4.4, on a 32bit Intel Core 2 Duo 3.16 GHz machine, with little-endian and record marker lengths equal to 4.
> >  
> > The machine I'm currently trying to read this Fortran output file is a Macbook Pro running Lion 10.7.3, on a 2.26 GHz Intel Core 2 Duo with 4Gb of ram. I'm running R 2.14.1.
> >  
> > Based on whatever information I could gather from the web, I've been trying out the following code (the name of the Fortran output file is "header", located in the current working directory).
> >  
> > > to.read<- file("header", "rb")
> > > readBin(to.read, "integer", n=2, size = 4, endian = "little")
> > >  
> >  
> >  
> > Unfortunately, these commands return empty.
> >  
> > Am I on the right track here? Is what I'm trying to accomplish here even technically possible?
>  
> Yes, that should have worked. To debug, I'd replace your second line with
>  
> readBin(to.read, "raw", n=100)
>  
> For example, when I create a file by writing out 1:10 using writeBin,  
> that gives
>  
> > readBin(to.read, "raw", n=100)
> [1] 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00
> [20] 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0a 00
> [39] 00 00
>  
> from which it is pretty obvious the file contains small integers in  
> little endian form. Paul Murrell's hexView package gives more elaborate  
> possibilities.
>  
> Duncan Murdoch  


	[[alternative HTML version deleted]]

