************************************************************************
*                                                                      *
*    Data output subroutines                                           *
*                                                                      *
************************************************************************

*********
* force *
*********
      subroutine outforce(numb,t,fix,fnx,ftx,fbx 
     &                              ,fiy,fny,fty,fby
     &                              ,fiz,fnz,ftz,fbz,fam1,fam2,fam3
     &                              ,famd1,famd2,famd3)
      implicit double precision(a-z)
      integer numb,j
      double precision fix(numb),fnx(numb),ftx(numb),fbx(numb)
     &                ,fiy(numb),fny(numb),fty(numb),fby(numb)
     &                ,fiz(numb),fnz(numb),ftz(numb),fbz(numb)

 9000 format(1p6e17.8)
 9100 format(1p7e17.8)

* x
       fx000=0.0d0
      fix000=0.0d0
      fnx000=0.0d0
      ftx000=0.0d0
      fbx000=0.0d0
      do j=1,numb
       fx000 =  fx000 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix000 = fix000 + fix(j)
      fnx000 = fnx000 + fnx(j)
      ftx000 = ftx000 + ftx(j)
      fbx000 = fbx000 + fbx(j)
      end do

       fx001=0.0d0
      fix001=0.0d0
      fnx001=0.0d0
      ftx001=0.0d0
      fbx001=0.0d0
      do j=1,9
       fx001 =  fx001 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix001 = fix001 + fix(j)
      fnx001 = fnx001 + fnx(j)
      ftx001 = ftx001 + ftx(j)
      fbx001 = fbx001 + fbx(j)
      end do

       fx002=0.0d0
      fix002=0.0d0
      fnx002=0.0d0
      ftx002=0.0d0
      fbx002=0.0d0
      do j=16,20,2
       fx002 =  fx002 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix002 = fix002 + fix(j)
      fnx002 = fnx002 + fnx(j)
      ftx002 = ftx002 + ftx(j)
      fbx002 = fbx002 + fbx(j)
      end do

       fx003=0.0d0
      fix003=0.0d0
      fnx003=0.0d0
      ftx003=0.0d0
      fbx003=0.0d0
      do j=17,21,2
       fx003 =  fx003 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix003 = fix003 + fix(j)
      fnx003 = fnx003 + fnx(j)
      ftx003 = ftx003 + ftx(j)
      fbx003 = fbx003 + fbx(j)
      end do

       fx004=0.0d0
      fix004=0.0d0
      fnx004=0.0d0
      ftx004=0.0d0
      fbx004=0.0d0
      do j=10,14,2
       fx004 =  fx004 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix004 = fix004 + fix(j)
      fnx004 = fnx004 + fnx(j)
      ftx004 = ftx004 + ftx(j)
      fbx004 = fbx004 + fbx(j)
      end do

       fx005=0.0d0
      fix005=0.0d0
      fnx005=0.0d0
      ftx005=0.0d0
      fbx005=0.0d0
      do j=11,15,2
       fx005 =  fx005 + fix(j)+fnx(j)+ftx(j)+fbx(j)
      fix005 = fix005 + fix(j)
      fnx005 = fnx005 + fnx(j)
      ftx005 = ftx005 + ftx(j)
      fbx005 = fbx005 + fbx(j)
      end do

      open(unit=10,file='Output_data/force_x_000whole_body_with_am2.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fx000+famd1,fix000,fnx000,ftx000,fbx000,famd1
      close(10)

      open(unit=10,file='Output_data/force_x_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fx000+fam1,fix000,fnx000,ftx000,fbx000,fam1
      close(10)

      open(unit=10,file='Output_data/force_x_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx000,fix000,fnx000,ftx000,fbx000
      close(10)

      open(unit=10,file='Output_data/force_x_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx001,fix001,fnx001,ftx001,fbx001
      close(10)

      open(unit=10,file='Output_data/force_x_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx002,fix002,fnx002,ftx002,fbx002
      close(10)

      open(unit=10,file='Output_data/force_x_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx003,fix003,fnx003,ftx003,fbx003
      close(10)

      open(unit=10,file='Output_data/force_x_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx004,fix004,fnx004,ftx004,fbx004
      close(10)

      open(unit=10,file='Output_data/force_x_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fx005,fix005,fnx005,ftx005,fbx005
      close(10)

      open(unit=10,file='Output_data/force_x_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(1)+fnx(1)+ftx(1)+fbx(1)
     &                 ,fix(1),fnx(1),ftx(1),fbx(1)
      close(10)

      open(unit=10,file='Output_data/force_x_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(2)+fnx(2)+ftx(2)+fbx(2)
     &                 ,fix(2),fnx(2),ftx(2),fbx(2)
      close(10)

      open(unit=10,file='Output_data/force_x_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(3)+fnx(3)+ftx(3)+fbx(3)
     &                 ,fix(3),fnx(3),ftx(3),fbx(3)
      close(10)

      open(unit=10,file='Output_data/force_x_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(4)+fnx(4)+ftx(4)+fbx(4)
     &                 ,fix(4),fnx(4),ftx(4),fbx(4)
      close(10)

      open(unit=10,file='Output_data/force_x_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(5)+fnx(5)+ftx(5)+fbx(5)
     &                 ,fix(5),fnx(5),ftx(5),fbx(5)
      close(10)

      open(unit=10,file='Output_data/force_x_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(6)+fnx(6)+ftx(6)+fbx(6)
     &                 ,fix(6),fnx(6),ftx(6),fbx(6)
      close(10)

      open(unit=10,file='Output_data/force_x_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(7)+fnx(7)+ftx(7)+fbx(7)
     &                 ,fix(7),fnx(7),ftx(7),fbx(7)
      close(10)

      open(unit=10,file='Output_data/force_x_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(8)+fnx(8)+ftx(8)+fbx(8)
     &                 ,fix(8),fnx(8),ftx(8),fbx(8)
      close(10)

      open(unit=10,file='Output_data/force_x_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(9)+fnx(9)+ftx(9)+fbx(9)
     &                 ,fix(9),fnx(9),ftx(9),fbx(9)
      close(10)

      open(unit=10,file='Output_data/force_x_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(10)+fnx(10)+ftx(10)+fbx(10)
     &                 ,fix(10),fnx(10),ftx(10),fbx(10)
      close(10)

      open(unit=10,file='Output_data/force_x_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(11)+fnx(11)+ftx(11)+fbx(11)
     &                 ,fix(11),fnx(11),ftx(11),fbx(11)
      close(10)

      open(unit=10,file='Output_data/force_x_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(12)+fnx(12)+ftx(12)+fbx(12)
     &                 ,fix(12),fnx(12),ftx(12),fbx(12)
      close(10)

      open(unit=10,file='Output_data/force_x_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(13)+fnx(13)+ftx(13)+fbx(13)
     &                 ,fix(13),fnx(13),ftx(13),fbx(13)
      close(10)

      open(unit=10,file='Output_data/force_x_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(14)+fnx(14)+ftx(14)+fbx(14)
     &                 ,fix(14),fnx(14),ftx(14),fbx(14)
      close(10)

      open(unit=10,file='Output_data/force_x_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(15)+fnx(15)+ftx(15)+fbx(15)
     &                 ,fix(15),fnx(15),ftx(15),fbx(15)
      close(10)

      open(unit=10,file='Output_data/force_x_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(16)+fnx(16)+ftx(16)+fbx(16)
     &                 ,fix(16),fnx(16),ftx(16),fbx(16)
      close(10)

      open(unit=10,file='Output_data/force_x_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(17)+fnx(17)+ftx(17)+fbx(17)
     &                 ,fix(17),fnx(17),ftx(17),fbx(17)
      close(10)

      open(unit=10,file='Output_data/force_x_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(18)+fnx(18)+ftx(18)+fbx(18)
     &                 ,fix(18),fnx(18),ftx(18),fbx(18)
      close(10)

      open(unit=10,file='Output_data/force_x_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(19)+fnx(19)+ftx(19)+fbx(19)
     &                 ,fix(19),fnx(19),ftx(19),fbx(19)
      close(10)

      open(unit=10,file='Output_data/force_x_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(20)+fnx(20)+ftx(20)+fbx(20)
     &                 ,fix(20),fnx(20),ftx(20),fbx(20)
      close(10)

      open(unit=10,file='Output_data/force_x_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fix(21)+fnx(21)+ftx(21)+fbx(21)
     &                 ,fix(21),fnx(21),ftx(21),fbx(21)
      close(10)

* y
       fy000=0.0d0
      fiy000=0.0d0
      fny000=0.0d0
      fty000=0.0d0
      fby000=0.0d0
      do j=1,numb
       fy000 =  fy000 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy000 = fiy000 + fiy(j)
      fny000 = fny000 + fny(j)
      fty000 = fty000 + fty(j)
      fby000 = fby000 + fby(j)
      end do

       fy001=0.0d0
      fiy001=0.0d0
      fny001=0.0d0
      fty001=0.0d0
      fby001=0.0d0
      do j=1,9
       fy001 =  fy001 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy001 = fiy001 + fiy(j)
      fny001 = fny001 + fny(j)
      fty001 = fty001 + fty(j)
      fby001 = fby001 + fby(j)
      end do

       fy002=0.0d0
      fiy002=0.0d0
      fny002=0.0d0
      fty002=0.0d0
      fby002=0.0d0
      do j=16,20,2
       fy002 =  fy002 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy002 = fiy002 + fiy(j)
      fny002 = fny002 + fny(j)
      fty002 = fty002 + fty(j)
      fby002 = fby002 + fby(j)
      end do

       fy003=0.0d0
      fiy003=0.0d0
      fny003=0.0d0
      fty003=0.0d0
      fby003=0.0d0
      do j=17,21,2
       fy003 =  fy003 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy003 = fiy003 + fiy(j)
      fny003 = fny003 + fny(j)
      fty003 = fty003 + fty(j)
      fby003 = fby003 + fby(j)
      end do

       fy004=0.0d0
      fiy004=0.0d0
      fny004=0.0d0
      fty004=0.0d0
      fby004=0.0d0
      do j=10,14,2
       fy004 =  fy004 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy004 = fiy004 + fiy(j)
      fny004 = fny004 + fny(j)
      fty004 = fty004 + fty(j)
      fby004 = fby004 + fby(j)
      end do

       fy005=0.0d0
      fiy005=0.0d0
      fny005=0.0d0
      fty005=0.0d0
      fby005=0.0d0
      do j=11,15,2
       fy005 =  fy005 + fiy(j)+fny(j)+fty(j)+fby(j)
      fiy005 = fiy005 + fiy(j)
      fny005 = fny005 + fny(j)
      fty005 = fty005 + fty(j)
      fby005 = fby005 + fby(j)
      end do

      open(unit=10,file='Output_data/force_y_000whole_body_with_am2.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fy000+famd2,fiy000,fny000,fty000,fby000,famd2
      close(10)

      open(unit=10,file='Output_data/force_y_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fy000+fam2,fiy000,fny000,fty000,fby000,fam2
      close(10)

      open(unit=10,file='Output_data/force_y_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy000,fiy000,fny000,fty000,fby000
      close(10)

      open(unit=10,file='Output_data/force_y_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy001,fiy001,fny001,fty001,fby001
      close(10)

      open(unit=10,file='Output_data/force_y_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy002,fiy002,fny002,fty002,fby002
      close(10)

      open(unit=10,file='Output_data/force_y_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy003,fiy003,fny003,fty003,fby003
      close(10)

      open(unit=10,file='Output_data/force_y_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy004,fiy004,fny004,fty004,fby004
      close(10)

      open(unit=10,file='Output_data/force_y_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fy005,fiy005,fny005,fty005,fby005
      close(10)

      open(unit=10,file='Output_data/force_y_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(1)+fny(1)+fty(1)+fby(1)
     &                 ,fiy(1),fny(1),fty(1),fby(1)
      close(10)

      open(unit=10,file='Output_data/force_y_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(2)+fny(2)+fty(2)+fby(2)
     &                 ,fiy(2),fny(2),fty(2),fby(2)
      close(10)

      open(unit=10,file='Output_data/force_y_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(3)+fny(3)+fty(3)+fby(3)
     &                 ,fiy(3),fny(3),fty(3),fby(3)
      close(10)

      open(unit=10,file='Output_data/force_y_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(4)+fny(4)+fty(4)+fby(4)
     &                 ,fiy(4),fny(4),fty(4),fby(4)
      close(10)

      open(unit=10,file='Output_data/force_y_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(5)+fny(5)+fty(5)+fby(5)
     &                 ,fiy(5),fny(5),fty(5),fby(5)
      close(10)

      open(unit=10,file='Output_data/force_y_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(6)+fny(6)+fty(6)+fby(6)
     &                 ,fiy(6),fny(6),fty(6),fby(6)
      close(10)

      open(unit=10,file='Output_data/force_y_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(7)+fny(7)+fty(7)+fby(7)
     &                 ,fiy(7),fny(7),fty(7),fby(7)
      close(10)

      open(unit=10,file='Output_data/force_y_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(8)+fny(8)+fty(8)+fby(8)
     &                 ,fiy(8),fny(8),fty(8),fby(8)
      close(10)

      open(unit=10,file='Output_data/force_y_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(9)+fny(9)+fty(9)+fby(9)
     &                 ,fiy(9),fny(9),fty(9),fby(9)
      close(10)

      open(unit=10,file='Output_data/force_y_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(10)+fny(10)+fty(10)+fby(10)
     &                 ,fiy(10),fny(10),fty(10),fby(10)
      close(10)

      open(unit=10,file='Output_data/force_y_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(11)+fny(11)+fty(11)+fby(11)
     &                 ,fiy(11),fny(11),fty(11),fby(11)
      close(10)

      open(unit=10,file='Output_data/force_y_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(12)+fny(12)+fty(12)+fby(12)
     &                 ,fiy(12),fny(12),fty(12),fby(12)
      close(10)

      open(unit=10,file='Output_data/force_y_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(13)+fny(13)+fty(13)+fby(13)
     &                 ,fiy(13),fny(13),fty(13),fby(13)
      close(10)

      open(unit=10,file='Output_data/force_y_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(14)+fny(14)+fty(14)+fby(14)
     &                 ,fiy(14),fny(14),fty(14),fby(14)
      close(10)

      open(unit=10,file='Output_data/force_y_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(15)+fny(15)+fty(15)+fby(15)
     &                 ,fiy(15),fny(15),fty(15),fby(15)
      close(10)

      open(unit=10,file='Output_data/force_y_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(16)+fny(16)+fty(16)+fby(16)
     &                 ,fiy(16),fny(16),fty(16),fby(16)
      close(10)

      open(unit=10,file='Output_data/force_y_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(17)+fny(17)+fty(17)+fby(17)
     &                 ,fiy(17),fny(17),fty(17),fby(17)
      close(10)

      open(unit=10,file='Output_data/force_y_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(18)+fny(18)+fty(18)+fby(18)
     &                 ,fiy(18),fny(18),fty(18),fby(18)
      close(10)

      open(unit=10,file='Output_data/force_y_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(19)+fny(19)+fty(19)+fby(19)
     &                 ,fiy(19),fny(19),fty(19),fby(19)
      close(10)

      open(unit=10,file='Output_data/force_y_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(20)+fny(20)+fty(20)+fby(20)
     &                 ,fiy(20),fny(20),fty(20),fby(20)
      close(10)

      open(unit=10,file='Output_data/force_y_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiy(21)+fny(21)+fty(21)+fby(21)
     &                 ,fiy(21),fny(21),fty(21),fby(21)
      close(10)

* z
       fz000=0.0d0
      fiz000=0.0d0
      fnz000=0.0d0
      ftz000=0.0d0
      fbz000=0.0d0
      do j=1,numb
       fz000 =  fz000 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz000 = fiz000 + fiz(j)
      fnz000 = fnz000 + fnz(j)
      ftz000 = ftz000 + ftz(j)
      fbz000 = fbz000 + fbz(j)
      end do

       fz001=0.0d0
      fiz001=0.0d0
      fnz001=0.0d0
      ftz001=0.0d0
      fbz001=0.0d0
      do j=1,9
       fz001 =  fz001 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz001 = fiz001 + fiz(j)
      fnz001 = fnz001 + fnz(j)
      ftz001 = ftz001 + ftz(j)
      fbz001 = fbz001 + fbz(j)
      end do

       fz002=0.0d0
      fiz002=0.0d0
      fnz002=0.0d0
      ftz002=0.0d0
      fbz002=0.0d0
      do j=16,20,2
       fz002 =  fz002 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz002 = fiz002 + fiz(j)
      fnz002 = fnz002 + fnz(j)
      ftz002 = ftz002 + ftz(j)
      fbz002 = fbz002 + fbz(j)
      end do

       fz003=0.0d0
      fiz003=0.0d0
      fnz003=0.0d0
      ftz003=0.0d0
      fbz003=0.0d0
      do j=17,21,2
       fz003 =  fz003 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz003 = fiz003 + fiz(j)
      fnz003 = fnz003 + fnz(j)
      ftz003 = ftz003 + ftz(j)
      fbz003 = fbz003 + fbz(j)
      end do

       fz004=0.0d0
      fiz004=0.0d0
      fnz004=0.0d0
      ftz004=0.0d0
      fbz004=0.0d0
      do j=10,14,2
       fz004 =  fz004 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz004 = fiz004 + fiz(j)
      fnz004 = fnz004 + fnz(j)
      ftz004 = ftz004 + ftz(j)
      fbz004 = fbz004 + fbz(j)
      end do

       fz005=0.0d0
      fiz005=0.0d0
      fnz005=0.0d0
      ftz005=0.0d0
      fbz005=0.0d0
      do j=11,15,2
       fz005 =  fz005 + fiz(j)+fnz(j)+ftz(j)+fbz(j)
      fiz005 = fiz005 + fiz(j)
      fnz005 = fnz005 + fnz(j)
      ftz005 = ftz005 + ftz(j)
      fbz005 = fbz005 + fbz(j)
      end do

      open(unit=10,file='Output_data/force_z_000whole_body_with_am2.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fz000+famd3,fiz000,fnz000,ftz000,fbz000,famd3
      close(10)

      open(unit=10,file='Output_data/force_z_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, fz000+fam3,fiz000,fnz000,ftz000,fbz000,fam3
      close(10)

      open(unit=10,file='Output_data/force_z_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz000,fiz000,fnz000,ftz000,fbz000
      close(10)

      open(unit=10,file='Output_data/force_z_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz001,fiz001,fnz001,ftz001,fbz001
      close(10)

      open(unit=10,file='Output_data/force_z_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz002,fiz002,fnz002,ftz002,fbz002
      close(10)

      open(unit=10,file='Output_data/force_z_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz003,fiz003,fnz003,ftz003,fbz003
      close(10)

      open(unit=10,file='Output_data/force_z_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz004,fiz004,fnz004,ftz004,fbz004
      close(10)

      open(unit=10,file='Output_data/force_z_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fz005,fiz005,fnz005,ftz005,fbz005
      close(10)

      open(unit=10,file='Output_data/force_z_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(1)+fnz(1)+ftz(1)+fbz(1)
     &                 ,fiz(1),fnz(1),ftz(1),fbz(1)
      close(10)

      open(unit=10,file='Output_data/force_z_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(2)+fnz(2)+ftz(2)+fbz(2)
     &                 ,fiz(2),fnz(2),ftz(2),fbz(2)
      close(10)

      open(unit=10,file='Output_data/force_z_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(3)+fnz(3)+ftz(3)+fbz(3)
     &                 ,fiz(3),fnz(3),ftz(3),fbz(3)
      close(10)

      open(unit=10,file='Output_data/force_z_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(4)+fnz(4)+ftz(4)+fbz(4)
     &                 ,fiz(4),fnz(4),ftz(4),fbz(4)
      close(10)

      open(unit=10,file='Output_data/force_z_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(5)+fnz(5)+ftz(5)+fbz(5)
     &                 ,fiz(5),fnz(5),ftz(5),fbz(5)
      close(10)

      open(unit=10,file='Output_data/force_z_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(6)+fnz(6)+ftz(6)+fbz(6)
     &                 ,fiz(6),fnz(6),ftz(6),fbz(6)
      close(10)

      open(unit=10,file='Output_data/force_z_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(7)+fnz(7)+ftz(7)+fbz(7)
     &                 ,fiz(7),fnz(7),ftz(7),fbz(7)
      close(10)

      open(unit=10,file='Output_data/force_z_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(8)+fnz(8)+ftz(8)+fbz(8)
     &                 ,fiz(8),fnz(8),ftz(8),fbz(8)
      close(10)

      open(unit=10,file='Output_data/force_z_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(9)+fnz(9)+ftz(9)+fbz(9)
     &                 ,fiz(9),fnz(9),ftz(9),fbz(9)
      close(10)

      open(unit=10,file='Output_data/force_z_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(10)+fnz(10)+ftz(10)+fbz(10)
     &                 ,fiz(10),fnz(10),ftz(10),fbz(10)
      close(10)

      open(unit=10,file='Output_data/force_z_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(11)+fnz(11)+ftz(11)+fbz(11)
     &                 ,fiz(11),fnz(11),ftz(11),fbz(11)
      close(10)

      open(unit=10,file='Output_data/force_z_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(12)+fnz(12)+ftz(12)+fbz(12)
     &                 ,fiz(12),fnz(12),ftz(12),fbz(12)
      close(10)

      open(unit=10,file='Output_data/force_z_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(13)+fnz(13)+ftz(13)+fbz(13)
     &                 ,fiz(13),fnz(13),ftz(13),fbz(13)
      close(10)

      open(unit=10,file='Output_data/force_z_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(14)+fnz(14)+ftz(14)+fbz(14)
     &                 ,fiz(14),fnz(14),ftz(14),fbz(14)
      close(10)

      open(unit=10,file='Output_data/force_z_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(15)+fnz(15)+ftz(15)+fbz(15)
     &                 ,fiz(15),fnz(15),ftz(15),fbz(15)
      close(10)

      open(unit=10,file='Output_data/force_z_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(16)+fnz(16)+ftz(16)+fbz(16)
     &                 ,fiz(16),fnz(16),ftz(16),fbz(16)
      close(10)

      open(unit=10,file='Output_data/force_z_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(17)+fnz(17)+ftz(17)+fbz(17)
     &                 ,fiz(17),fnz(17),ftz(17),fbz(17)
      close(10)

      open(unit=10,file='Output_data/force_z_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(18)+fnz(18)+ftz(18)+fbz(18)
     &                 ,fiz(18),fnz(18),ftz(18),fbz(18)
      close(10)

      open(unit=10,file='Output_data/force_z_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(19)+fnz(19)+ftz(19)+fbz(19)
     &                 ,fiz(19),fnz(19),ftz(19),fbz(19)
      close(10)

      open(unit=10,file='Output_data/force_z_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(20)+fnz(20)+ftz(20)+fbz(20)
     &                 ,fiz(20),fnz(20),ftz(20),fbz(20)
      close(10)

      open(unit=10,file='Output_data/force_z_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, fiz(21)+fnz(21)+ftz(21)+fbz(21)
     &                 ,fiz(21),fnz(21),ftz(21),fbz(21)
      close(10)

      return
      end


**********
* moment *
**********
      subroutine outmomen(numb,t,mi1,mn1,mt1,mb1 
     &                          ,mi2,mn2,mt2,mb2
     &                          ,mi3,mn3,mt3,mb3,mam1,mam2,mam3
     &                          ,mamd1,mamd2,mamd3)
      implicit double precision(a-z)
      integer numb,j
      double precision mi1(numb),mn1(numb),mt1(numb),mb1(numb)
     &                ,mi2(numb),mn2(numb),mt2(numb),mb2(numb)
     &                ,mi3(numb),mn3(numb),mt3(numb),mb3(numb)

 9000 format(1p6e17.8)
 9100 format(1p7e17.8)

* 1
       m1000=0.0d0
      mi1000=0.0d0
      mn1000=0.0d0
      mt1000=0.0d0
      mb1000=0.0d0
      do j=1,numb
       m1000 =  m1000 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1000 = mi1000 + mi1(j)
      mn1000 = mn1000 + mn1(j)
      mt1000 = mt1000 + mt1(j)
      mb1000 = mb1000 + mb1(j)
      end do

       m1001=0.0d0
      mi1001=0.0d0
      mn1001=0.0d0
      mt1001=0.0d0
      mb1001=0.0d0
      do j=1,9
       m1001 =  m1001 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1001 = mi1001 + mi1(j)
      mn1001 = mn1001 + mn1(j)
      mt1001 = mt1001 + mt1(j)
      mb1001 = mb1001 + mb1(j)
      end do

       m1002=0.0d0
      mi1002=0.0d0
      mn1002=0.0d0
      mt1002=0.0d0
      mb1002=0.0d0
      do j=16,20,2
       m1002 =  m1002 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1002 = mi1002 + mi1(j)
      mn1002 = mn1002 + mn1(j)
      mt1002 = mt1002 + mt1(j)
      mb1002 = mb1002 + mb1(j)
      end do

       m1003=0.0d0
      mi1003=0.0d0
      mn1003=0.0d0
      mt1003=0.0d0
      mb1003=0.0d0
      do j=17,21,2
       m1003 =  m1003 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1003 = mi1003 + mi1(j)
      mn1003 = mn1003 + mn1(j)
      mt1003 = mt1003 + mt1(j)
      mb1003 = mb1003 + mb1(j)
      end do

       m1004=0.0d0
      mi1004=0.0d0
      mn1004=0.0d0
      mt1004=0.0d0
      mb1004=0.0d0
      do j=10,14,2
       m1004 =  m1004 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1004 = mi1004 + mi1(j)
      mn1004 = mn1004 + mn1(j)
      mt1004 = mt1004 + mt1(j)
      mb1004 = mb1004 + mb1(j)
      end do

       m1005=0.0d0
      mi1005=0.0d0
      mn1005=0.0d0
      mt1005=0.0d0
      mb1005=0.0d0
      do j=11,15,2
       m1005 =  m1005 + mi1(j)+mn1(j)+mt1(j)+mb1(j)
      mi1005 = mi1005 + mi1(j)
      mn1005 = mn1005 + mn1(j)
      mt1005 = mt1005 + mt1(j)
      mb1005 = mb1005 + mb1(j)
      end do

      open(unit=10,file='Output_data/moment_1_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, m1000+mam1,mi1000,mn1000,mt1000,mb1000,mam1
      close(10)

      open(unit=10,file='Output_data/moment_1_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1000,mi1000,mn1000,mt1000,mb1000
      close(10)

      open(unit=10,file='Output_data/moment_1_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1001,mi1001,mn1001,mt1001,mb1001
      close(10)

      open(unit=10,file='Output_data/moment_1_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1002,mi1002,mn1002,mt1002,mb1002
      close(10)

      open(unit=10,file='Output_data/moment_1_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1003,mi1003,mn1003,mt1003,mb1003
      close(10)

      open(unit=10,file='Output_data/moment_1_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1004,mi1004,mn1004,mt1004,mb1004
      close(10)

      open(unit=10,file='Output_data/moment_1_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m1005,mi1005,mn1005,mt1005,mb1005
      close(10)

      open(unit=10,file='Output_data/moment_1_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(1)+mn1(1)+mt1(1)+mb1(1)
     &                 ,mi1(1),mn1(1),mt1(1),mb1(1)
      close(10)

      open(unit=10,file='Output_data/moment_1_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(2)+mn1(2)+mt1(2)+mb1(2)
     &                 ,mi1(2),mn1(2),mt1(2),mb1(2)
      close(10)

      open(unit=10,file='Output_data/moment_1_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(3)+mn1(3)+mt1(3)+mb1(3)
     &                 ,mi1(3),mn1(3),mt1(3),mb1(3)
      close(10)

      open(unit=10,file='Output_data/moment_1_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(4)+mn1(4)+mt1(4)+mb1(4)
     &                 ,mi1(4),mn1(4),mt1(4),mb1(4)
      close(10)

      open(unit=10,file='Output_data/moment_1_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(5)+mn1(5)+mt1(5)+mb1(5)
     &                 ,mi1(5),mn1(5),mt1(5),mb1(5)
      close(10)

      open(unit=10,file='Output_data/moment_1_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(6)+mn1(6)+mt1(6)+mb1(6)
     &                 ,mi1(6),mn1(6),mt1(6),mb1(6)
      close(10)

      open(unit=10,file='Output_data/moment_1_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(7)+mn1(7)+mt1(7)+mb1(7)
     &                 ,mi1(7),mn1(7),mt1(7),mb1(7)
      close(10)

      open(unit=10,file='Output_data/moment_1_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(8)+mn1(8)+mt1(8)+mb1(8)
     &                 ,mi1(8),mn1(8),mt1(8),mb1(8)
      close(10)

      open(unit=10,file='Output_data/moment_1_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(9)+mn1(9)+mt1(9)+mb1(9)
     &                 ,mi1(9),mn1(9),mt1(9),mb1(9)
      close(10)

      open(unit=10,file='Output_data/moment_1_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(10)+mn1(10)+mt1(10)+mb1(10)
     &                 ,mi1(10),mn1(10),mt1(10),mb1(10)
      close(10)

      open(unit=10,file='Output_data/moment_1_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(11)+mn1(11)+mt1(11)+mb1(11)
     &                 ,mi1(11),mn1(11),mt1(11),mb1(11)
      close(10)

      open(unit=10,file='Output_data/moment_1_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(12)+mn1(12)+mt1(12)+mb1(12)
     &                 ,mi1(12),mn1(12),mt1(12),mb1(12)
      close(10)

      open(unit=10,file='Output_data/moment_1_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(13)+mn1(13)+mt1(13)+mb1(13)
     &                 ,mi1(13),mn1(13),mt1(13),mb1(13)
      close(10)

      open(unit=10,file='Output_data/moment_1_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(14)+mn1(14)+mt1(14)+mb1(14)
     &                 ,mi1(14),mn1(14),mt1(14),mb1(14)
      close(10)

      open(unit=10,file='Output_data/moment_1_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(15)+mn1(15)+mt1(15)+mb1(15)
     &                 ,mi1(15),mn1(15),mt1(15),mb1(15)
      close(10)

      open(unit=10,file='Output_data/moment_1_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(16)+mn1(16)+mt1(16)+mb1(16)
     &                 ,mi1(16),mn1(16),mt1(16),mb1(16)
      close(10)

      open(unit=10,file='Output_data/moment_1_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(17)+mn1(17)+mt1(17)+mb1(17)
     &                 ,mi1(17),mn1(17),mt1(17),mb1(17)
      close(10)

      open(unit=10,file='Output_data/moment_1_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(18)+mn1(18)+mt1(18)+mb1(18)
     &                 ,mi1(18),mn1(18),mt1(18),mb1(18)
      close(10)

      open(unit=10,file='Output_data/moment_1_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(19)+mn1(19)+mt1(19)+mb1(19)
     &                 ,mi1(19),mn1(19),mt1(19),mb1(19)
      close(10)

      open(unit=10,file='Output_data/moment_1_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(20)+mn1(20)+mt1(20)+mb1(20)
     &                 ,mi1(20),mn1(20),mt1(20),mb1(20)
      close(10)

      open(unit=10,file='Output_data/moment_1_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi1(21)+mn1(21)+mt1(21)+mb1(21)
     &                 ,mi1(21),mn1(21),mt1(21),mb1(21)
      close(10)

* 2
       m2000=0.0d0
      mi2000=0.0d0
      mn2000=0.0d0
      mt2000=0.0d0
      mb2000=0.0d0
      do j=1,numb
       m2000 =  m2000 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2000 = mi2000 + mi2(j)
      mn2000 = mn2000 + mn2(j)
      mt2000 = mt2000 + mt2(j)
      mb2000 = mb2000 + mb2(j)
      end do

       m2001=0.0d0
      mi2001=0.0d0
      mn2001=0.0d0
      mt2001=0.0d0
      mb2001=0.0d0
      do j=1,9
       m2001 =  m2001 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2001 = mi2001 + mi2(j)
      mn2001 = mn2001 + mn2(j)
      mt2001 = mt2001 + mt2(j)
      mb2001 = mb2001 + mb2(j)
      end do

       m2002=0.0d0
      mi2002=0.0d0
      mn2002=0.0d0
      mt2002=0.0d0
      mb2002=0.0d0
      do j=16,20,2
       m2002 =  m2002 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2002 = mi2002 + mi2(j)
      mn2002 = mn2002 + mn2(j)
      mt2002 = mt2002 + mt2(j)
      mb2002 = mb2002 + mb2(j)
      end do

       m2003=0.0d0
      mi2003=0.0d0
      mn2003=0.0d0
      mt2003=0.0d0
      mb2003=0.0d0
      do j=17,21,2
       m2003 =  m2003 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2003 = mi2003 + mi2(j)
      mn2003 = mn2003 + mn2(j)
      mt2003 = mt2003 + mt2(j)
      mb2003 = mb2003 + mb2(j)
      end do

       m2004=0.0d0
      mi2004=0.0d0
      mn2004=0.0d0
      mt2004=0.0d0
      mb2004=0.0d0
      do j=10,14,2
       m2004 =  m2004 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2004 = mi2004 + mi2(j)
      mn2004 = mn2004 + mn2(j)
      mt2004 = mt2004 + mt2(j)
      mb2004 = mb2004 + mb2(j)
      end do

       m2005=0.0d0
      mi2005=0.0d0
      mn2005=0.0d0
      mt2005=0.0d0
      mb2005=0.0d0
      do j=11,15,2
       m2005 =  m2005 + mi2(j)+mn2(j)+mt2(j)+mb2(j)
      mi2005 = mi2005 + mi2(j)
      mn2005 = mn2005 + mn2(j)
      mt2005 = mt2005 + mt2(j)
      mb2005 = mb2005 + mb2(j)
      end do

      open(unit=10,file='Output_data/moment_2_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, m2000+mam2,mi2000,mn2000,mt2000,mb2000,mam2
      close(10)

      open(unit=10,file='Output_data/moment_2_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2000,mi2000,mn2000,mt2000,mb2000
      close(10)

      open(unit=10,file='Output_data/moment_2_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2001,mi2001,mn2001,mt2001,mb2001
      close(10)

      open(unit=10,file='Output_data/moment_2_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2002,mi2002,mn2002,mt2002,mb2002
      close(10)

      open(unit=10,file='Output_data/moment_2_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2003,mi2003,mn2003,mt2003,mb2003
      close(10)

      open(unit=10,file='Output_data/moment_2_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2004,mi2004,mn2004,mt2004,mb2004
      close(10)

      open(unit=10,file='Output_data/moment_2_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m2005,mi2005,mn2005,mt2005,mb2005
      close(10)

      open(unit=10,file='Output_data/moment_2_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(1)+mn2(1)+mt2(1)+mb2(1)
     &                 ,mi2(1),mn2(1),mt2(1),mb2(1)
      close(10)

      open(unit=10,file='Output_data/moment_2_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(2)+mn2(2)+mt2(2)+mb2(2)
     &                 ,mi2(2),mn2(2),mt2(2),mb2(2)
      close(10)

      open(unit=10,file='Output_data/moment_2_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(3)+mn2(3)+mt2(3)+mb2(3)
     &                 ,mi2(3),mn2(3),mt2(3),mb2(3)
      close(10)

      open(unit=10,file='Output_data/moment_2_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(4)+mn2(4)+mt2(4)+mb2(4)
     &                 ,mi2(4),mn2(4),mt2(4),mb2(4)
      close(10)

      open(unit=10,file='Output_data/moment_2_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(5)+mn2(5)+mt2(5)+mb2(5)
     &                 ,mi2(5),mn2(5),mt2(5),mb2(5)
      close(10)

      open(unit=10,file='Output_data/moment_2_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(6)+mn2(6)+mt2(6)+mb2(6)
     &                 ,mi2(6),mn2(6),mt2(6),mb2(6)
      close(10)

      open(unit=10,file='Output_data/moment_2_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(7)+mn2(7)+mt2(7)+mb2(7)
     &                 ,mi2(7),mn2(7),mt2(7),mb2(7)
      close(10)

      open(unit=10,file='Output_data/moment_2_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(8)+mn2(8)+mt2(8)+mb2(8)
     &                 ,mi2(8),mn2(8),mt2(8),mb2(8)
      close(10)

      open(unit=10,file='Output_data/moment_2_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(9)+mn2(9)+mt2(9)+mb2(9)
     &                 ,mi2(9),mn2(9),mt2(9),mb2(9)
      close(10)

      open(unit=10,file='Output_data/moment_2_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(10)+mn2(10)+mt2(10)+mb2(10)
     &                 ,mi2(10),mn2(10),mt2(10),mb2(10)
      close(10)

      open(unit=10,file='Output_data/moment_2_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(11)+mn2(11)+mt2(11)+mb2(11)
     &                 ,mi2(11),mn2(11),mt2(11),mb2(11)
      close(10)

      open(unit=10,file='Output_data/moment_2_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(12)+mn2(12)+mt2(12)+mb2(12)
     &                 ,mi2(12),mn2(12),mt2(12),mb2(12)
      close(10)

      open(unit=10,file='Output_data/moment_2_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(13)+mn2(13)+mt2(13)+mb2(13)
     &                 ,mi2(13),mn2(13),mt2(13),mb2(13)
      close(10)

      open(unit=10,file='Output_data/moment_2_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(14)+mn2(14)+mt2(14)+mb2(14)
     &                 ,mi2(14),mn2(14),mt2(14),mb2(14)
      close(10)

      open(unit=10,file='Output_data/moment_2_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(15)+mn2(15)+mt2(15)+mb2(15)
     &                 ,mi2(15),mn2(15),mt2(15),mb2(15)
      close(10)

      open(unit=10,file='Output_data/moment_2_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(16)+mn2(16)+mt2(16)+mb2(16)
     &                 ,mi2(16),mn2(16),mt2(16),mb2(16)
      close(10)

      open(unit=10,file='Output_data/moment_2_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(17)+mn2(17)+mt2(17)+mb2(17)
     &                 ,mi2(17),mn2(17),mt2(17),mb2(17)
      close(10)

      open(unit=10,file='Output_data/moment_2_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(18)+mn2(18)+mt2(18)+mb2(18)
     &                 ,mi2(18),mn2(18),mt2(18),mb2(18)
      close(10)

      open(unit=10,file='Output_data/moment_2_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(19)+mn2(19)+mt2(19)+mb2(19)
     &                 ,mi2(19),mn2(19),mt2(19),mb2(19)
      close(10)

      open(unit=10,file='Output_data/moment_2_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(20)+mn2(20)+mt2(20)+mb2(20)
     &                 ,mi2(20),mn2(20),mt2(20),mb2(20)
      close(10)

      open(unit=10,file='Output_data/moment_2_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi2(21)+mn2(21)+mt2(21)+mb2(21)
     &                 ,mi2(21),mn2(21),mt2(21),mb2(21)
      close(10)

* 3
       m3000=0.0d0
      mi3000=0.0d0
      mn3000=0.0d0
      mt3000=0.0d0
      mb3000=0.0d0
      do j=1,numb
       m3000 =  m3000 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3000 = mi3000 + mi3(j)
      mn3000 = mn3000 + mn3(j)
      mt3000 = mt3000 + mt3(j)
      mb3000 = mb3000 + mb3(j)
      end do

       m3001=0.0d0
      mi3001=0.0d0
      mn3001=0.0d0
      mt3001=0.0d0
      mb3001=0.0d0
      do j=1,9
       m3001 =  m3001 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3001 = mi3001 + mi3(j)
      mn3001 = mn3001 + mn3(j)
      mt3001 = mt3001 + mt3(j)
      mb3001 = mb3001 + mb3(j)
      end do

       m3002=0.0d0
      mi3002=0.0d0
      mn3002=0.0d0
      mt3002=0.0d0
      mb3002=0.0d0
      do j=16,20,2
       m3002 =  m3002 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3002 = mi3002 + mi3(j)
      mn3002 = mn3002 + mn3(j)
      mt3002 = mt3002 + mt3(j)
      mb3002 = mb3002 + mb3(j)
      end do

       m3003=0.0d0
      mi3003=0.0d0
      mn3003=0.0d0
      mt3003=0.0d0
      mb3003=0.0d0
      do j=17,21,2
       m3003 =  m3003 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3003 = mi3003 + mi3(j)
      mn3003 = mn3003 + mn3(j)
      mt3003 = mt3003 + mt3(j)
      mb3003 = mb3003 + mb3(j)
      end do

       m3004=0.0d0
      mi3004=0.0d0
      mn3004=0.0d0
      mt3004=0.0d0
      mb3004=0.0d0
      do j=10,14,2
       m3004 =  m3004 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3004 = mi3004 + mi3(j)
      mn3004 = mn3004 + mn3(j)
      mt3004 = mt3004 + mt3(j)
      mb3004 = mb3004 + mb3(j)
      end do

       m3005=0.0d0
      mi3005=0.0d0
      mn3005=0.0d0
      mt3005=0.0d0
      mb3005=0.0d0
      do j=11,15,2
       m3005 =  m3005 + mi3(j)+mn3(j)+mt3(j)+mb3(j)
      mi3005 = mi3005 + mi3(j)
      mn3005 = mn3005 + mn3(j)
      mt3005 = mt3005 + mt3(j)
      mb3005 = mb3005 + mb3(j)
      end do

      open(unit=10,file='Output_data/moment_3_000whole_body_with_am.dat'
     &            ,status='old',access='append')
      write(10,9100) t, m3000+mam3,mi3000,mn3000,mt3000,mb3000,mam3
      close(10)

      open(unit=10,file='Output_data/moment_3_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3000,mi3000,mn3000,mt3000,mb3000
      close(10)

      open(unit=10,file='Output_data/moment_3_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3001,mi3001,mn3001,mt3001,mb3001
      close(10)

      open(unit=10,file='Output_data/moment_3_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3002,mi3002,mn3002,mt3002,mb3002
      close(10)

      open(unit=10,file='Output_data/moment_3_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3003,mi3003,mn3003,mt3003,mb3003
      close(10)

      open(unit=10,file='Output_data/moment_3_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3004,mi3004,mn3004,mt3004,mb3004
      close(10)

      open(unit=10,file='Output_data/moment_3_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, m3005,mi3005,mn3005,mt3005,mb3005
      close(10)

      open(unit=10,file='Output_data/moment_3_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(1)+mn3(1)+mt3(1)+mb3(1)
     &                 ,mi3(1),mn3(1),mt3(1),mb3(1)
      close(10)

      open(unit=10,file='Output_data/moment_3_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(2)+mn3(2)+mt3(2)+mb3(2)
     &                 ,mi3(2),mn3(2),mt3(2),mb3(2)
      close(10)

      open(unit=10,file='Output_data/moment_3_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(3)+mn3(3)+mt3(3)+mb3(3)
     &                 ,mi3(3),mn3(3),mt3(3),mb3(3)
      close(10)

      open(unit=10,file='Output_data/moment_3_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(4)+mn3(4)+mt3(4)+mb3(4)
     &                 ,mi3(4),mn3(4),mt3(4),mb3(4)
      close(10)

      open(unit=10,file='Output_data/moment_3_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(5)+mn3(5)+mt3(5)+mb3(5)
     &                 ,mi3(5),mn3(5),mt3(5),mb3(5)
      close(10)

      open(unit=10,file='Output_data/moment_3_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(6)+mn3(6)+mt3(6)+mb3(6)
     &                 ,mi3(6),mn3(6),mt3(6),mb3(6)
      close(10)

      open(unit=10,file='Output_data/moment_3_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(7)+mn3(7)+mt3(7)+mb3(7)
     &                 ,mi3(7),mn3(7),mt3(7),mb3(7)
      close(10)

      open(unit=10,file='Output_data/moment_3_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(8)+mn3(8)+mt3(8)+mb3(8)
     &                 ,mi3(8),mn3(8),mt3(8),mb3(8)
      close(10)

      open(unit=10,file='Output_data/moment_3_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(9)+mn3(9)+mt3(9)+mb3(9)
     &                 ,mi3(9),mn3(9),mt3(9),mb3(9)
      close(10)

      open(unit=10,file='Output_data/moment_3_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(10)+mn3(10)+mt3(10)+mb3(10)
     &                 ,mi3(10),mn3(10),mt3(10),mb3(10)
      close(10)

      open(unit=10,file='Output_data/moment_3_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(11)+mn3(11)+mt3(11)+mb3(11)
     &                 ,mi3(11),mn3(11),mt3(11),mb3(11)
      close(10)

      open(unit=10,file='Output_data/moment_3_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(12)+mn3(12)+mt3(12)+mb3(12)
     &                 ,mi3(12),mn3(12),mt3(12),mb3(12)
      close(10)

      open(unit=10,file='Output_data/moment_3_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(13)+mn3(13)+mt3(13)+mb3(13)
     &                 ,mi3(13),mn3(13),mt3(13),mb3(13)
      close(10)

      open(unit=10,file='Output_data/moment_3_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(14)+mn3(14)+mt3(14)+mb3(14)
     &                 ,mi3(14),mn3(14),mt3(14),mb3(14)
      close(10)

      open(unit=10,file='Output_data/moment_3_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(15)+mn3(15)+mt3(15)+mb3(15)
     &                 ,mi3(15),mn3(15),mt3(15),mb3(15)
      close(10)

      open(unit=10,file='Output_data/moment_3_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(16)+mn3(16)+mt3(16)+mb3(16)
     &                 ,mi3(16),mn3(16),mt3(16),mb3(16)
      close(10)

      open(unit=10,file='Output_data/moment_3_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(17)+mn3(17)+mt3(17)+mb3(17)
     &                 ,mi3(17),mn3(17),mt3(17),mb3(17)
      close(10)

      open(unit=10,file='Output_data/moment_3_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(18)+mn3(18)+mt3(18)+mb3(18)
     &                 ,mi3(18),mn3(18),mt3(18),mb3(18)
      close(10)

      open(unit=10,file='Output_data/moment_3_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(19)+mn3(19)+mt3(19)+mb3(19)
     &                 ,mi3(19),mn3(19),mt3(19),mb3(19)
      close(10)

      open(unit=10,file='Output_data/moment_3_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(20)+mn3(20)+mt3(20)+mb3(20)
     &                 ,mi3(20),mn3(20),mt3(20),mb3(20)
      close(10)

      open(unit=10,file='Output_data/moment_3_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, mi3(21)+mn3(21)+mt3(21)+mb3(21)
     &                 ,mi3(21),mn3(21),mt3(21),mb3(21)
      close(10)

      return
      end


*********
* power *
*********
      subroutine outpower(numb,t,pix,pnx,ptx 
     &                          ,piy,pny,pty
     &                          ,piz,pnz,ptz)
      implicit double precision(a-z)
      integer numb,j
      double precision pix(numb),pnx(numb),ptx(numb)
     &                ,piy(numb),pny(numb),pty(numb)
     &                ,piz(numb),pnz(numb),ptz(numb)

 9000 format(1p6e17.8)

* x
       px000=0.0d0
      pix000=0.0d0
      pnx000=0.0d0
      ptx000=0.0d0
      do j=1,numb
       px000 =  px000 + pix(j)+pnx(j)+ptx(j)
      pix000 = pix000 + pix(j)
      pnx000 = pnx000 + pnx(j)
      ptx000 = ptx000 + ptx(j)
      end do

       px001=0.0d0
      pix001=0.0d0
      pnx001=0.0d0
      ptx001=0.0d0
      do j=1,9
       px001 =  px001 + pix(j)+pnx(j)+ptx(j)
      pix001 = pix001 + pix(j)
      pnx001 = pnx001 + pnx(j)
      ptx001 = ptx001 + ptx(j)
      end do

       px002=0.0d0
      pix002=0.0d0
      pnx002=0.0d0
      ptx002=0.0d0
      do j=16,20,2
       px002 =  px002 + pix(j)+pnx(j)+ptx(j)
      pix002 = pix002 + pix(j)
      pnx002 = pnx002 + pnx(j)
      ptx002 = ptx002 + ptx(j)
      end do

       px003=0.0d0
      pix003=0.0d0
      pnx003=0.0d0
      ptx003=0.0d0
      do j=17,21,2
       px003 =  px003 + pix(j)+pnx(j)+ptx(j)
      pix003 = pix003 + pix(j)
      pnx003 = pnx003 + pnx(j)
      ptx003 = ptx003 + ptx(j)
      end do

       px004=0.0d0
      pix004=0.0d0
      pnx004=0.0d0
      ptx004=0.0d0
      do j=10,14,2
       px004 =  px004 + pix(j)+pnx(j)+ptx(j)
      pix004 = pix004 + pix(j)
      pnx004 = pnx004 + pnx(j)
      ptx004 = ptx004 + ptx(j)
      end do

       px005=0.0d0
      pix005=0.0d0
      pnx005=0.0d0
      ptx005=0.0d0
      do j=11,15,2
       px005 =  px005 + pix(j)+pnx(j)+ptx(j)
      pix005 = pix005 + pix(j)
      pnx005 = pnx005 + pnx(j)
      ptx005 = ptx005 + ptx(j)
      end do

      open(unit=10,file='Output_data/power_x_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px000,pix000,pnx000,ptx000
      close(10)

      open(unit=10,file='Output_data/power_x_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px001,pix001,pnx001,ptx001
      close(10)

      open(unit=10,file='Output_data/power_x_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px002,pix002,pnx002,ptx002
      close(10)

      open(unit=10,file='Output_data/power_x_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px003,pix003,pnx003,ptx003
      close(10)

      open(unit=10,file='Output_data/power_x_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px004,pix004,pnx004,ptx004
      close(10)

      open(unit=10,file='Output_data/power_x_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, px005,pix005,pnx005,ptx005
      close(10)

      open(unit=10,file='Output_data/power_x_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(1)+pnx(1)+ptx(1)
     &                 ,pix(1),pnx(1),ptx(1)
      close(10)

      open(unit=10,file='Output_data/power_x_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(2)+pnx(2)+ptx(2)
     &                 ,pix(2),pnx(2),ptx(2)
      close(10)

      open(unit=10,file='Output_data/power_x_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(3)+pnx(3)+ptx(3)
     &                 ,pix(3),pnx(3),ptx(3)
      close(10)

      open(unit=10,file='Output_data/power_x_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(4)+pnx(4)+ptx(4)
     &                 ,pix(4),pnx(4),ptx(4)
      close(10)

      open(unit=10,file='Output_data/power_x_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(5)+pnx(5)+ptx(5)
     &                 ,pix(5),pnx(5),ptx(5)
      close(10)

      open(unit=10,file='Output_data/power_x_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(6)+pnx(6)+ptx(6)
     &                 ,pix(6),pnx(6),ptx(6)
      close(10)

      open(unit=10,file='Output_data/power_x_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(7)+pnx(7)+ptx(7)
     &                 ,pix(7),pnx(7),ptx(7)
      close(10)

      open(unit=10,file='Output_data/power_x_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(8)+pnx(8)+ptx(8)
     &                 ,pix(8),pnx(8),ptx(8)
      close(10)

      open(unit=10,file='Output_data/power_x_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(9)+pnx(9)+ptx(9)
     &                 ,pix(9),pnx(9),ptx(9)
      close(10)

      open(unit=10,file='Output_data/power_x_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(10)+pnx(10)+ptx(10)
     &                 ,pix(10),pnx(10),ptx(10)
      close(10)

      open(unit=10,file='Output_data/power_x_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(11)+pnx(11)+ptx(11)
     &                 ,pix(11),pnx(11),ptx(11)
      close(10)

      open(unit=10,file='Output_data/power_x_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(12)+pnx(12)+ptx(12)
     &                 ,pix(12),pnx(12),ptx(12)
      close(10)

      open(unit=10,file='Output_data/power_x_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(13)+pnx(13)+ptx(13)
     &                 ,pix(13),pnx(13),ptx(13)
      close(10)

      open(unit=10,file='Output_data/power_x_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(14)+pnx(14)+ptx(14)
     &                 ,pix(14),pnx(14),ptx(14)
      close(10)

      open(unit=10,file='Output_data/power_x_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(15)+pnx(15)+ptx(15)
     &                 ,pix(15),pnx(15),ptx(15)
      close(10)

      open(unit=10,file='Output_data/power_x_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(16)+pnx(16)+ptx(16)
     &                 ,pix(16),pnx(16),ptx(16)
      close(10)

      open(unit=10,file='Output_data/power_x_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(17)+pnx(17)+ptx(17)
     &                 ,pix(17),pnx(17),ptx(17)
      close(10)

      open(unit=10,file='Output_data/power_x_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(18)+pnx(18)+ptx(18)
     &                 ,pix(18),pnx(18),ptx(18)
      close(10)

      open(unit=10,file='Output_data/power_x_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(19)+pnx(19)+ptx(19)
     &                 ,pix(19),pnx(19),ptx(19)
      close(10)

      open(unit=10,file='Output_data/power_x_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(20)+pnx(20)+ptx(20)
     &                 ,pix(20),pnx(20),ptx(20)
      close(10)

      open(unit=10,file='Output_data/power_x_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pix(21)+pnx(21)+ptx(21)
     &                 ,pix(21),pnx(21),ptx(21)
      close(10)

* y
       py000=0.0d0
      piy000=0.0d0
      pny000=0.0d0
      pty000=0.0d0
      do j=1,numb
       py000 =  py000 + piy(j)+pny(j)+pty(j)
      piy000 = piy000 + piy(j)
      pny000 = pny000 + pny(j)
      pty000 = pty000 + pty(j)
      end do

       py001=0.0d0
      piy001=0.0d0
      pny001=0.0d0
      pty001=0.0d0
      do j=1,9
       py001 =  py001 + piy(j)+pny(j)+pty(j)
      piy001 = piy001 + piy(j)
      pny001 = pny001 + pny(j)
      pty001 = pty001 + pty(j)
      end do

       py002=0.0d0
      piy002=0.0d0
      pny002=0.0d0
      pty002=0.0d0
      do j=16,20,2
       py002 =  py002 + piy(j)+pny(j)+pty(j)
      piy002 = piy002 + piy(j)
      pny002 = pny002 + pny(j)
      pty002 = pty002 + pty(j)
      end do

       py003=0.0d0
      piy003=0.0d0
      pny003=0.0d0
      pty003=0.0d0
      do j=17,21,2
       py003 =  py003 + piy(j)+pny(j)+pty(j)
      piy003 = piy003 + piy(j)
      pny003 = pny003 + pny(j)
      pty003 = pty003 + pty(j)
      end do

       py004=0.0d0
      piy004=0.0d0
      pny004=0.0d0
      pty004=0.0d0
      do j=10,14,2
       py004 =  py004 + piy(j)+pny(j)+pty(j)
      piy004 = piy004 + piy(j)
      pny004 = pny004 + pny(j)
      pty004 = pty004 + pty(j)
      end do

       py005=0.0d0
      piy005=0.0d0
      pny005=0.0d0
      pty005=0.0d0
      do j=11,15,2
       py005 =  py005 + piy(j)+pny(j)+pty(j)
      piy005 = piy005 + piy(j)
      pny005 = pny005 + pny(j)
      pty005 = pty005 + pty(j)
      end do

      open(unit=10,file='Output_data/power_y_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py000,piy000,pny000,pty000
      close(10)

      open(unit=10,file='Output_data/power_y_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py001,piy001,pny001,pty001
      close(10)

      open(unit=10,file='Output_data/power_y_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py002,piy002,pny002,pty002
      close(10)

      open(unit=10,file='Output_data/power_y_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py003,piy003,pny003,pty003
      close(10)

      open(unit=10,file='Output_data/power_y_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py004,piy004,pny004,pty004
      close(10)

      open(unit=10,file='Output_data/power_y_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, py005,piy005,pny005,pty005
      close(10)

      open(unit=10,file='Output_data/power_y_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(1)+pny(1)+pty(1)
     &                 ,piy(1),pny(1),pty(1)
      close(10)

      open(unit=10,file='Output_data/power_y_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(2)+pny(2)+pty(2)
     &                 ,piy(2),pny(2),pty(2)
      close(10)

      open(unit=10,file='Output_data/power_y_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(3)+pny(3)+pty(3)
     &                 ,piy(3),pny(3),pty(3)
      close(10)

      open(unit=10,file='Output_data/power_y_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(4)+pny(4)+pty(4)
     &                 ,piy(4),pny(4),pty(4)
      close(10)

      open(unit=10,file='Output_data/power_y_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(5)+pny(5)+pty(5)
     &                 ,piy(5),pny(5),pty(5)
      close(10)

      open(unit=10,file='Output_data/power_y_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(6)+pny(6)+pty(6)
     &                 ,piy(6),pny(6),pty(6)
      close(10)

      open(unit=10,file='Output_data/power_y_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(7)+pny(7)+pty(7)
     &                 ,piy(7),pny(7),pty(7)
      close(10)

      open(unit=10,file='Output_data/power_y_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(8)+pny(8)+pty(8)
     &                 ,piy(8),pny(8),pty(8)
      close(10)

      open(unit=10,file='Output_data/power_y_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(9)+pny(9)+pty(9)
     &                 ,piy(9),pny(9),pty(9)
      close(10)

      open(unit=10,file='Output_data/power_y_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(10)+pny(10)+pty(10)
     &                 ,piy(10),pny(10),pty(10)
      close(10)

      open(unit=10,file='Output_data/power_y_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(11)+pny(11)+pty(11)
     &                 ,piy(11),pny(11),pty(11)
      close(10)

      open(unit=10,file='Output_data/power_y_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(12)+pny(12)+pty(12)
     &                 ,piy(12),pny(12),pty(12)
      close(10)

      open(unit=10,file='Output_data/power_y_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(13)+pny(13)+pty(13)
     &                 ,piy(13),pny(13),pty(13)
      close(10)

      open(unit=10,file='Output_data/power_y_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(14)+pny(14)+pty(14)
     &                 ,piy(14),pny(14),pty(14)
      close(10)

      open(unit=10,file='Output_data/power_y_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(15)+pny(15)+pty(15)
     &                 ,piy(15),pny(15),pty(15)
      close(10)

      open(unit=10,file='Output_data/power_y_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(16)+pny(16)+pty(16)
     &                 ,piy(16),pny(16),pty(16)
      close(10)

      open(unit=10,file='Output_data/power_y_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(17)+pny(17)+pty(17)
     &                 ,piy(17),pny(17),pty(17)
      close(10)

      open(unit=10,file='Output_data/power_y_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(18)+pny(18)+pty(18)
     &                 ,piy(18),pny(18),pty(18)
      close(10)

      open(unit=10,file='Output_data/power_y_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(19)+pny(19)+pty(19)
     &                 ,piy(19),pny(19),pty(19)
      close(10)

      open(unit=10,file='Output_data/power_y_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(20)+pny(20)+pty(20)
     &                 ,piy(20),pny(20),pty(20)
      close(10)

      open(unit=10,file='Output_data/power_y_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piy(21)+pny(21)+pty(21)
     &                 ,piy(21),pny(21),pty(21)
      close(10)

* z
       pz000=0.0d0
      piz000=0.0d0
      pnz000=0.0d0
      ptz000=0.0d0
      do j=1,numb
       pz000 =  pz000 + piz(j)+pnz(j)+ptz(j)
      piz000 = piz000 + piz(j)
      pnz000 = pnz000 + pnz(j)
      ptz000 = ptz000 + ptz(j)
      end do

       pz001=0.0d0
      piz001=0.0d0
      pnz001=0.0d0
      ptz001=0.0d0
      do j=1,9
       pz001 =  pz001 + piz(j)+pnz(j)+ptz(j)
      piz001 = piz001 + piz(j)
      pnz001 = pnz001 + pnz(j)
      ptz001 = ptz001 + ptz(j)
      end do

       pz002=0.0d0
      piz002=0.0d0
      pnz002=0.0d0
      ptz002=0.0d0
      do j=16,20,2
       pz002 =  pz002 + piz(j)+pnz(j)+ptz(j)
      piz002 = piz002 + piz(j)
      pnz002 = pnz002 + pnz(j)
      ptz002 = ptz002 + ptz(j)
      end do

       pz003=0.0d0
      piz003=0.0d0
      pnz003=0.0d0
      ptz003=0.0d0
      do j=17,21,2
       pz003 =  pz003 + piz(j)+pnz(j)+ptz(j)
      piz003 = piz003 + piz(j)
      pnz003 = pnz003 + pnz(j)
      ptz003 = ptz003 + ptz(j)
      end do

       pz004=0.0d0
      piz004=0.0d0
      pnz004=0.0d0
      ptz004=0.0d0
      do j=10,14,2
       pz004 =  pz004 + piz(j)+pnz(j)+ptz(j)
      piz004 = piz004 + piz(j)
      pnz004 = pnz004 + pnz(j)
      ptz004 = ptz004 + ptz(j)
      end do

       pz005=0.0d0
      piz005=0.0d0
      pnz005=0.0d0
      ptz005=0.0d0
      do j=11,15,2
       pz005 =  pz005 + piz(j)+pnz(j)+ptz(j)
      piz005 = piz005 + piz(j)
      pnz005 = pnz005 + pnz(j)
      ptz005 = ptz005 + ptz(j)
      end do

      open(unit=10,file='Output_data/power_z_000whole_body.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz000,piz000,pnz000,ptz000
      close(10)

      open(unit=10,file='Output_data/power_z_001trunk_with_head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz001,piz001,pnz001,ptz001
      close(10)

      open(unit=10,file='Output_data/power_z_002right_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz002,piz002,pnz002,ptz002
      close(10)

      open(unit=10,file='Output_data/power_z_003left_upper_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz003,piz003,pnz003,ptz003
      close(10)

      open(unit=10,file='Output_data/power_z_004right_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz004,piz004,pnz004,ptz004
      close(10)

      open(unit=10,file='Output_data/power_z_005left_lower_limb.dat'
     &            ,status='old',access='append')
      write(10,9000) t, pz005,piz005,pnz005,ptz005
      close(10)

      open(unit=10,file='Output_data/power_z_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(1)+pnz(1)+ptz(1)
     &                 ,piz(1),pnz(1),ptz(1)
      close(10)

      open(unit=10,file='Output_data/power_z_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(2)+pnz(2)+ptz(2)
     &                 ,piz(2),pnz(2),ptz(2)
      close(10)

      open(unit=10,file='Output_data/power_z_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(3)+pnz(3)+ptz(3)
     &                 ,piz(3),pnz(3),ptz(3)
      close(10)

      open(unit=10,file='Output_data/power_z_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(4)+pnz(4)+ptz(4)
     &                 ,piz(4),pnz(4),ptz(4)
      close(10)

      open(unit=10,file='Output_data/power_z_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(5)+pnz(5)+ptz(5)
     &                 ,piz(5),pnz(5),ptz(5)
      close(10)

      open(unit=10,file='Output_data/power_z_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(6)+pnz(6)+ptz(6)
     &                 ,piz(6),pnz(6),ptz(6)
      close(10)

      open(unit=10,file='Output_data/power_z_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(7)+pnz(7)+ptz(7)
     &                 ,piz(7),pnz(7),ptz(7)
      close(10)

      open(unit=10,file='Output_data/power_z_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(8)+pnz(8)+ptz(8)
     &                 ,piz(8),pnz(8),ptz(8)
      close(10)

      open(unit=10,file='Output_data/power_z_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(9)+pnz(9)+ptz(9)
     &                 ,piz(9),pnz(9),ptz(9)
      close(10)

      open(unit=10,file='Output_data/power_z_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(10)+pnz(10)+ptz(10)
     &                 ,piz(10),pnz(10),ptz(10)
      close(10)

      open(unit=10,file='Output_data/power_z_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(11)+pnz(11)+ptz(11)
     &                 ,piz(11),pnz(11),ptz(11)
      close(10)

      open(unit=10,file='Output_data/power_z_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(12)+pnz(12)+ptz(12)
     &                 ,piz(12),pnz(12),ptz(12)
      close(10)

      open(unit=10,file='Output_data/power_z_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(13)+pnz(13)+ptz(13)
     &                 ,piz(13),pnz(13),ptz(13)
      close(10)

      open(unit=10,file='Output_data/power_z_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(14)+pnz(14)+ptz(14)
     &                 ,piz(14),pnz(14),ptz(14)
      close(10)

      open(unit=10,file='Output_data/power_z_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(15)+pnz(15)+ptz(15)
     &                 ,piz(15),pnz(15),ptz(15)
      close(10)

      open(unit=10,file='Output_data/power_z_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(16)+pnz(16)+ptz(16)
     &                 ,piz(16),pnz(16),ptz(16)
      close(10)

      open(unit=10,file='Output_data/power_z_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(17)+pnz(17)+ptz(17)
     &                 ,piz(17),pnz(17),ptz(17)
      close(10)

      open(unit=10,file='Output_data/power_z_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(18)+pnz(18)+ptz(18)
     &                 ,piz(18),pnz(18),ptz(18)
      close(10)

      open(unit=10,file='Output_data/power_z_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(19)+pnz(19)+ptz(19)
     &                 ,piz(19),pnz(19),ptz(19)
      close(10)

      open(unit=10,file='Output_data/power_z_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(20)+pnz(20)+ptz(20)
     &                 ,piz(20),pnz(20),ptz(20)
      close(10)

      open(unit=10,file='Output_data/power_z_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, piz(21)+pnz(21)+ptz(21)
     &                 ,piz(21),pnz(21),ptz(21)
      close(10)

      return
      end

****************
* Joint torque *
****************
      subroutine outjoint(numb,t,mxup,myup,mzup,mxdw,mydw,mzdw
     &                    ,mxbup,mybup,mzbup,mxbdw,mybdw,mzbdw)
      implicit double precision(a-z)
      integer numb
      double precision mxup(numb),myup(numb),mzup(numb)
     &                ,mxdw(numb),mydw(numb),mzdw(numb)
     &                ,mxbup(numb),mybup(numb),mzbup(numb)
     &                ,mxbdw(numb),mybdw(numb),mzbdw(numb)

 9000 format(1p4e17.8)

* x
      open(unit=10,file='Output_data/joint_torque_x_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(1)-mxdw(1))*0.5d0, mxup(1),-mxdw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(2)-mxdw(2))*0.5d0, mxup(2),-mxdw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(3)-mxdw(3))*0.5d0, mxup(3),-mxdw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(4)-mxdw(4))*0.5d0, mxup(4),-mxdw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(5)-mxdw(5))*0.5d0, mxup(5),-mxdw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(6)-mxdw(6))*0.5d0, mxup(6),-mxdw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(7)-mxdw(7))*0.5d0, mxup(7),-mxdw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(8)-mxdw(8))*0.5d0, mxup(8),-mxdw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(9)-mxdw(9))*0.5d0, mxup(9),-mxdw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(10)-mxdw(10))*0.5d0, mxup(10),-mxdw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(11)-mxdw(11))*0.5d0, mxup(11),-mxdw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(12)-mxdw(12))*0.5d0, mxup(12),-mxdw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(13)-mxdw(13))*0.5d0, mxup(13),-mxdw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(14)-mxdw(14))*0.5d0, mxup(14),-mxdw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(15)-mxdw(15))*0.5d0, mxup(15),-mxdw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_x_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(16)-mxdw(16))*0.5d0, mxup(16),-mxdw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_x_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(17)-mxdw(17))*0.5d0, mxup(17),-mxdw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_x_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(18)-mxdw(18))*0.5d0, mxup(18),-mxdw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(19)-mxdw(19))*0.5d0, mxup(19),-mxdw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(20)-mxdw(20))*0.5d0, mxup(20),-mxdw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_x_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxup(21)-mxdw(21))*0.5d0, mxup(21),-mxdw(21)
      close(10)

* y
      open(unit=10,file='Output_data/joint_torque_y_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(1)-mydw(1))*0.5d0, myup(1),-mydw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(2)-mydw(2))*0.5d0, myup(2),-mydw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(3)-mydw(3))*0.5d0, myup(3),-mydw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(4)-mydw(4))*0.5d0, myup(4),-mydw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(5)-mydw(5))*0.5d0, myup(5),-mydw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(6)-mydw(6))*0.5d0, myup(6),-mydw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(7)-mydw(7))*0.5d0, myup(7),-mydw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(8)-mydw(8))*0.5d0, myup(8),-mydw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(9)-mydw(9))*0.5d0, myup(9),-mydw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(10)-mydw(10))*0.5d0, myup(10),-mydw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(11)-mydw(11))*0.5d0, myup(11),-mydw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(12)-mydw(12))*0.5d0, myup(12),-mydw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(13)-mydw(13))*0.5d0, myup(13),-mydw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(14)-mydw(14))*0.5d0, myup(14),-mydw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(15)-mydw(15))*0.5d0, myup(15),-mydw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_y_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(16)-mydw(16))*0.5d0, myup(16),-mydw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_y_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(17)-mydw(17))*0.5d0, myup(17),-mydw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_y_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(18)-mydw(18))*0.5d0, myup(18),-mydw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(19)-mydw(19))*0.5d0, myup(19),-mydw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(20)-mydw(20))*0.5d0, myup(20),-mydw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_y_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (myup(21)-mydw(21))*0.5d0, myup(21),-mydw(21)
      close(10)

* z
      open(unit=10,file='Output_data/joint_torque_z_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(1)-mzdw(1))*0.5d0, mzup(1),-mzdw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(2)-mzdw(2))*0.5d0, mzup(2),-mzdw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(3)-mzdw(3))*0.5d0, mzup(3),-mzdw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(4)-mzdw(4))*0.5d0, mzup(4),-mzdw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(5)-mzdw(5))*0.5d0, mzup(5),-mzdw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(6)-mzdw(6))*0.5d0, mzup(6),-mzdw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(7)-mzdw(7))*0.5d0, mzup(7),-mzdw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(8)-mzdw(8))*0.5d0, mzup(8),-mzdw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(9)-mzdw(9))*0.5d0, mzup(9),-mzdw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(10)-mzdw(10))*0.5d0, mzup(10),-mzdw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(11)-mzdw(11))*0.5d0, mzup(11),-mzdw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(12)-mzdw(12))*0.5d0, mzup(12),-mzdw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(13)-mzdw(13))*0.5d0, mzup(13),-mzdw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(14)-mzdw(14))*0.5d0, mzup(14),-mzdw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(15)-mzdw(15))*0.5d0, mzup(15),-mzdw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_z_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(16)-mzdw(16))*0.5d0, mzup(16),-mzdw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_z_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(17)-mzdw(17))*0.5d0, mzup(17),-mzdw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_z_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(18)-mzdw(18))*0.5d0, mzup(18),-mzdw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(19)-mzdw(19))*0.5d0, mzup(19),-mzdw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(20)-mzdw(20))*0.5d0, mzup(20),-mzdw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_z_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzup(21)-mzdw(21))*0.5d0, mzup(21),-mzdw(21)
      close(10)

* xb
      open(unit=10,file='Output_data/joint_torque_xb_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(1)-mxbdw(1))*0.5d0, mxbup(1),-mxbdw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(2)-mxbdw(2))*0.5d0, mxbup(2),-mxbdw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(3)-mxbdw(3))*0.5d0, mxbup(3),-mxbdw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(4)-mxbdw(4))*0.5d0, mxbup(4),-mxbdw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(5)-mxbdw(5))*0.5d0, mxbup(5),-mxbdw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(6)-mxbdw(6))*0.5d0, mxbup(6),-mxbdw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(7)-mxbdw(7))*0.5d0, mxbup(7),-mxbdw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(8)-mxbdw(8))*0.5d0, mxbup(8),-mxbdw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(9)-mxbdw(9))*0.5d0, mxbup(9),-mxbdw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(10)-mxbdw(10))*0.5d0,mxbup(10),-mxbdw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(11)-mxbdw(11))*0.5d0,mxbup(11),-mxbdw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(12)-mxbdw(12))*0.5d0,mxbup(12),-mxbdw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(13)-mxbdw(13))*0.5d0,mxbup(13),-mxbdw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(14)-mxbdw(14))*0.5d0,mxbup(14),-mxbdw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(15)-mxbdw(15))*0.5d0,mxbup(15),-mxbdw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_xb_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(16)-mxbdw(16))*0.5d0,mxbup(16),-mxbdw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_xb_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(17)-mxbdw(17))*0.5d0,mxbup(17),-mxbdw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_xb_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(18)-mxbdw(18))*0.5d0,mxbup(18),-mxbdw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(19)-mxbdw(19))*0.5d0,mxbup(19),-mxbdw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(20)-mxbdw(20))*0.5d0,mxbup(20),-mxbdw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_xb_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mxbup(21)-mxbdw(21))*0.5d0,mxbup(21),-mxbdw(21)
      close(10)

* yb
      open(unit=10,file='Output_data/joint_torque_yb_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(1)-mybdw(1))*0.5d0, mybup(1),-mybdw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(2)-mybdw(2))*0.5d0, mybup(2),-mybdw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(3)-mybdw(3))*0.5d0, mybup(3),-mybdw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(4)-mybdw(4))*0.5d0, mybup(4),-mybdw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(5)-mybdw(5))*0.5d0, mybup(5),-mybdw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(6)-mybdw(6))*0.5d0, mybup(6),-mybdw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(7)-mybdw(7))*0.5d0, mybup(7),-mybdw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(8)-mybdw(8))*0.5d0, mybup(8),-mybdw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(9)-mybdw(9))*0.5d0, mybup(9),-mybdw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(10)-mybdw(10))*0.5d0,mybup(10),-mybdw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(11)-mybdw(11))*0.5d0,mybup(11),-mybdw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(12)-mybdw(12))*0.5d0,mybup(12),-mybdw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(13)-mybdw(13))*0.5d0,mybup(13),-mybdw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(14)-mybdw(14))*0.5d0,mybup(14),-mybdw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(15)-mybdw(15))*0.5d0,mybup(15),-mybdw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_yb_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(16)-mybdw(16))*0.5d0,mybup(16),-mybdw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_yb_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(17)-mybdw(17))*0.5d0,mybup(17),-mybdw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_yb_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(18)-mybdw(18))*0.5d0,mybup(18),-mybdw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(19)-mybdw(19))*0.5d0,mybup(19),-mybdw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(20)-mybdw(20))*0.5d0,mybup(20),-mybdw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_yb_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mybup(21)-mybdw(21))*0.5d0,mybup(21),-mybdw(21)
      close(10)

* zb
      open(unit=10,file='Output_data/joint_torque_zb_01lower_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(1)-mzbdw(1))*0.5d0, mzbup(1),-mzbdw(1)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_02upper_waist.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(2)-mzbdw(2))*0.5d0, mzbup(2),-mzbdw(2)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_03lower_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(3)-mzbdw(3))*0.5d0, mzbup(3),-mzbdw(3)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_04upper_breast.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(4)-mzbdw(4))*0.5d0, mzbup(4),-mzbdw(4)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_05shoulder.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(5)-mzbdw(5))*0.5d0, mzbup(5),-mzbdw(5)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_06neck.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(6)-mzbdw(6))*0.5d0, mzbup(6),-mzbdw(6)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_07head.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(7)-mzbdw(7))*0.5d0, mzbup(7),-mzbdw(7)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_08upper_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(8)-mzbdw(8))*0.5d0, mzbup(8),-mzbdw(8)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_09lower_hip.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(9)-mzbdw(9))*0.5d0, mzbup(9),-mzbdw(9)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_10right_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(10)-mzbdw(10))*0.5d0,mzbup(10),-mzbdw(10)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_11left_thigh.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(11)-mzbdw(11))*0.5d0,mzbup(11),-mzbdw(11)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_12right_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(12)-mzbdw(12))*0.5d0,mzbup(12),-mzbdw(12)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_13left_shank.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(13)-mzbdw(13))*0.5d0,mzbup(13),-mzbdw(13)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_14right_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(14)-mzbdw(14))*0.5d0,mzbup(14),-mzbdw(14)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_15left_foot.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(15)-mzbdw(15))*0.5d0,mzbup(15),-mzbdw(15)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_zb_16right_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(16)-mzbdw(16))*0.5d0,mzbup(16),-mzbdw(16)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_zb_17left_upper_arm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(17)-mzbdw(17))*0.5d0,mzbup(17),-mzbdw(17)
      close(10)

      open(unit=10
     &    ,file='Output_data/joint_torque_zb_18right_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(18)-mzbdw(18))*0.5d0,mzbup(18),-mzbdw(18)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_19left_forearm.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(19)-mzbdw(19))*0.5d0,mzbup(19),-mzbdw(19)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_20right_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(20)-mzbdw(20))*0.5d0,mzbup(20),-mzbdw(20)
      close(10)

      open(unit=10,file='Output_data/joint_torque_zb_21left_hand.dat'
     &            ,status='old',access='append')
      write(10,9000) t, (mzbup(21)-mzbdw(21))*0.5d0,mzbup(21),-mzbdw(21)
      close(10)


      return
      end
