  The quality of today's research is often tightly limited to the available
computing power and scalability of codes to many processors. For example,
tackling the problem of heating the solar corona requires a most realistic
description of the plasma dynamics and the magnetic field. Numerically solving
such a magneto-hydrodynamical (MHD) description of a small active region (AR)
on the Sun requires millions of computation hours on current high-performance
computing (HPC) hardware. The aim of this work is to describe methods for an
efficient parallelization of boundary conditions and data input/output (IO)
strategies that allow for a better scaling towards thousands of processors
(CPUs). The Pencil Code is tested before and after optimization to compare the
performance and scalability of a coronal MHD model above an AR. We present a
novel boundary condition for non-vertical magnetic fields in the photosphere,
where we approach the realistic pressure increase below the photosphere. With
that, magnetic flux bundles become narrower with depth and the flux density
increases accordingly. The scalability is improved by more than one order of
magnitude through the HPC-friendly boundary conditions and IO strategies. This
work describes also the necessary nudging methods to drive the MHD model with
observed magnetic fields from the Sun's photosphere. In addition, we present
the upper and lower atmospheric boundary conditions (photospheric and towards
the outer corona), including swamp layers to diminish perturbations before they
reach the boundaries. Altogether, these methods enable more realistic 3D MHD
simulations than previous models regarding the coronal heating problem above an
AR -- simply because of the ability to use a large amount of CPUs efficiently
in parallel.
