Perfomance analysis and optimization of large-scale scientific applications