Compactifications of F-theory on Calabi-Yau threefolds. (I)