(abridged version) Identifying the processes that determine the initial mass function of stars (IMF) is a fundamental problem in star formation theory. One of the major uncertainties is the exact chemical state of the star forming gas and its influence on the dynamical evolution. Most simulations of star forming clusters use an isothermal equation of state (EOS). We address these issues and study the effect of a piecewise polytropic EOS on the formation of stellar clusters in turbulent, self-gravitating molecular clouds. We increase the polytropic exponent gamma from 0.7 to 1.1 at some chosen density n_c, which we vary from from 4.3x10^4 cm^-3 to 4.3x10^7 cm^-3. The change of thermodynamic state at n_c selects a characteristic mass scale for fragmentation M_ch, which we relate to the peak of the observed IMF. We find a relation M_ch ~ n_c^-0.5, supporting the idea that the distribution of stellar masses largely depends on the thermodynamic state of the star-forming gas.