      SUBROUTINE CMPWND
C
      INCLUDE "parmwave"
C
      PARAMETER(MWAVEP=MWAVE+1,MWAVE2=MWAVE+2,
     1          MDIM=(MWAVE+1)*(MWAVE+2)*2*IROMB+
     2               (MWAVE+1)*(MWAVE+4)*(1-IROMB))
C
      COMMON/COMWND/ INDXVN(MDIM)
C
C  INDXVN(MDIM) :  1-D INDEX OF CONVERTING INPUT FORM SPHER COEFF ARRAY
C                  TO TRANSPOSED FORM ARRAY
C
      IF(IROMB.EQ.0) THEN
      L=0
      DO 10 M=1,MWAVEP
      NEND=MWAVEP-M+2
      DO 10 NN=1,NEND
      N=NN+M-1
      L=L+2
      if(n.eq.m) then
        indx = m * 2 - 1
      elseif(n.eq.m+1) then
        indx=(mwavep+m)*2-1
      else
        indx=((n-m)*mwavep-(n-m-1)*(n-m-2)/2+m)*2-1
      endif
      INDXVN(L-1)=INDX
      INDXVN(L  )=INDX+1
   10 CONTINUE
C
      RETURN
      ENDIF
C
      IF(IROMB.EQ.1) THEN
      L=0
      DO 30 M=1,MWAVEP
      DO 30 NN=1,MWAVE2
      N=NN+M-1
      if(n.eq.m) then
        indx = m * 2 - 1
      else
        indx=((n-m)*mwavep+m)*2-1
      endif
      L=L+2
      INDXVN(L-1)=INDX
      INDXVN(L  )=INDX+1
   30 CONTINUE
C
      RETURN
      ENDIF
C
      END
