A lot of factors are involved.
Nationality is one, morale is another, number of units defending and number of units attacking. First thing in decision to fire is is attacker/defender disrupted. The main goal of the majority of my attacks is based on disrupting enemy units and avoiding disruption myself. You can not attack nor defend a position that is subject to assault if disrupted. Attacking bunkers from adjacent units is usually a waste-better to disrupt with artillery/air and assault with those units. Defenders goal is to disrupt units capable of assault, while attackers is to get adjacent without being disrupted. That being said if your enemy out numbers you(number of units adjacent) and you need to hold that position don't give him any free shots in DF. Make him use MPs in his turn to fire vice assaulting or moving.
I am less apt to DF low morale units-they disrupt easier-don't give your opponents more free opportunties to disrupt you.
If I have one unit defending and 3+ good order units attacking or in position to attack, I will not usually offensive fire.
There all always exceptions.
My first rule is if I am going to fire, do not waste fire on disrupted unts. My first fire is always at units that can assault me. The most dangerous one first until that unit is disrupted, and on to the next. Disrupted units are mission killed and fire shifted to non-disrupted units. Exception you need to break a unit to clear a path for supply or movement and you can't assault it. Defending a bridge from a non-assaultable hex is the most common I think.:smoke: