!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!

      SUBROUTINE SETCMA 1,1
      use modmask, only : lmask
#if defined (DOC)
*
c Purpose:
c Through indices interchange, the inovation (Z') CMA reference
C (NCMOMF) is substitute to the observations (Z) CMA reference (NCMVAR).
c This implement the incremental approach with an invariant code
C downward.
c Observations (Z) CMA reference is kept in inovation (Z') one (NCMOMF)
c
c Author  : S. Pellerin ARMA/AES December 2008
c
c Revision:
*
#endif
      IMPLICIT NONE
*implicits
#include "comdimo.cdk"
#include "comoabdy.cdk"
#include "comoahdr.cdk"
#include "comoba.cdk"
*
      INTEGER JDATA,II,IASS,ITYP
C
c-------Fill ROBDATA with Z' = -( H(xb_hr) - Z ) = Z - H(xb_hr)
c
      DO JDATA=1,NDATA
        robdata8(ncmomn,jdata) = 0.d0
        ROBDATA8(NCMOMF,JDATA) = -ROBDATA8(NCMOMA,JDATA)*ROBDATA8(NCMOER
     &       ,JDATA)
      ENDDO
c
      II = NCMVAR
      NCMVAR = NCMOMF
      NCMOMF = II

      RETURN
      END