subroutine ch_abaloper
#if defined (DOC)
*
***s/r ch_abaloper - Apply adjoint of variable transformation(s) in grid space
*                    using balance operator(s).
*
*Author  : Y.J. Rochon, ARQX/MSC, April 2007
*
*Revision:
*
*    -------------------
*
* PURPOSE: Apply adjoint of variable transformation(s) in grid space
*          using balance operator(s).
*
*          See adivbal.ftn or abmass.ftn for reference.                     
*
*Arguments:
*
*   INPUT
*
*   OUTPUT
*
*-----------------------------------------------------------
#endif
      IMPLICIT NONE
C
C     Global variables
C
#include "pardim.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comgem.cdk" 
#include "comleg.cdk"
#include "comgd0.cdk" 
#include "comchem.cdk"
#include "combalop.cdk"
C
C*    Local variables
C
      integer j,j1,jlon,jlat,jv1,jv2,jv12,jv22,jnj1,jnj2
C
      if (nbalop.eq.0) return
C
      WRITE(NULOUT,*) ' '
      WRITE(NULOUT,*) 'Enter CH_ABALOPER'
      WRITE(NULOUT,*) ' '
C
      DO J=NBALOP,1,-1
C
C        Identify variables
C
         jv1=nbalsrc(j)
         jv2=nbaldest(j)
         jv12=jv1+nflev-1
         jv22=jv2+nflev-1
C
C        Identify range for operator
C
         jnj1=1+(j-1)*nj
         jnj2=nj+(j-1)*nj
C
C        Apply adjoint of balance operator
C
         IF (NBALI(J).EQ.1) THEN
C
C           Matrix operator: Does not include spatial correlation and
C           is a function only of latitude and vertical level.
C
            DO JLON = 1, NI
               gd(jlon,jv1:jv12,1:nj)=
     &            gd(jlon,jv1:jv12,1:nj) +
     &            balop(1,1:nflev,jnj1:jnj2)*
     &            gd(jlon,jv2:jv22,1:nj)
            END DO
C
         ELSE
C
C           Matrix operator: Includes vertical correlation and
C           is a function only of latitude and vertical level.
C
            DO JLAT = 1, NJ
            DO JLON = 1, NI
            DO j1=1,NFLEV
               gd(jlon,jv1+j1-1,jlat)=
     &            gd(jlon,jv1+j1-1,jlat) +
     &            sum(balop(1:nflev,j1,jlat-1+jnj1)*
     &                gd(jlon,jv2:jv22,jlat))
            END DO
            END DO
            END DO
C
         END IF
      END DO
C 
      WRITE(NULOUT,*) ' '       
      WRITE(NULOUT,*) 'Exit CH_ABALOPER'                       
      WRITE(NULOUT,*) ' '       
C      
      RETURN
      END