      subroutine potran (rho,hex,ierr)                                  POTR001
c ----------------------------------------------------------------------POTR002
c     transforms rhombohedral to hexagonal atom position                POTR003
c     coordinates using matrix (see old Tables Vol. (I))                POTR004
c ----------------------------------------------------------------------POTR005
c     This program module is part of the PhysiSoft X-ray Library        POTR006
c     and may not be sold or reproduced for commercial purposes.        POTR007
c     Although it has been tested carefully, there is no warranty       POTR008
c     regarding accuracy or freedom from side-effects.                  POTR009
c                   (C) 1986-1990 Bernhard Rupp                         POTR010
c ----------------------------------------------------------------------POTR011
                                                                        POTR012
      real hex(3), rho(3), P(3,3)                                       POTR013
c --- the transformation matrix ----                                    POTR014
      data P/ 0.6666667,-0.3333333,-0.3333333,                          POTR015
     &        0.3333333, 0.3333333,-0.6666667,                          POTR016
     &        0.3333333, 0.3333333, 0.3333333/                          POTR017
                                                                        POTR018
      ierr=0                                                            POTR019
      do 0001 i=1,3                                                     POTR020
         hex(i)=0.0                                                     POTR021
 0001 continue                                                          POTR022
      do 0003 i=1,3                                                     POTR023
         do 0004, j=1,3                                                 POTR024
            hex(i)=hex(i) + rho(j)*p(j,i)                               POTR025
 0004    continue                                                       POTR026
      if (abs(hex(i)).gt.1.0) then                                      POTR027
          ierr=1                                                        POTR028
          return                                                        POTR029
      end if                                                            POTR030
 0003 continue                                                          POTR031
      return                                                            POTR032
      end                                                               POTR033
                                                                        POTR034
