Well, your HR%F_fire should be a vector (in a xy-plane), so it should have two components: HR%F_fire_x and HR%F_fire_y. And then you add the x and y components of the fire force to:
! Save the forces for the loop evac_move_loop (next time step)
HR%F_X = P2P_U
HR%F_Y = P2P_V
And you have lines like:
FC_X = FC_X - FC_DAMPING*(U_TMP(III)-U_TMP(JJJ))*(X_TMP(III)-X_TMP(JJJ))/TIM_DIST
FC_Y = FC_Y - FC_DAMPING*(V_TMP(III)-V_TMP(JJJ))*(Y_TMP(III)-Y_TMP(JJJ))/TIM_DIST
CONTACT_F = CONTACT_F + SQRT(FC_X**2 + FC_Y**2)
CONTACT_FX = CONTACT_FX + FC_X
CONTACT_FY = CONTACT_FY + FC_Y
P2P_U = P2P_U + FC_X
P2P_V = P2P_V + FC_Y
P2P stands for "Person to person force" and it has both x and y components. Well, "person to person" includes also walls:
CALL WALL_CONTACTFORCES(X_TMP(1), Y_TMP(1), R_TMP(1), U_TMP(1), V_TMP(1), D_XY, &
P2P_U, P2P_V, P2P_TORQUE, CONTACT_F, D_WALLS, FOUNDWALL_XY, CONTACT_FX, CONTACT_FY)
CALL WALL_CONTACTFORCES(X_TMP(2), Y_TMP(2), R_TMP(2), U_TMP(2), V_TMP(2), D_XY, &
P2P_U, P2P_V, P2P_TORQUE, CONTACT_F, D_WALLS, FOUNDWALL_XY, CONTACT_FX, CONTACT_FY)
CALL WALL_CONTACTFORCES(X_TMP(3), Y_TMP(3), R_TMP(3), U_TMP(3), V_TMP(3), D_XY, &
P2P_U, P2P_V, P2P_TORQUE, CONTACT_F, D_WALLS, FOUNDWALL_XY, CONTACT_FX, CONTACT_FY)
Above one calculates three times wall forces for an agent, why? The reason is that the agent body is represented by three circles. For each circle one has to see if it touches a wall. In your case, it is enough to use the centre point of the agent, i.e., the cell II,JJ where it is and see, what is the gradient of the red.intensity there. And you need not to calculate any torque due to the force. You do not want to turn the agent body due to the fire force, you just want to change the movement as due to a repulsive force. The agent nose is pointing where the desired velocity V0 is pointing (the angular equation has "motive torgue" such that it makes the agent to turn its nose towards the desired walking velocity direction).
The other option would be to change the desired velocity vector V0 of the agent due to the "fire force". In this case, you would not add anything to P2P_U not HR%F_X, but you would turn the V0 vector to some other direction. See;
! ========================================================
! Collision avoidance, counterflow, etc.
! ========================================================
DO III = 1, N_SECTORS+1
IF (SUM_SUUNTA(III) > SUM_SUUNTA_MAX) THEN
UBAR = U_THETA(III)
VBAR = V_THETA(III)
SUM_SUUNTA_MAX = SUM_SUUNTA(III)
I_SUUNTA_MAX = III
END IF
END DO
So, the agents check three direction in head of it and sees, what is the best. And then it changes the V0 (x and y components UBAR and VBAR, respectively). One of the V0 directions in the "counter flow" model is the original V0 direction. So, you could modify the UBAR,VBAR vector so that the agent does not go towards the negative gradient of the rad.intensity (gradient points away from the fire, gradient "goes downhill"). This might be easier than to modify the force.
So, you should use the gradient of the rad.intensity. A gradient is a vector.
TimoK