Let $G$ be a finite abelian group, and $g_1, \ldots, g_k$ a set of "linearly independent elements", namely such that $\langle g_1 \rangle \oplus \ldots \oplus\langle g_k \rangle$.
I would like to "complete" this set to a basis for $G$. Of course this can not be done literally, so what I am really after is a procedure to
1) substitute $g_1, \ldots, g_k$ with elements $h_1, \ldots, h_k$ such that $g_i$ is a suitable multiple of $h_i$,
2) add further elements $h_{n-k+1}, \ldots, h_n$
such that $\langle h_1\rangle \oplus \ldots \oplus\langle h_n\rangle=G$.
If the cardinality of a minimal set of linearly independent generators for $G$ is $a$, and the cardinality of a maximal set of linearly independent generators for $G$ is $b$, what can we say about $n$? (besides the fact that $a \leq n \leq b$)? What is the minimal $n$ that realizes our request?
I am pretty sure this must simple and well-known, so I would be happy with a reference.