  We describe a numerical implementation of star formation in disk galaxies, in
which the conversion of cooling gas to stars in the multiphase interstellar
medium is governed by the rate at which molecular clouds are formed and
destroyed. In the model, clouds form from thermally unstable ambient gas and
get destroyed by feedback from massive stars and thermal conduction. Feedback
in the ambient phase cycles gas into a hot galactic fountain or wind. We model
the ambient gas hydrodynamically using smoothed particle hydrodynamics (SPH).
However, we cannot resolve the Jeans mass in the cold and dense molecular gas
and, therefore, represent the cloud phase with ballistic particles that
coagulate when colliding. We show that this naturally produces a multiphase
medium with cold clouds, a warm disk, hot supernova bubbles and a hot, tenuous
halo. Our implementation of this model is based on the Gadget N-Body code. We
illustrate the model by evolving an isolated Milky Way-like galaxy and study
the properties of a disk formed in a rotating spherical collapse. Many observed
properties of disk galaxies are reproduced well, including the molecular cloud
mass spectrum, the molecular fraction as a function of radius, the Schmidt law,
the stellar density profile and the appearance of a galactic fountain.
