  Aims. Excitation of far-infrared and submillimetric molecular lines may
originate from nonreactive collisions, chemical formation, or far infrared,
near-infrared, and optical fluorescences. As a template, we investigate the
impact of each of these processes on the excitation of the methylidyne cation
CH+ and on the intensities of its rotational transitions recently detected in
emission in dense photodissociation regions (PDRs) and in planetary nebulae.
Methods. We have developed a nonlocal thermodynamic equilibrium (non-LTE)
excitation model that includes the entire energy structure of CH+, i.e. taking
into account the pumping of its vibrational and bound and unbound electronic
states by near-infrared and optical photons. The model includes the theoretical
cross-sections of nonreactive collisions with H, H2, He, and e-, and a
Boltzmann distribution is used to describe the probability of populating the
excited levels of CH+ during its chemical formation by hydrogenation of C+. To
confirm our results we also performed an extensive analytical study, which we
use to predict the main excitation process of several diatomic molecules,
namely HF, HCl, SiO, CS, and CO. Results. At densities nH = 10^4 cm-3, the
excitation of the rotational levels of CH+ is dominated by the radiative
pumping of its electronic, vibrational, and rotational states if the
intensities of the radiation field at \sim 0.4, \sim 4, and \sim 300 \mum are
stronger than 10^5, 10^8, and 10^4 times those of the local interstellar
radiation field (ISRF). Below these values, the chemical pumping is the
dominant source of excitation of the J > 1 levels, even at high kinetic
temperatures (\sim 1000 K). The far-infrared emission lines of CH+ observed in
the Orion Bar and the NGC 7027 PDRs are consistent with the predictions of our
excitation model assuming an incident far-ultraviolet (FUV) radiation field of
\sim 3 \times 10^4 (in Draine's unit) and densities of \sim 5 \times 10^4 and
\sim 2 \times 10^5 cm-3. In the case of NGC 7027, the estimate of the density
is 10 to 100 times lower than those deduced by traditional excitation codes.
Applying our model to other X1\Sigma+ ground state diatomic molecules, we find
that HF, and SiO and HCl are the species the most sensitive to the radiative
pumping of their vibrational and bound electronic states. In both cases, the
minimal near-infrared and optical/UV radiation field intensities required to
modify their rotational level populations are \sim 10^3 times those of the
local ISRF at densities nH = 10^4 cm-3. All these results point towards
interstellar and circumstellar media with densities lower than previously
established and cast doubts on the clumpiness of well-studied molecular clouds.
