      SUBROUTINE CTEMS (RMATCROT,RTCTMROT,
     1                  AILCROT,PAICROT,SLAICROT,
     2                  FCANCROT,TODFCROT,AILCGROT,SLAIROT,
     3                  CFCANROT,CALVCROT,CALICROT,
     4                  ZOLNCROT,CMASCROT,
     5                  CFLUXCGROT,CFLUXCSROT,
     6                  CO2CG1ROT,CO2CG2ROT,CO2CS1ROT,CO2CS2ROT,
     7                  TARTL,FSNOWRTL,TCANORTL,TCANSRTL,
     8                  TBARRTL,TBARCRTL,TBARCSRTL,TBARGRTL,
     9                  TBARGSRTL,THLIQCRTL,THLIQGRTL,THICECRTL,
     A                  ANCSRTL,ANCGRTL,RMLCSRTL,RMLCGRTL,
     B                  SOILCROT,LITRCROT,ROOTCROT,STEMCROT,
     C                  GLEAFCROT,BLEAFCROT,FALLHROT,POSPHROT,
     D                  LEAFSROT,GROWTROT,LASTRROT,LASTSROT,
     E                  THISYLROT,STEMHROT,ROOTHROT,TEMPCROT,
     F                  AILCBROT,BMASVROT,VEGHROT,ROOTDROT,
     G                  CVEGROT,CDEBROT,CHUMROT,FCOLROT,
     H                  PREFROT,NEWFROT,
     I                  ILMOS,JLMOS,
     J                  NML,NL,NM,ILG,IG,IC,ICP1,ICTEM,ICTEMP1,
     K                  RMATCGAT,RTCTMGAT,
     L                  AILCGAT,PAICGAT,SLAICGAT,
     M                  FCANCGAT,TODFCGAT,AILCGGAT,SLAIGAT,
     N                  CFCANGAT,CALVCGAT,CALICGAT,
     O                  ZOLNCGAT,CMASCGAT,
     P                  CFLUXCGGAT,CFLUXCSGAT,
     Q                  CO2CG1GAT,CO2CG2GAT,CO2CS1GAT,CO2CS2GAT,
     R                  TAGTL,FSNOWGTL,TCANOGTL,TCANSGTL,
     S                  TBARGTL,TBARCGTL,TBARCSGTL,TBARGGTL,
     T                  TBARGSGTL,THLIQCGTL,THLIQGGTL,THICECGTL,
     U                  ANCSGTL,ANCGGTL,RMLCSGTL,RMLCGGTL,
     V                  SOILCGAT,LITRCGAT,ROOTCGAT,STEMCGAT,
     W                  GLEAFCGAT,BLEAFCGAT,FALLHGAT,POSPHGAT,
     X                  LEAFSGAT,GROWTGAT,LASTRGAT,LASTSGAT,
     Y                  THISYLGAT,STEMHGAT,ROOTHGAT,TEMPCGAT,   
     Z                  AILCBGAT,BMASVGAT,VEGHGAT,ROOTDGAT,
     +                  CVEGGAT,CDEBGAT,CHUMGAT,FCOLGAT,
     +                  PREFGAT,NEWFGAT                      )
C
C     * Feb 20/16 - M.LAZARE. New version for gcm19+:
C     *                       - Add all necessary extra arrays to
C     *                         support moving CTEM into AGCM.
C     * NOV 10/11 - M.LAZARE. SCATTER ROUTINE FOR CTEM BASED ON CLASSS.
C 
      IMPLICIT NONE
C
C     * INTEGER CONSTANTS.
C
      INTEGER  NML,NL,NM,ILG,IG,IC,ICP1,ICTEM,ICTEMP1,J,K,L,M
C
C     * CTEM VARIABLES.
C
      REAL RMATCROT(NL,NM,IC,IG)
      REAL RTCTMROT(NL,NM,ICTEM,IG)

      REAL CFCANROT(NL,NM,ICP1),   CALVCROT (NL,NM,ICP1),
     1     CALICROT(NL,NM,ICP1)

      REAL AILCROT  (NL,NM,IC),    PAICROT  (NL,NM,IC),
     1     SLAICROT (NL,NM,IC),    ZOLNCROT (NL,NM,IC),
     2     CMASCROT (NL,NM,IC)

      REAL FCANCROT (NL,NM,ICTEM), TODFCROT (NL,NM,ICTEM),
     1     AILCGROT (NL,NM,ICTEM), SLAIROT  (NL,NM,ICTEM),
     2     CO2CG1ROT(NL,NM,ICTEM), CO2CG2ROT(NL,NM,ICTEM),
     3     CO2CS1ROT(NL,NM,ICTEM), CO2CS2ROT(NL,NM,ICTEM)
