I find it particularly difficult reading the binary file with Python. Can you give me a hand? I need to read this file, which in Fortran 90 is easily read by
int*4 n_particles, n_groups
read (*) n_particles, n_groups
read (*) (group_id(j),j=1,n_particles)
In detail, the file format is:
Bytes 1-4 -- The integer 8.
Bytes 5-8 -- The number of particles, N.
Bytes 9-12 -- The number of groups.
Bytes 13-16 -- The integer 8.
Bytes 17-20 -- The integer 4*N.
Next many bytes -- The group ID numbers for all the particles. Last 4 bytes -- The integer 4*N.
How can I read this with Python? I tried everything but it never worked. Is there any chance I might use an f90 program in python, reading this binary file and then save the data that I need to use?