The letters IEN are usually pronounced /jɛ̃/ (e.g. chien, musicien, gardien, bientôt, ancien, rien), but sometimes they are pronounced /jɑ̃/ (e.g. science). Is it possible to predict the pronunciation of this group of letters or must it be learned case by case?
A similar question with relevant answers: Européen as européin
Ways to guess based on the position in a word
The pattern seems to be, approximately, that word final -ien and -iens are pronounced /jɛ̃/.
Word-medial -ien-, when followed by a consonant letter other than N, is pronounced /jɑ̃/ in a number of words: orient, omniscient, science, récipiendaire. However, the very common verb forms vient, tient, viendra(s etc.), tiendra(s etc) are pronounced with /jɛ̃/ in exception to that.
Also, some words that are spelled with -ien- followed by another consonant letter are derived from words where -ien is word-final, and have the same /jɛ̃/ pronunciation as the shorter word. This would explain bientôt and chrétienté.
The different pronunciations usually developed from different historical sources
The actual reason for the difference seems to be historical development, rather than the position of the letters. It looks like there are three main sources of IEN in French words:
Diphthongization of what was originally a single short e sound /ɛ/ in Latin. This results in /jɛ̃/, not /jɑ̃/ (as in Latin bene, rem > French bien, rien).
This diphthongization only affected e when it occurred in a stressed open syllable (a syllable ending in a vowel) in Latin. When short e came before a consonant cluster in Latin, such as -nt- or -nd-, it didn't diphthongize to -ie-, so Latin ventus, tendit became French vent, tend.
The verb forms vient and tient have -ie- despite the following -nt because they come from Latin venit and tenet: the -nt in the French forms is not from a Latin consonant cluster, but was created later on by the loss of the vowel that was originally before the final -t. I don't know how the forms viendra and tiendra developed.
From the etymological perspective, the pronunciation of the word fiente as /fjɑ̃t/ is unexpected.
The change of an originally separate /i/ vowel to a glide /j/ before another vowel. When that following vowel is e before a Latin consonant cluster starting in N, the result is /jɑ̃/, as in French science, orient < Latin scientia, orientem.
This kind of sequence in Latin can also correspond to a French pronunciation with two syllables, /i.ɑ̃/ or /ijɑ̃/, depending on the preceding sounds or the accent of the speaker. For example, in French client from Latin clientem, the preceding cluster /kl/ might make it more likely to be pronounced with /ijɑ̃/ as /klijɑ̃/.
These kind of words all seem to have been borrowed from Latin with fairly little change in spelling.
The change of stressed a in an open syllable to ɛ̃ when nasalized. In most contexts, ɛ̃ from this source was spelled AIN (as in French vain from Latin vanus). But when preceded by a front vowel or a palatalized consonant, it apparently developed to the diphthong /jɛ̃/.
Latin canem > French chien : the a in the stressed open syllable became ɛ, nasalized by the following n to ɛ̃. The c at the start of the word was palatalized to ch, which was a regular sound change, and a glide /j/ developed between the palatalized consonant ch and the vowel ɛ̃
Latin -ianus to French -ien in gardien, musicien etc.
I think that the -ien in musicien and so on is always pronounced in a single syllable, the same as with /jɛ̃/ from diphthongized short e. I'm not totally sure though.
In complement to user sumelic's answer and pertaining to medial "ien" followed by a consonant I will mention the words in which "ien" is followed by "ne", the resulting combination being "ienne"; "ien" is not pronounced, instead "ienne" is and this pronunciation is regularly /jɛn/ (there might be a very few exceptions where it is /ijɛn/.
In such a group are the words that result by derivation in a feminine form and which regularly show the change "/jɛ̃/ → /jɛn/" in pronunciation. It's an enormous subclass.
- Adrien → Adrienne /ijɛn/ jacobien → jacobienne - Autrichien → Autrichienne lagrangien → lagrangienne - académicien → académicienne chrétien → chrétienne - chien → chienne ancien → ancienne - mien → mienne arien → arienne - tien → tienne terrien → terrienne - sien sienne …
In addition must be mentioned all those words which exist, along with a derivation by adding "ien(…)" to a stem, a dérivation in "ienne(…)"; all those formations result in the change "/jɛ̃/ → /jɛn/" in pronunciation. It's a small subclass.
- tiens,tient → tienne(s), tiennent maintiens, maintient → maintienne(s), maintiennent - viens, vient → vienne(s), viennent soutiens, soutient → soutienne(s), soutiennent
No dérivation (only a few words)
- obsidienne, persienne, Vienne, Étienne,