C
      REAL CFLUXCSROT(NL,NM),      CFLUXCGROT(NL,NM)

      REAL TBARRTL  (NL,NM,IG),    TBARCRTL (NL,NM,IG),
     1     TBARCSRTL(NL,NM,IG),    TBARGRTL (NL,NM,IG),
     2     TBARGSRTL(NL,NM,IG),    THLIQCRTL(NL,NM,IG),
     3     THLIQGRTL(NL,NM,IG),    THICECRTL(NL,NM,IG)
C
      REAL ANCSRTL  (NL,NM,ICTEM), ANCGRTL  (NL,NM,ICTEM),
     1     RMLCSRTL (NL,NM,ICTEM), RMLCGRTL (NL,NM,ICTEM)
C
      REAL TARTL    (NL,NM),       FSNOWRTL (NL,NM), 
     1     TCANORTL (NL,NM),       TCANSRTL (NL,NM)

      REAL SOILCROT (NL,NM,ICTEMP1),  LITRCROT (NL,NM,ICTEMP1),
     1     ROOTCROT (NL,NM,ICTEM),    STEMCROT (NL,NM,ICTEM),
     2     GLEAFCROT(NL,NM,ICTEM),    BLEAFCROT(NL,NM,ICTEM),
     3     FALLHROT (NL,NM,ICTEM),    POSPHROT (NL,NM,ICTEM),
     4     LEAFSROT (NL,NM,ICTEM),    GROWTROT (NL,NM,ICTEM),
     5     LASTRROT (NL,NM,ICTEM),    LASTSROT (NL,NM,ICTEM),
     6     THISYLROT(NL,NM,ICTEM),    STEMHROT (NL,NM,ICTEM),
     7     ROOTHROT (NL,NM,ICTEM),    TEMPCROT (NL,NM,2),
     8     AILCBROT (NL,NM,ICTEM),    BMASVROT (NL,NM,ICTEM),
     9     VEGHROT  (NL,NM,ICTEM),    ROOTDROT (NL,NM,ICTEM)

      REAL CVEGROT(NL,NM), CDEBROT(NL,NM), CHUMROT(NL,NM),
     1     FCOLROT(NL,NM)
C
C     * CTEM VEGEGATION CLASS FRACTION FIELDS (3 TIME LEVELS).
C
      REAL PREFROT  (NL,NM,ICTEM),    NEWFROT  (NL,NM,ICTEM)
C------------------------------------------------------------
      REAL RMATCGAT(ILG,IC,IG)
      REAL RTCTMGAT(ILG,ICTEM,IG)

      REAL CFCANGAT(ILG,IC),     CALVCGAT(ILG,IC),
     1     CALICGAT(ILG,IC)

      REAL AILCGAT (ILG,IC),     PAICGAT (ILG,IC),
     1     SLAICGAT(ILG,IC),     ZOLNCGAT(ILG,IC),
     2     CMASCGAT(ILG,IC)

      REAL FCANCGAT (ILG,ICTEM), TODFCGAT (ILG,ICTEM),
     1     AILCGGAT (ILG,ICTEM), SLAIGAT  (ILG,ICTEM),
     2     CO2CG1GAT(ILG,ICTEM), CO2CG2GAT(ILG,ICTEM),
     3     CO2CS1GAT(ILG,ICTEM), CO2CS2GAT(ILG,ICTEM)
C
      REAL CFLUXCSGAT(ILG),      CFLUXCGGAT(ILG)

      REAL TBARGTL  (ILG,IG),  TBARCGTL (ILG,IG),
     1     TBARCSGTL(ILG,IG),  TBARGGTL (ILG,IG),
     2     TBARGSGTL(ILG,IG),  THLIQCGTL(ILG,IG),
     3     THLIQGGTL(ILG,IG),  THICECGTL(ILG,IG)
C
      REAL ANCSGTL  (ILG,ICTEM), ANCGGTL  (ILG,ICTEM),
     1     RMLCSGTL (ILG,ICTEM), RMLCGGTL (ILG,ICTEM)
