LAPACK make fails: "recipe for target 'znep.out' failed" error
After attending to a HPC lecture and doing some research I had the answer.
It looks like the kernel associates a certain amount of memory to the compilation processes. This feature helps in some cases, when bugs can arise and those start to allocate unnecessarily big amounts of memory. But sometimes, the compilation requires more memory than usual and start getting errors.
Then, by using the following command, it sets an unlimited amount of memory to the compilation.
ulimit -s unlimited
Now everything works fine.
Thanks to @steeldriver for the extra questions.