The H II region W40 harbors a small group of young, hot stars behind roughl
y 9 mag of visual extinction. We have detected gaseous carbon monoxide (CO)
and diatomic carbon (C-2) in absorption toward the star W40 IRS 1a. The J
= 2-0 R0, R1, and R2 lines of (CO)-C-12 at 2.3 mu m were measured using the
CSHELL on the NASA Infrared Telescope Facility (with upper limits placed o
n R3, R4, and R5) yielding an N-CO of (1.1 +/- 0.2) x 10(18) cm(-2). Excita
tion analysis indicates T-kin > 7 K. The Phillips system of C-2 transitions
near 8775 Angstrom was measured using the Kitt Peak 4 m telescope and eche
lle spectrometer. Radiative pumping models indicate a total C-2 column dens
ity of (7.0 +/- 0.4) x 10(14) cm(-2), two excitation temperatures (39 and 1
26 K), and a total gas density of n similar to 250 cm(-3). The CO ice band
at 4.7 mu m was not detected, placing an upper limit on the CO depletion of
delta < 1%. We postulate that the sight line has multiple translucent comp
onents and is associated with the W40 molecular cloud. Our data for W40 IRS
1a, coupled with other sight lines, shows that the ratio of CO/C-2 increas
es from diffuse through translucent environs. Finally, we show that the hyd
rogen-to-dust ratio seems to remain constant from diffuse to dense environm
ents, whereas the CO-to-dust ratio apparently does not.