  Recent observations with the Submillimeter Wave Astronomy Satellite indicate
abundances of gaseous H2O and O2 in dense molecular clouds which are
significantly lower than found in standard homogeneous chemistry models. We
present here results for the thermal and chemical balance of inhomogeneous
molecular clouds exposed to ultraviolet radiation in which the abundances of
H2O and O2 are computed for various density distributions, radiation field
strengths and geometries. It is found that an inhomogeneous density
distribution lowers the column densities of H2O and O2 compared to the
homogeneous case by more than an order of magnitude at the same A_V. O2 is
particularly sensitive to the penetrating ultraviolet radiation, more so than
H2O. The S140 and rho Oph clouds are studied as relevant test cases of
star-forming and quiescent regions. The SWAS results of S140 can be
accommodated naturally in a clumpy model with mean density of 2x10^3 cm-3 and
enhancement I_UV=140 compared with the average interstellar radiation field, in
agreement with observations of [CI] and 13CO of this cloud. Additional
radiative transfer computations suggest that this diffuse H2O component is
warm, ~60-90 K, and can account for the bulk of the 1_10-1_01 line emission
observed by SWAS. The rho Oph model yields consistent O2 abundances but too
much H2O, even for [C]/[O]=0.94, if I_UV<10 respectively <40 for a mean density
of 10^3 respectively 10^4 cm-3. It is concluded that enhanced photodissociation
in clumpy regions can explain the low H2O and O2 abundances and emissivities
found in the large SWAS beam for extended molecular clouds, but that additional
freeze-out of oxygen onto grains is needed in dense cold cores.
