  We present a new implementation of star formation in cosmological
simulations, by considering star clusters as a unit of star formation. Cluster
particles grow in mass over several million years at the rate determined by
local gas properties, with high time resolution. The particle growth is
terminated by its own energy and momentum feedback on the interstellar medium.
We test this implementation for Milky Way-sized galaxies at high redshift, by
comparing the properties of model clusters with observations of young star
clusters. We find that the cluster initial mass function is best described by a
Schechter function rather than a single power law. In agreement with
observations, at low masses the logarithmic slope is $\alpha\approx 1.8-2$,
while the cutoff at high mass scales with the star formation rate. A related
trend is a positive correlation between the surface density of star formation
rate and fraction of stars contained in massive clusters. Both trends indicate
that the formation of massive star clusters is preferred during bursts of star
formation. These bursts are often associated with major merger events. We also
find that the median timescale for cluster formation ranges from 0.5 to 4 Myr
and decreases systematically with increasing star formation efficiency. Local
variations in the gas density and cluster accretion rate naturally lead to the
scatter of the overall formation efficiency by an order of magnitude, even when
the instantaneous efficiency is kept constant. Comparison of the formation
timescale with the observed age spread of young star clusters provides an
additional important constraint on the modeling of star formation and feedback
schemes.
