I have a system containing several water molecules. I use fix shake to reduce the DOF. Now I want to know how the command compute temp is applied to calculate the temperature of a single molecule and the whole system.
Originally, a water molecule should have 6 DOF right. The fix shake command would subtract 3. From the manual, compute temp can also get the correct DOF of the system with fix shake. Does compute temp calculate the kinetic energy of each atom in a water molecule with DOF of 3 being used and sum them to get the kinetic energy of the water molecule, then add the kinetic energy of each water molecule together to have the final total kinetic energy of the system? Thank you very much!

Compute temp only computes the temperature of the entire group of atoms.

No. The kinetic energy of a group of N atoms is \sum^{N_{\mathrm{atoms}}}_{i=1} (\frac{1}{2}m_iv^2_i). That is it. The determination of degrees of freedom only enters the equation when computing the temperature from the kinetic energy. You may be misinterpreting the equation. To see how the temperature is computed you have to rearrange it so that T is on the left hand side of the equal sign and not the kinetic energy.

Yes, sorry I made a mistake. I wanted to know the way compute temp calculates temperature. Then, the temperature of the system will be calculated by using the total kinetic energy and the DOF of 3, which is T_total = 2KE_totalNk_B/3. If I don’t add constraint to the molecule (fix shake), then it would be T_total = KE_totalN*k_B/3 right?

Not really. A flexible water molecule has 9 configurational DoFs (three atoms each with 3D coordinates), and a rigid water molecule such as with SHAKE has 6 (3 translational + 3 rotational).