      SUBROUTINE SETTVT(ICHID,ML,MGB,MSTATES,MG3,NCEL,NGB,IDGB,IVTS,
     &IVTSG3,TVRMOD,TVRG3,TVT,VIBTRAN,VIBTRANTV)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C TVCALCVMR SETS THE VIBRATIONAL TEMPERATURES FOR THE TRANSITIONS
C MODELED IN CO2 VMR FORWARD MODEL EQUAL TO CORRESPONDING VIBRATIONAL
C TEMPERATURES COMPUTED BY THE CO2 Tv MODEL.
C
C INPUT PARAMETERS:
C
C   ICHID     --- CHANNEL LOCATOR
C   ML        --- MAXIMUM LEVELS IN INPUT ATMOSPHERE.
C   MGB       --- MAXIMUM SIMULATED VIBRATIONAL TRANSITIONS.
C   MSTATES   --- MAXIMUM VIBRATIONAL TRANSITIONS in TV model.
C   MG3       --- NUMBER OF STATES IN G3-STATE MANIFOLD.
C   NCEL      --- NUMBER OF LEVELS IN INPUT ATMOSPHERE.
C   NGB       --- NUMBER TRANSITIONS IN FORWARD MODEL
C   IDGB      --- PSEUDO GASID'S FOR FORWARD MODEL.
C   IVTS      --- PSUEDO GAS ID'S OF OF TRANSITIONS FROM Tv model
C   IVTSG3    --- PSUEDO GAS ID'S OF OF 4.3UM TRANSITIONS FROM G3-STATES
C   TVRMOD    --- COMPUTED CO2 VIBRATIONAL TEMPERATURES (K).
C   TVRG3     --- COMPUTED CO2 G3-STATE VIBRATIONAL TEMPERATURES (K).
C   VIBTRAN   --- VIBRATIONAL TRANSITION DESCRIPTOR FOR FORWARD MODEL.
C   VIBTRANTV --- VIBRATIONAL TRANSITION DESCRIPTOR FOR TV MODEL.
C
C OUTPUT PARAMETERS:
C
C   TVT      --- VIBRATIONAL TEMPERATURES NEEDED IN FORWARD MODEL (K).
C   
C Written by Benjamin T. Marshall April 2008
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      CHARACTER*(*) VIBTRAN,VIBTRANTV
      DIMENSION IDGB(MGB),IVTS(MSTATES),IVTSG3(MG3),TVRG3(ML,MG3,2),
     &TVRMOD(ML,MSTATES,2),TVT(ML,MGB,2,*)
      DIMENSION VIBTRAN(MGB,*),VIBTRANTV(MSTATES)

C First set matching transitions using non-G3 states
C The following call to settvt_to_tvib will also set the residual
C transition according to control input.
C
C      WRITE(*,*) 'Set 4.3 TVT'
      CALL SETTVT_TO_TVIB(ML,MGB,MSTATES,NCEL,NGB,MSTATES,IDGB,IVTS,
     &VIBTRAN(1,ICHID),VIBTRANTV,TVT(1,1,1,ICHID),TVRMOD)

C Finally set matching G3 states
C      WRITE(*,*) 'Set matching G3 states'
      DO IG=1,NGB
        DO IGG=1,MG3
          IF(IDGB(IG).EQ.IVTSG3(IGG)) THEN
            WRITE(*,*) IDGB(IG),IVTSG3(IGG)
            DO IL=1,NCEL
              DO IS=1,2
                TVT(IL,IG,IS,ICHID)=TVRG3(IL,IGG,IS)
              ENDDO
            ENDDO
          ENDIF
        ENDDO
      ENDDO

      RETURN
      END                       
