Determination of the Gruneisen parameter by the thermoelastic effect in anharmonic solids