If you are strictly not looking to use available libraries, it is fairly straightforward to do that using Fortran. I have copied below the code that I use to parse LAMMPS dump files, and it processes one frame at a time.
program coordination implicit none ! declare buffers double precision, allocatable :: c(:,:), q(:) integer, allocatable :: aindex(:), atype(:) character(len=2), allocatable :: aname(:) ! declare variables double precision :: ax, ay, az double precision :: dx, dy, dz double precision :: wx, wy, wz double precision :: xl, yl, zl double precision :: xh, yh, zh double precision :: xx, yy, zz integer :: ia, ib, ic integer :: na character(len=80) :: ifile ! get input file name call get_command_argument(1, ifile) open (unit = 10, file = ifile, status = "old", action = "read") ! here 20001 is the total number of frames in my LAMMPS dump file do ia = 1, 20001 read (10, *) read (10, *) read (10, *) read (10, *) na read (10, *) read (10, *) xl, xh read (10, *) yl, yh read (10, *) zl, zh read (10, *) ! allocate buffers at each frame allocate (c(na, 3)) allocate (aindex(na)) allocate (atype(na)) allocate (aname(na)) allocate (q(na)) do ib = 1, na read (10, *) aindex(ib), atype(ib), aname(ib), (c(ib, ic), ic = 1, 3), q(ib) end do free(c) free(q) free(aindex) free(atype) free(aname) end do
Here I am reading a LAMMPSTRJ file with the following data dumped for each atom: index, type, element name, coords and charge.