  In the low-mass regime, it is found that the gas-phase abundances of
C-bearing molecules in cold starless cores rapidly decrease with increasing
density, as the molecules form mantles on dust grains. We study CO depletion in
102 massive clumps selected from the ATLASGAL 870 micron survey, and
investigate its correlation with evolutionary stage and with the physical
parameters of the sources. Moreover, we study the gradients in [12C]/[13C] and
[18O]/[17O] isotopic ratios across the inner Galaxy, and the virial stability
of the clumps. We use low-J emission lines of CO isotopologues and the dust
continuum emission to infer the depletion factor fD. RATRAN one-dimensional
models were also used to determine fD and to investigate the presence of
depletion above a density threshold. The isotopic ratios and optical depth were
derived with a Bayesian approach. We find a significant number of clumps with a
large fD, up to ~20. Larger values are found for colder clumps, thus for
earlier evolutionary phases. For massive clumps in the earliest stages of
evolution we estimate the radius of the region where CO depletion is important
to be a few tenths of a pc. Clumps are found with total masses derived from
dust continuum emission up to ~20 times higher than the virial mass, especially
among the less evolved sources. These large values may in part be explained by
the presence of depletion: if the CO emission comes mainly from the low-density
outer layers, the molecules may be subthermally excited, leading to an
overestimate of the dust masses. CO depletion in high-mass clumps seems to
behave as in the low-mass regime, with less evolved clumps showing larger
values for the depletion than their more evolved counterparts, and increasing
for denser sources. The C and O isotopic ratios are consistent with previous
determinations, and show a large intrinsic scatter.
