      SUBROUTINE DERIVDY(FIELD,ID,DD,ILON,ILAT,BETAS,BETA,DFIELD)
C 
C     * APR 22/02 - BM  - MODIFIED FOR NEW DATA DESCRIPTION FORMAT
C     * JUN 08/01 - B. MIVILLE
C    
C     * CALCULATE THE DERIVATIVE IN THE DY FIELD
C
C     * INPUT PARAMETERS...
C
C     * FIELD = INPUT FIELD TO BE DERIVED
C     * ID    = DETERMINE IF WE ARE DERIVING TRACERS OR NOT
C     * DD    = VALUES OF DY
C     * ILON  = NUMBER OF LONGITUDES INCLUDING CYCLIC
C     * ILAT  = NUMBER OF LATITUDES 
C     * BETAS = SHAVED HEAVISIDE FUNCTION
C     * BETA  = FULL HEAVISIDE FUNCTION
C
C     * OUTPUT PARAMETERS...
C
C     * DFIELD = DERIVED FIELD
C
C-----------------------------------------------------------------
C
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      INTEGER ILON,ILAT
      REAL FIELD(ILON,ILAT),DD(ILON,ILAT),DFIELD(ILON,ILAT)
      REAL BETAS(ILON,ILAT),BETA(ILON,ILAT),ID
C-----------------------------------------------------------------------
C
      DO 202 I=1,ILON
         DO 102 J=2,ILAT-1
            DFIELD(I,J)=BETAS(I,J)*(BETA(I,J+1)*FIELD(I,J+1)+ID*
     1           (BETA(I,J+1)-BETA(I,J-1))*FIELD(I,J)-BETA(I,J-1)
     2           *FIELD(I,J-1))/(2.E0*DD(I,J))
 102     CONTINUE
C
C     * NORTH AND SOUTH POLE
C     * VALUES AT J+1 ARE SET EQUAL TO VALUES AT J FOR NORTH POLE
C     * VALUES AT J=0 ARE SET EQUAL TO VALUES AT 1 FOR SOUTH POLE
C
         J=ILAT
C
         DFIELD(I,J)=BETAS(I,J)*(BETA(I,J)*FIELD(I,J)+ID*
     1        (BETA(I,J)-BETA(I,J-1))*FIELD(I,J)-BETA(I,J-1)
     2        *FIELD(I,J-1))/(2.E0*DD(I,J))
C
         J=1
         DFIELD(I,J)=BETAS(I,J)*(BETA(I,J+1)*FIELD(I,J+1)+ID*
     1        (BETA(I,J+1)-BETA(I,J))*FIELD(I,J)-BETA(I,J)
     2        *FIELD(I,J))/(2.E0*DD(I,J))
 202  CONTINUE
C
      RETURN
      END
