  We model the temperature and chemical structure of molecular clouds as a
function of depth into the cloud, assuming a cloud of constant density n
illuminated by an external FUV (6 eV < E < 13.6 eV) flux G_0 (scaling factor in
multiples of the local interstellar field). Extending previous
photodissociation region models, we include the freezing of species, simple
grain surface chemistry, and desorption (including FUV photodesorption) of
ices. We also treat the opaque cloud interior with time-dependent chemistry.
Here, under certain conditions, gas phase elemental oxygen freezes out as water
ice and the elemental C/O abundance ratio can exceed unity, leading to complex
carbon chemistry. Gas phase H2O and O2 peak in abundance at intermediate depth
into the cloud, roughly A_V~3-8 from the surface, the depth proportional to
ln(G_0/n). Closer to the surface, molecules are photodissociated. Deeper into
the cloud, molecules freeze to grain surfaces. At intermediate depths
photodissociation rates are attenuated by dust extinction, but photodesorption
prevents total freezeout. For G_0 < 500, abundances of H2O and O2 peak at
values ~10^(-7), producing columns ~10^(15) per cm^2, independent of G_0 and n.
The peak abundances depend primarily on the product of the photodesorption
yield of water ice and the grain surface area per H nucleus. At higher values
of G_0, thermal desorption of O atoms from grains enhances the gas phase H2O
peak abundance and column slightly, whereas the gas phase O2 peak abundance
rises to ~10^(-5) and the column to ~2x10^(16) per cm^2. We present simple
analytic equations for the abundances as a function of depth which clarify the
dependence on parameters. The models are applied to observations of H2O, O2,
and water ice in a number of sources, including B68, NGC 2024, and Rho Oph.
