  We describe a newly developed code for the extrapolation of nonlinear
force-free coronal magnetic fields in spherical coordinates. The program uses
measured vector magnetograms on the solar photosphere as input and solves the
force-free equations in the solar corona. The method is based on an
optimization principle and the heritage of the newly developed code is a
corresponding method in Cartesian geometry. We test the newly developed code
with the help of a semi-analytic solution and rate the quality of our
reconstruction qualitatively by magnetic field line plots and quantitatively
with a number of comparison metrics. We find that we can reconstruct the
original test field with high accuracy. The method is fast if the computation
is limited to low co-latitudes (say $30^\circ \leq \theta \leq 150^\circ$), but
becomes significantly slower if the polar regions are included.
