Melting and crystallization of magmas