Hi all, I'm having problems trying to export binary arrays from R and importing them into fortran (linux openSUSE 10.3 (x86_64), gfortran compiler, fortran 90/95 program).
Let's say the problem can be expressed as: R part ------------ >whini <- runif(1000) >writeBin(whini,"fwhini.dat") f90 part ------------ PROGRAM foo INTEGER, PARAMETER :: DP = KIND(1.0D0) INTEGER :: status REAL(DP), DIMENSION(10,100) :: whini OPEN(UNIT=5, FILE='fwhini.dat', STATUS='OLD', ACTION='READ', & FORM='UNFORMATTED', IOSTAT=status) READ(5) whini CLOSE(5) WRITE(*,*) whini END PROGRAM Now, if within the R session I check >typeof(whini) [1] "double" and try >whini.copy <- readBin("fwhini.dat",what=double(),n=1000) the copy of whini is right. However, execution of the fortran program gives the message: Fortran runtime error: Unformatted file structure has been corrupted. I've tried also to declare whini in the fortran part as SINGLE precision, and to force writeBin using the "size" argument. size=4 and size=8 give the same error (whini as double in the fortran part), while size=16 gives the alternative error "Fortran runtime error: I/O past end of record on unformatted file" Please, could you help me with this problem? Thanks, Javier --- ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.