Problems about using compute chunk/atom to find certain number of atom in region

Dear lammps Users

I use the lammps version of lammps-30Jul16.
The problem I need to do is that:
I tried to find a certain number of atoms in a region and change their atom type every loop. In my system, every atom is assigned a different molecule id, starting from 1.
The commands inside the loop I used is partially listed below:

Dear lammps Users

I use the lammps version of lammps-30Jul16.

​when reporting potential bugs in LAMMPS, please always test with the
latest development version (17 March 2017, right now).
LAMMPS is continuously improved and bugs are fixed, so you have to verify
that you are not reporting an issue that has already been addressed.

thanks for your understanding,
     axel.​