Cosmic-ray ionization of molecular clouds