Selection in control volume

GROMACS version: 2021
GROMACS modification: Yes/No


I am trying to perform a selection based on a control volume, i.e. I provide the whole trajectory to gmx select and get in the index file a group for each frame, corresponding to the molecules in the control volume at that frame.

Now, I would like to output a trajectory with the molecules occupying the control volume at each frame; it is possible to do it automatically with gmx trjconv? I believe one way to go could be:

for n from 1 to N_frames :
echo <n> | gmx trjconv -f ... -s ... -n control_volume.ndx -dump <n> -b <n-1> -o ...

and the concatenate the all output files, but that is quite slow (I got 4000 frames and the trajectory weight almost 100G); is there a way to made trjconv change selection group at each frame automatically?