      SUBROUTINE CKINPT(NSUBX)
C
C        'CKINPT' CALCULATES THE TRANSFORMATION MATRIX BETWEEN THE
C        ELEMENT FRAME AND THE BODY FRAME
C
        IMPLICIT REAL*8 (A-H,O-Z)
      REAL * 8 NSUBX(3)
      INTEGER*4 ACNTRL
C
      COMMON/CONSTS/ PI,TWOPI,RADIAN
C
      COMMON/DEBUG2/ IOUT,JOUT,KLUGE
C
      COMMON/IPOOL1/ IGRAV,IDAMP,IK,K1,ITIM,IAB,IAPS,IBB,IBPS,NK(10),
     .               LK(10),LLK(10)
C
      COMMON/MOMENT/ ACNTRL,IVISCS,IATTDE,IMGMTS,IWHEEL,NPULSE
C
      COMMON/RPOOL5/ CKMAT(3,3,10),FM2(3,3)
C
      COMMON/XIN3  / ALFAEK(10),BETAEK(10),GAMAEK(10),ETTAD,ZETTAD
C
      DIMENSION S(3,3),CK(3,3,10)
C
C
C
      DO 10 I=1,3
      DO 10 J=1,3
      FM2(I,J)=0.D0
   10 FM2(I,I)=1.D0
C
C
      IF(IVISCS.EQ.0) GO TO 15
C
C                    CALCULATE NSUBX ARRAY
      CETA=DCOS(ETTAD*RADIAN)
      SETA=DSIN(ETTAD*RADIAN)
      SZETA=DSIN(ZETTAD*RADIAN)
      CZETA=DCOS(ZETTAD*RADIAN)
C
      NSUBX(1)=SETA*CZETA
      NSUBX(2)=SETA*SZETA
      NSUBX(3)=CETA
C
C
   15 DO 30 K=1,IK
C
C
      SALFAE=DSIN(ALFAEK(K)*RADIAN)
      CALFAE=DCOS(ALFAEK(K)*RADIAN)
      SBETAE=DSIN(BETAEK(K)*RADIAN)
      CBETAE=DCOS(BETAEK(K)*RADIAN)
      SGAMAE=DSIN(GAMAEK(K)*RADIAN)
      CGAMAE=DCOS(GAMAEK(K)*RADIAN)
C
      S(1,1)=CGAMAE*CBETAE + SALFAE*SGAMAE*SBETAE
      S(1,2)=CGAMAE*SALFAE*SBETAE - SGAMAE*CBETAE
      S(1,3)=CALFAE*SBETAE
C
      S(2,1)=SGAMAE*CALFAE
      S(2,2)=CALFAE*CGAMAE
      S(2,3)=-SALFAE
C
      S(3,1)=SGAMAE*SALFAE*CBETAE - SBETAE*CGAMAE
      S(3,2)=CGAMAE*SALFAE*CBETAE + SBETAE*SGAMAE
      S(3,3)=CALFAE*CBETAE
C
C
      DO 20 I=1,3
      DO 20 J=1,3
   20 CK(I,J,K)=S(I,J)
C
   30 CONTINUE
C
      N=1
      DO 70 K=1,IK
      L=IK-K1+N
      IF((K-K1).GT.0) L=K-K1
C
      DO 40 I=1,3
      DO 40 J=1,3
   40 CKMAT(I,J,K)=CK(I,J,L)
      N=N + 1
C
C
   70 CONTINUE
      IF(IOUT.EQ.1) RETURN
      WRITE(6,10000)
      DO 80 K=1,IK
   80 WRITE(6,10001) ((CKMAT(I,J,K),J=1,3),I=1,3)
C
      RETURN
10000 FORMAT('0',3X,'CKMAT')
10001 FORMAT('0',3X,3(G15.8,2X)/3X,3(G15.8,2X)/3X,3(G15.8,2X))
      END
