# Which temperature does $T$ in Clausius inequality ($\oint \frac{\delta Q}T\le 0$) refer to?

I got a little confused about the temperature in Clausius inequality. As you can see in this answer of Luboš Motl, it seems that temperature is the temperature of the system.

But in some answers of Chester Miller e.g. this and this, he has apparently mentioned that,

$T$ is the temperature at the boundary interface (with the surroundings) at which heat transfer is occurring.

I think $T$ in $\oint \frac{\delta Q}T\le 0$ is the temperature of the system, because $\mathrm dS=\frac{\delta Q_{\textrm{rev}}}T$, and $S$ is a property of the system. So, it should be related to a property of whole of system not a property of system boundary.

On the other hand, Clausius inequality is valid for all cases either reversible or irreversible. And for some irreversible (e.g. non-quasi-static) processes, we cannot define a temperature for system.

May someone please explain clearly what is the temperature in Clausius inequality?

The temperature appearing the the Clausius inequality is definitely the temperature of the "boundary interface (with the surroundings)", or simply the temperature of the sources. One of the best places I have seen this discussion is in Fermi's book, chapter 5, section 11. He is explicit about it. To see this you have to recapitulate the steps in obtaining the Clausius inequality. You start with a cycle and suppose each infinitesimal part of this cycle is exchanging heat $\Delta Q_i$ with a (external) source at a temperature $T_i$. Then you sum all contributions $\Delta Q_i/T_i$ and in the limiting case it gives the Clausius inequality.
This is in fact a point underestimated in many books. However it is crucial. For instance a way to find out whether a process is reversible or not is just to calculate the Clausius integral (using the temperatures of the source) and compare it with the entropy change (using the temperature of the system). Then one finds $$\Delta S=\int\frac{dQ}{T_{sys}}\geq\int\frac{dQ}{T_{sour}}.$$ The equal sign meaning it is reversible and the greater sign meaning it is irreversible.
It is worth to mention that the temperature in the expression for the entropy is then the temperature of the system. The process chosen to calculate $\Delta S$ is reversible which means the temperature of the system always equals the temperature of the source.