


















































































































 


































































































































































 






























































































































































































 



















































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                





































c

      SUBROUTINE met_rad_der(origin,Dx,Dy,Dz,x,y,z,g,dg)

c
c
c
c
c
c
c
      
      IMPLICIT NONE

c
      REAL*8,INTENT(IN) :: 
     &     Dx,Dy,Dz,origin(3)
      REAL*8,DIMENSION(:),INTENT(IN) :: 
     &     x,y,z
      REAL*8,DIMENSION(:,:,:),INTENT(IN) :: 
     &     g
      
c
      REAL*8,DIMENSION(:,:,:),INTENT(OUT) :: 
     &     dg
      
c
      INTEGER :: 
     &     i,j,k
      REAL*8,PARAMETER ::
     &     zero = 0.0D0,
     &     half = 0.5D0
      REAL*8 :: 
     &     rad

c

      DO k = 2, SIZE(z)-1
         DO j = 2, SIZE(y)-1
            DO i = 2, SIZE(x)-1
               
               rad = SQRT((x(i)-origin(1))**2 
     &              +(y(j)-origin(2))**2
     &              +(z(k)-origin(3))**2)
               
               IF (rad.NE.0) THEN
                  
                  dg(i,j,k) = half/rad*
     &                 ((x(i)-origin(1))/Dx*(g(i+1,j,k)-g(i-1,j,k))
     &                 +(y(j)-origin(2))/Dy*(g(i,j+1,k)-g(i,j-1,k))
     &                 +(z(k)-origin(3))/Dz*(g(i,j,k+1)-g(i,j,k-1)))
                  
               ELSE
                  
                  dg(i,j,k) = zero
                  
               ENDIF

          ENDDO
        ENDDO
      ENDDO

c
c

      DO k = 2, size(z)-1
         DO j = 2, size(y)-1
            dg(1,j,k) = dg(2,j,k)
         ENDDO
      ENDDO
      DO k = 2, size(z)-1
         DO i = 1, size(x)-1
            dg(i,1,k) = dg(i,2,k)
         ENDDO
      ENDDO
      DO j = 1, size(y)-1
         DO i = 1, size(x)-1
            dg(i,j,1) = dg(i,j,2)
         ENDDO
      ENDDO

      END SUBROUTINE met_rad_der






