Manipulation of spin state of iron porphyrin by chemisorption on magnetic substrates