A method of adapting smoothed particle hydrodynamics ( SPH ) with periodic boundary conditions for use with the special purpose device Grape is presented . Grape ( GRAvity PipE ) solves the Poisson and force equations for an N-body system by direct summation on a specially designed chip and in addition returns the neighbour list for each particle . Due to its design , Grape can not treat periodic particle distributions directly . This limitation of GrapeSPH can be overcome by computing a correction force for each particle due to periodicity ( Ewald correction ) on the host computer using a PM-like method . This scheme is applied to study the fragmentation process in giant molecular clouds . Assuming a pure isothermal model , we follow the dynamical evolution in the interior of a molecular cloud starting from an Gaussian initial density distribution to the formation of selfgravitating clumps until most of the gas is consumed in these dense cores . Despite its simplicity , this model can reproduce some fundamental properties of observed molecular clouds , like a clump mass distribution of the form dN / dm \propto m ^ { n } , with n \simeq - 1.5 .