Read & write data files b/w IDL & Fortran 90 [message #39062] |
Thu, 08 April 2004 13:33 |
bridgemat
Messages: 6 Registered: August 2003
|
Junior Member |
|
|
As someone who knows just the basics of IDL and the basics plus a bit
more of Fortran 90, I'm sure this is just some rookie mistake, so
hopefully someone out there can help me out.
I'm trying to write an idl array to a file, read the file in Fortran
90, manipulate the Fortran array, and then write that new array to a
file that I then read into IDL. Here's how I write the original array
to a file:
test=indgen(3,4,5)
openw,lun,'testidl.dat',/get_lun
writeu,lun,test
free_lun,lun
Then I try to run this Fortran 90 program:
PROGRAM testidl
INTEGER::in=3,out=6
INTEGER,DIMENSION(3,4,5)::arr_in,arr_out
OPEN(UNIT=in,FORM="UNFORMATTED",FILE="testidl.dat")
OPEN(UNIT=out,FORM="UNFORMATTED",FILE="testf90.dat",STATUS= "REPLACE")
READ (UNIT=in) arr_in
arr_out=arr_in*2
WRITE (UNIT=out) arr_out
END PROGRAM
It compiles (pgf90), but I get this error when I run it:
PGFIO-F-217/unformatted read/unit=3/attempt to read past end of file.
This is my first time dealing w/ unformatted files. Needless to say, I
don't even get to try out the last part of my scenario - reading the
file w/ the new array into IDL.
Another issue: array dimensions! My IDL book tells me that both IDL
and Fortran arrays are column-major. Although I've been using Fortran
longer than IDL, I haven't done much w/ multi-dimensional arrays, so I
looked in my Fortran book, and it says that Fortran is row-major!
Ack!!! So does that mean my Fortran array should be declared as
DIMENSION(5,4,3) in this case? I tried that, too, but got the same
error...
Sorry to be so long-winded!
-Bridget
|
|
|