I'm reading a binary file and in the binary file I have integer and real arrays which are supposed to be 8 byte integers as in the documentation concerning the binary file.
So, I have the follwoing code;
integer*8 geom_data(512) !Declaration of array to be read from the binary file
open(unit=1,file=my_file_name,status='old',form='unformatted',access='direct',recl=512*8)
read(1,rec=record_no)geom_data
.......
This works ok.
But now after testing several test cases, I'm encountering a couple of test cases where the binary file has the integer and real arrays of 4 bytes.
So, the above code reads correctly if I have:
integer*4 geom_data(512) !Declaration of array to be read from the binary file
open(unit=1,file=my_file_name,status='old',form='unformatted',access='direct',recl=512*4
That is, I declare geom_data as 4 bytes. Can anyone help/advise such that the reading is done correctly whether the integer happens to be 8 or 4 bytes in the binary file?
Please help..
Christy