guys. I am trying to read a scientific datum file stored by a VAX FORTRAN code. The data were stored in structure, of which the file and code descriptions are as follows. I googled that FORTRAN 77 might read the file, but my frequently used language is not FORTRAN. So can some one tell me how to read the data into a FORTRAN or C/IDL/etc. variables? For example, N units of the structure are stored in file "pxm.mos", how can I read the data into my variables? Thanks a lot! Here are the descriptions.
c FILE name is "pxm.mos"
c FILE AND RECORD STRUCTURE
c The files were created with form='unformatted', organization='sequential',
c access='sequential', recordtype='fixed', recordsize=512.
c The following VAX FORTRAN code specifies the record structure:
structure /PXMstruc/
union
map
integer*4 buffer(512)
end map
map
integer*4 mod16
integer*4 mod60
integer*4 line
integer*4 sct
integer*4 mfdsc
integer*4 spare(3)
real*4 datamin
real*4 datamax
real*4 data(0:427)
end map
end union
end structure
record /PXMstruc/ in
This isn't hard. You can think of structure like a C struct, with unions. Each record is 2048 bytes (512 "longwords" in VAX terms) and consists of five 32-bit ints, an array of 3 ints for padding, two 32-bit floats and then an array of 428 floats. Given that the file is fixed length, there's no metadata to worry about. The union with "buffer" can be ignored.
I would be more concerned about how the file made its way to your computer, assuming it originated on a VMS system. You'll want to verify that the file size is an exact multiple of 2048 bytes. Most likely it transferred just fine, so declare a struct with the right layout and read it in, record by record.