C
      REAL TAGTL    (ILG),       FSNOWGTL (ILG), 
     1     TCANOGTL (ILG),       TCANSGTL (ILG)

      REAL    SOILCGAT (ILG,ICTEMP1),  LITRCGAT (ILG,ICTEMP1),
     1        ROOTCGAT (ILG,ICTEM),    STEMCGAT (ILG,ICTEM),
     2        GLEAFCGAT(ILG,ICTEM),    BLEAFCGAT(ILG,ICTEM),
     3        FALLHGAT (ILG,ICTEM),    GROWTGAT (ILG,ICTEM),
     5        LASTRGAT (ILG,ICTEM),    LASTSGAT (ILG,ICTEM),
     6        THISYLGAT(ILG,ICTEM),    STEMHGAT (ILG,ICTEM),
     7        ROOTHGAT (ILG,ICTEM),
     8        AILCBGAT (ILG,ICTEM),    BMASVGAT (ILG,ICTEM),
     9        VEGHGAT  (ILG,ICTEM),    ROOTDGAT (ILG,ICTEM)
      INTEGER POSPHGAT (ILG,ICTEM),    LEAFSGAT (ILG,ICTEM),
     1        TEMPCGAT (ILG,2)

      REAL CVEGGAT(ILG), CDEBGAT(ILG), CHUMGAT(ILG),
     1     FCOLGAT(ILG)
C
C     * CTEM VEGEGATION CLASS FRACTION FIELDS (3 TIME LEVELS).
C
      REAL PREFGAT  (ILG,ICTEM), NEWFGAT  (ILG,ICTEM)
C
C     * GATHER-SCATTER INDEX ARRAYS.
C
      INTEGER  ILMOS (ILG),  JLMOS  (ILG)
C----------------------------------------------------------------------
      DO 100 K=1,NML
        TARTL     (ILMOS(K),JLMOS(K))=TAGTL     (K)
        FSNOWRTL  (ILMOS(K),JLMOS(K))=FSNOWGTL  (K)  
        TCANORTL  (ILMOS(K),JLMOS(K))=TCANOGTL  (K)  
        TCANSRTL  (ILMOS(K),JLMOS(K))=TCANSGTL  (K)  
        CFLUXCSROT(ILMOS(K),JLMOS(K))=CFLUXCSGAT(K)  
        CFLUXCGROT(ILMOS(K),JLMOS(K))=CFLUXCGGAT(K)  
        CVEGROT   (ILMOS(K),JLMOS(K))=CVEGGAT   (K)  
        CDEBROT   (ILMOS(K),JLMOS(K))=CDEBGAT   (K)  
        CHUMROT   (ILMOS(K),JLMOS(K))=CHUMGAT   (K)  
        FCOLROT   (ILMOS(K),JLMOS(K))=FCOLGAT   (K)  
  100 CONTINUE
C
      DO 150 L=1,IC
      DO 150 K=1,NML
        CFCANROT (ILMOS(K),JLMOS(K),L)=CFCANGAT(K,L)
        CALVCROT (ILMOS(K),JLMOS(K),L)=CALVCGAT(K,L)
        CALICROT (ILMOS(K),JLMOS(K),L)=CALICGAT(K,L)
  150 CONTINUE 
C
      DO 175 L=1,IC
      DO 175 K=1,NML
        ZOLNCROT (ILMOS(K),JLMOS(K),L)=ZOLNCGAT(K,L)
        CMASCROT (ILMOS(K),JLMOS(K),L)=CMASCGAT(K,L)
        AILCROT  (ILMOS(K),JLMOS(K),L)=AILCGAT (K,L)
        PAICROT  (ILMOS(K),JLMOS(K),L)=PAICGAT (K,L)
        SLAICROT (ILMOS(K),JLMOS(K),L)=SLAICGAT(K,L)
  175 CONTINUE 
C
      DO 200 L=1,ICTEM
      DO 200 K=1,NML
        FCANCROT (ILMOS(K),JLMOS(K),L)=FCANCGAT(K,L)
        TODFCROT (ILMOS(K),JLMOS(K),L)=TODFCGAT(K,L)
        AILCGROT (ILMOS(K),JLMOS(K),L)=AILCGGAT(K,L)
        SLAIROT  (ILMOS(K),JLMOS(K),L)=SLAIGAT(K,L)
C
        CO2CG1ROT(ILMOS(K),JLMOS(K),L)=CO2CG1GAT(K,L)
        CO2CG2ROT(ILMOS(K),JLMOS(K),L)=CO2CG2GAT(K,L)
        CO2CS1ROT(ILMOS(K),JLMOS(K),L)=CO2CS1GAT(K,L)
        CO2CS2ROT(ILMOS(K),JLMOS(K),L)=CO2CS2GAT(K,L)
        ANCSRTL  (ILMOS(K),JLMOS(K),L)=ANCSGTL(K,L)
        ANCGRTL  (ILMOS(K),JLMOS(K),L)=ANCGGTL(K,L)
        RMLCSRTL (ILMOS(K),JLMOS(K),L)=RMLCSGTL(K,L)
        RMLCGRTL (ILMOS(K),JLMOS(K),L)=RMLCGGTL(K,L)
