This is part of the generic module

Dump masses and charges on a selected file.

This command dumps a file containing charges and masses. It does so only once in the simulation (at first step). File can be recycled in the driver tool.

Notice that masses and charges are only written once at the beginning of the simulation. In case no atom list is provided, charges and masses for all atoms are written.

The atoms involved can be specified using
ATOMS the atom indices whose positions you would like to print out. For more information on how to specify lists of atoms see Groups and Virtual Atoms
Compulsory keywords
STRIDE ( default=1 ) the frequency with which the atoms should be output
FILE file on which to output coordinates. .gro extension is automatically detected

You can add the DUMPMASSCHARGE action at the end of the plumed.dat file that you use during an MD simulations:

c1: COM ATOMS=1-10
c2: COM ATOMS=11-20
PRINT ARG=c1,c2 FILE=colvar STRIDE=100


(see also COM and PRINT)

In this way, you will be able to use the same masses while processing a trajectory from the driver . To do so, you need to add the –mc flag on the driver command line, e.g.

plumed driver --mc mcfile --plumed plumed.dat --ixyz traj.xyz

With the following input you can dump only the charges for a specific group.

solute_ions: GROUP ATOMS=1-121,200-2012
DUMPATOMS FILE=traj.gro ATOMS=solute_ions STRIDE=100

Notice however that if you want to process the charges with the driver (e.g. reading traj.gro) you have to fix atom numbers first, e.g. with the script

awk 'BEGIN{c=0}{
  if(match($0,"#")) print ; else {print c,$2,$3; c++}
}' < mc > newmc


plumed driver --mc newmc --plumed plumed.dat --ixyz traj.gro