a finitely generated module of constant finite rank which is not free?

Let $$M$$ be a finitely generated module over a commutative ring $$A$$.

If there exists a natural number $$n$$ such that for any prime ideal $$P$$ of $$A$$, $$M_P$$ is a free $$A_P$$-module of rank $$n$$, then $$M$$ is said to be of constant finite rank.

I have known every finitely generated projective module of constant finite rank over a semilocal ring is free.

I want to know whether there exists a finitely generated module of constant finite rank which is not free or not.

If $$M$$ can be generated by $$n$$ elements $$x_1,\cdots,x_n\in M,$$ and $$\dim_{A_P}(M_P)=n$$ for any prime ideal $$P$$, we cannot find such examples. One way goes as follows: Consider the following map $$\phi\colon A^n\rightarrow M,\ e_i\mapsto x_i,$$ where $$e_i$$ is the standard basis of $$A^n.$$ By localization, $$\phi$$ is an isomorphism. When $$A$$ is a seimilocal ring, we can prove $$M$$ can be generated by $$n$$ elements.

• Why not take a projective module which is not free? Commented Jul 20, 2022 at 18:54
• @Mohan cannot gurantee a projective module has constant finite rank Commented Jul 21, 2022 at 2:00

If $$A$$ is an integral domain , any finitely generated projective $$A$$-module $$M$$ has constant rank, equal to $$\dim_{Frac(A)}(M\otimes_A Frac(A)),$$ since for any prime ideal $$P$$, we have a canonical injection $$A_P\to Frac(A)$$.
For $$A$$, you can take for instance a non principal Dedekind domain and for $$P$$ a non principal ideal of $$A$$.