  Photodissociation regions (PDRs) define the transition zone between an
ionized and a dark molecular region. They consist of neutral gas which
interacts with far-ultraviolet radiation and are characterized by strong
infrared line emission. Various numerical codes treating one-dimensional PDRs
have been developed in the past, simulating the complexity of chemical
reactions occurring and providing a better understanding of the structure of a
PDR. In this paper we present the three-dimensional code, 3D-PDR, which can
treat PDRs of arbitrary density distribution. The code solves the chemistry and
the thermal balance self-consistently within a given three-dimensional cloud.
It calculates the total heating and cooling functions at any point in a given
PDR by adopting an escape probability method. It uses a HEALPix-based
ray-tracing scheme to evaluate the attenuation of the far-ultraviolet radiation
in the PDR and the propagation of the far-infrared/submm line emission out of
the PDR. We present benchmarking results and apply 3D-PDR to i) a
uniform-density spherical cloud interacting with a plane-parallel external
radiation field, ii) a uniform-density spherical cloud interacting with a
two-component external radiation field, and iii) a cometary globule interacting
with a plane-parallel external radiation field. We find that the code is able
to reproduce the benchmarking results of various other one-dimensional
numerical codes treating PDRs. We also find that the accurate treatment of the
radiation field in the fully three-dimensional treatment of PDRs can in some
cases leads to different results when compared to a standard one-dimensional
treatment.
