[lammps-users] compute temperature and number of atoms

Dear lammps users,

I wrote a new fix and it requires that I calculate the temperature and the number of atoms for a particular region in space. The attached code (below) is part of this fix. Tph[iregion] stores the value of the temperature and I want to store the number of atoms in that region in natoms[iregion]; i can compile the code fine, but when I run it I get the error: Reuse of compute ID.

Any suggestions are appreciated.

thanks
Jaime

  int n = strlen(id) + 6;
   char *id_temp = new char[n];
   strcpy(id_temp,id);
   strcat(id_temp,"_temp");
   char **newarg = new char*[4];
   newarg[0] = id_temp;
   newarg[1] = group->names[igroup];
   newarg[2] = "temp/region";
   newarg[3] = domain->regions[iregion]->id;
   modify->add_compute(4,newarg);
   Tph[iregion] = modify->compute[modify->find_compute(id_temp)]->compute_scalar();

   delete [] newarg;
   modify->delete_compute(id_temp);
   delete [] id_temp;

   n = strlen(id) + 6;
   char *id_natoms = new char[n];
   strcpy(id_natoms,id);
   strcat(id_natoms,"_natoms");
   newarg = new char*[4];
   newarg[0] = id_natoms;
   newarg[1] = group->names[igroup];
   newarg[2] = "temp/region";
   newarg[3] = domain->regions[iregion]->id;
   modify->add_compute(4,newarg);
   natoms[iregion] = modify->compute[modify->find_compute(id_temp)]->compute_scalaratoms();