Sorry for the rather basic question, I asked this on mathstackexchange but didn't get an answer.

I'm trying to understand how does the inverse exceptional image $f^!$ of a coherent sheaf look like.

Let's say for the sake of this question that $f:X\rightarrow Y$ is a finite flat morphism between schemes. In this case, my understanding is that $f^!$ is a functor from coherent sheaves on $Y$ to coherent sheaves on $X$, and that if $\mathcal{F}$ is a coherent sheaf on $Y$ then $f^!\mathcal{F}$ can be described as $\underline{Hom}_{\mathcal{O}_Y}(f_*(\mathcal{O}_X),\mathcal{F})$.

If $X$ and $Y$ are affine then it's not hard to work out what this does for a coherent sheaf on Y.

As another basic case, I'm trying to understand what happens if $X$ and $Y$ are smooth projective curves, and $\mathcal{L}$ is a line bundle on $Y$, in terms of divisors. Say $D=\sum{P_i}$ is a divisor on $Y$, and $\mathcal{L}(D)$ is the corresponding line bundle. My understanding is that if $f$ is etale then $f^! = f^*$, so that in that case $f^!(\mathcal{L}(D))=\mathcal{L}(D')$ where $D'=\sum_i\sum_{f(Q)=P_i}{Q}$.

Can we understand $f^!(\mathcal{L}(D))$ in general (by which I mean, when $f$ is assumed finite flat but not necessarily etale)? (can we say something more specific than $f^!\mathcal{L}(D)=\underline{Hom}_{\mathcal{O}_Y}(f_*(\mathcal{O}_X),\mathcal{L}(D))$, in terms of the divisor $D$)? And how should I think of the functor $f^!$ for general coherent sheaves, in this setting?

Thanks!