How to tell the rank of a semisimple Lie algebra? My understanding is that the rank of a finite-dimensional semisimple Lie algebra (over an algebraically closed field of characteristic zero) is defined non-constructively as the (unique) dimension of  a Cartan subalgebra [1]. Equivalently, it is defined to be the dimension of the maximal abelian subalgebra, or in the context of subalgebras of $\text{sl}(n,\mathbb{C})$, the largest number of (linear combinations of) generators which commute with each other  [2].
But how do you find this rank in practice? Is there a constructive definition? If I am constructing a Cartan subalgebra, how will I know when to stop?
 A: Well, if you come to the definition of a Cartan subalgebra (in an arbitrary finite-dimensional Lie algebra over an arbitrary infinite field — denote by $d$ the dimension), you see that it is defined as $K_x=\mathrm{Ker}(\mathrm{ad}(x)^d)$, where $x$ is regular, and regular precisely means that $K_x$ has minimal dimension.
So, the Cartan rank (I don't like calling it the rank in this generality) is by definition $\inf_{x\in\mathfrak{g}}\dim\mathrm{Ker}(\mathrm{ad}(x)^d)$.
Moreover, if $\mathfrak{g}$ is semisimple in characteristic zero, then the Cartan rank is $\inf_{x\in\mathfrak{g}}\dim\mathrm{Ker}(\mathrm{ad}(x))$.
This is, at least, in principle, constructive: choose a basis $(e_i)$: consider $w=\sum_i t_ie_i$. Compute $\mathrm{ad}(w)^d$, treating the $t_i$ as indeterminates. Then you get a $d\times d$-matrix with entries in $K[t_1,\dots,t_n]$. Computing the determinant of all minors yields its rank (some number $k'$), and hence yields the Cartan rank (which is $d-k'$).
This shows, if $K$ is a computable field, that there is an algorithm whose input is $d$ and the $d^3$ structure constants of a $d$-dimensional Lie algebra, and outputs the Cartan rank.
In practice, this is not greatly efficient, because you don't want to compute $\mathrm{ad}(w)^d$ (which involves huge polynomials) and so many minors within it.
So there is a better algorithm. If $\mathfrak{g}$ is nilpotent, the Cartan rank is $d$. Otherwise, there exists $x$ with $\mathrm{ad}(x)$ is not nilpotent (this is a theorem, e.g., in Jacobson's book). The first step is thus to determine if $\mathfrak{g}$ is nilpotent, and otherwise to find $x$. One can efficiently compute the center (as equal to $\bigcap_i\mathrm{Ker}(\mathrm{ad}(e_i))$) and so on, so this computes the ascending central series, and its union $\mathfrak{z}$ ("hypercenter"). If $\mathfrak{z}=\mathfrak{g}$, then $\mathfrak{g}$ is nilpotent. Otherwise, one has to find $x$. Since generically $x$ is not ad-nilpotent, I'd say that an efficient non-deterministic way to find a non-ad-nilpotent element is to pick a "random" element and check if it's ad-nilpotent. Then one computes $\mathrm{Ker}(\mathrm{ad}(x)^d)$. If the latter is nilpotent, this is a Cartan subalgebra and we are done. Otherwise, we find a non-ad-nilpotent $x'$ therein and we go on (actually, if $x$ was chosen sufficiently random, one step should be enough).
A: As Dietrich has said, if you know the simple ideals you can compute their rank as the indices of their Dynkin diagrams and then the rank you are looking for is the sum of these.
I would, however, like to note that the rank is not the dimension of just any maximal abelian subalgebras. In general there can be abelian subalgebras of higher dimension than the Cartan subalgebra. As an example, consider $\mathfrak{sl}(2n,\mathbb{C})$ this has root system $A_{2n-1}$, and so has rank $2n-1$. However, it has abelian subalgebras of dimension $n^2$ which we can think of as block strictly upper triangular matrices:
$$
\begin{pmatrix}
0 & A \\
0 & 0
\end{pmatrix}
$$
where each block is $n\times n$.
