criterion for a differential of the third kind to be a logarithmic derivative of a function

Let $X$ be a compact Riemann surface of genus $g\geq 1$. If $f$ is a meromorphic function on $X$ then, the meromorphic differential $\omega=\frac{df}{f}$ is a differential of the third kind with integral residues.

Q Let $\omega$ be a meromorphic differential of the third kind on $X$ with integral residues. Is there a general algebraic criterion to decide when is $\omega$ the logarithmic derivative of a meromorphic function $f$?

P.S. One may give an analytic criterion by observing that $\omega$ is a logarithmic derivative if and only if the periods of $\omega$ lie in $2\pi\sqrt{-1}\cdot\mathbb{Z}$. Indeed, if all the periods lie in $2\pi\sqrt{-1}\cdot\mathbb{Z}$, then the function $z\mapsto e^{\int_{z_0}^z \omega}$ is a well defined meromorphic function on $X$. If the curve is given by the zero locus of polynomials, it is probably possible to rephrase artificially this analytic criterion in terms of an algebraic cup product.

Yes, in principle. If the curve is given by $F(x,y)=0$ and the differential by $D(x,y)dx$ (every curve and differential can be described like this), then we look for a function in the form $R(x,y)$ where $R$ is rational. The degrees of the numerator and denominator of $R$ are bounded by the residues of the differential, so we obtain a PDE on $R$ which has to be solved in rational functions of bounded degree. Writing $R$ with undetermined coefficients, and eliminating all coefficients of $R$ we obtain an algebraic criterion.