C
        ROOTCROT (ILMOS(K),JLMOS(K),L)=ROOTCGAT (K,L)
        STEMCROT (ILMOS(K),JLMOS(K),L)=STEMCGAT (K,L)
        GLEAFCROT(ILMOS(K),JLMOS(K),L)=GLEAFCGAT(K,L)
        BLEAFCROT(ILMOS(K),JLMOS(K),L)=BLEAFCGAT(K,L)
        FALLHROT (ILMOS(K),JLMOS(K),L)=FALLHGAT (K,L)
        POSPHROT (ILMOS(K),JLMOS(K),L)=REAL(POSPHGAT(K,L))
        LEAFSROT (ILMOS(K),JLMOS(K),L)=REAL(LEAFSGAT(K,L))
        GROWTROT (ILMOS(K),JLMOS(K),L)=GROWTGAT (K,L)
        LASTRROT (ILMOS(K),JLMOS(K),L)=LASTRGAT (K,L)
        LASTSROT (ILMOS(K),JLMOS(K),L)=LASTSGAT (K,L)
        THISYLROT(ILMOS(K),JLMOS(K),L)=THISYLGAT(K,L)
        STEMHROT (ILMOS(K),JLMOS(K),L)=STEMHGAT (K,L)
        ROOTHROT (ILMOS(K),JLMOS(K),L)=ROOTHGAT (K,L)
        AILCBROT (ILMOS(K),JLMOS(K),L)=AILCBGAT (K,L)
        BMASVROT (ILMOS(K),JLMOS(K),L)=BMASVGAT (K,L)
        VEGHROT  (ILMOS(K),JLMOS(K),L)=VEGHGAT  (K,L)
        ROOTDROT (ILMOS(K),JLMOS(K),L)=ROOTDGAT (K,L)
  200 CONTINUE
C
      DO 250 L=1,ICTEMP1
      DO 250 K=1,NML
        SOILCROT (ILMOS(K),JLMOS(K),L)=SOILCGAT(K,L)
        LITRCROT (ILMOS(K),JLMOS(K),L)=LITRCGAT(K,L)
  250 CONTINUE
C
      DO 280 L=1,2
      DO 280 K=1,NML
        TEMPCROT (ILMOS(K),JLMOS(K),L)=REAL(TEMPCGAT(K,L))
  280 CONTINUE
C
      DO 300 L=1,IG
      DO 300 K=1,NML
        TBARRTL  (ILMOS(K),JLMOS(K),L)=TBARGTL  (K,L)
        TBARCRTL (ILMOS(K),JLMOS(K),L)=TBARCGTL (K,L)
        TBARCSRTL(ILMOS(K),JLMOS(K),L)=TBARCSGTL(K,L)
        TBARGRTL (ILMOS(K),JLMOS(K),L)=TBARGGTL (K,L)
        TBARGSRTL(ILMOS(K),JLMOS(K),L)=TBARGSGTL(K,L)
        THLIQCRTL(ILMOS(K),JLMOS(K),L)=THLIQCGTL(K,L)
        THLIQGRTL(ILMOS(K),JLMOS(K),L)=THLIQGGTL(K,L)
        THICECRTL(ILMOS(K),JLMOS(K),L)=THICECGTL(K,L)
  300 CONTINUE
C
      DO 350 L=1,ICTEM
      DO 350 K=1,NML
        PREFROT  (ILMOS(K),JLMOS(K),L)=PREFGAT(K,L)
        NEWFROT  (ILMOS(K),JLMOS(K),L)=NEWFGAT(K,L)
  350 CONTINUE
C
      DO 500 J=1,IG
      DO 500 L=1,IC
      DO 500 K=1,NML
        RMATCROT(ILMOS(K),JLMOS(K),L,J)=RMATCGAT(K,L,J)
  500 CONTINUE
C
      DO 600 J=1,IG
      DO 600 L=1,ICTEM
      DO 600 K=1,NML
        RTCTMROT(ILMOS(K),JLMOS(K),L,J)=RTCTMGAT(K,L,J)
  600 CONTINUE

      RETURN
      END
