***********************************************************************
*
*     Anaysis parameter reading part for Swumsuit
*                                          since 2004.12.2
*                                         (c) Motomu Nakashima 
*
***********************************************************************
      implicit double precision(a-z)
      integer numb,conam,multi
      integer i,numl,numl1,numl2,numld2,lastloop,div,divr,divt,numsp
      integer flagoutr,flagoutf,flagoutj,flagouta,flagpene(0:10)
      integer flagoutm
      integer comsolv,vgxsolv,vgysolv,vgzsolv,ome1solv,ome2solv,ome3solv
      character*10 chars
      double precision inipos(3),inidirec(3,3),inivel(3),iniavel(3)
      double precision cn(21),cs(21),ca(21),pcn

 1000 format(a10)

*********
* multi *
*********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."multi=") goto 125
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  125 continue
      read(23,*) multi
      close(unit=23)

*********
* conam *
*********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."conam=") goto 124
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  124 continue
      read(23,*) conam
      close(unit=23)

********
* numb *
********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."numb=") goto 123
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  123 continue
      read(23,*) numb
      close(unit=23)

********************
* numl,numl1,numl2 *
********************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."time_step=") goto 101
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  101 continue
      read(23,*) numld2
      close(unit=23)
      numl=numld2*2
      numl1=numl+1
      numl2=numl+2


*********
* cycle *
*********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."cycle=") goto 102
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  102 continue
      read(23,*) cycle
      close(unit=23)

************
* drag_gli *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."drag_gli=") goto 103
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  103 continue
      read(23,*) draggli

******
* cn *
******
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."cn_list=") goto 104
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  104 continue
      do i=1,21
          read(23,*) cn(i)
      enddo
      close(unit=23)

******
* cs *
******
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."ct_list=") goto 105
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  105 continue
      do i=1,21
          read(23,*) cs(i)
      enddo
      close(unit=23)

******
* ca *
******
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."ca_list=") goto 106
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  106 continue
      do i=1,21
          read(23,*) ca(i)
      enddo
      close(unit=23)

************
* lastloop *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."cycle_num=") goto 107
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  107 continue
      read(23,*) lastloop
      close(unit=23)

*******
* div *
*******
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."divl=") goto 108
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  108 continue
      read(23,*) div
      close(unit=23)

********
* divr *
********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."divr=") goto 109
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  109 continue
      read(23,*) divr
      close(unit=23)

********
* divt *
********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."divt=") goto 110
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  110 continue
      read(23,*) divt
      close(unit=23)

**********
* inipos *
**********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."inipos=") goto 111
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  111 continue
      read(23,*) inipos(1),inipos(2),inipos(3)
      close(unit=23)

************
* inidirec *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."inidirec=") goto 112
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  112 continue
      read(23,*) inidirec(1,1),inidirec(1,2),inidirec(1,3)
      read(23,*) inidirec(2,1),inidirec(2,2),inidirec(2,3)
      read(23,*) inidirec(3,1),inidirec(3,2),inidirec(3,3)
      close(unit=23)

**********
* inivel *
**********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."inivel=") goto 113
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  113 continue
      read(23,*) inivel(1),inivel(2),inivel(3)
      close(unit=23)

***********
* iniavel *
***********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."iniavel=") goto 114
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  114 continue
      read(23,*) iniavel(1),iniavel(2),iniavel(3)
      close(unit=23)

**********
* direcd *
**********
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."direcd=") goto 115
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  115 continue
      read(23,*) direcd
      close(unit=23)

************
* flagoutr *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagoutr=") goto 116
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  116 continue
      read(23,*) flagoutr
      close(unit=23)

************
* flagoutf *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagoutf=") goto 117
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  117 continue
      read(23,*) flagoutf
      close(unit=23)

************
* flagoutj *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagoutj=") goto 118
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  118 continue
      read(23,*) flagoutj
      close(unit=23)

************
* flagouta *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagouta=") goto 119
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  119 continue
      read(23,*) flagouta
      close(unit=23)

*********
* numsp *
*********
      open(unit=22,file='joint_motion.dat',status='unknown')
      read(22,*) numsp
      close(unit=22)

***********************************************************************
* motsolv(comsolv,vgxsolv,vgysolv,vgzsolv,ome1solv,ome2solv,ome3solv) *
***********************************************************************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."motsolv=") goto 120
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  120 continue
      read(23,*) comsolv
      read(23,*) vgxsolv
      read(23,*) vgysolv
      read(23,*) vgzsolv
      read(23,*) ome1solv
      read(23,*) ome2solv
      read(23,*) ome3solv
      close(unit=23)

************
* flagpene *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagpene=") goto 121
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  121 continue

      do i=0,10
      read(23,*) flagpene(i)
      enddo
      close(unit=23)


************
* flagoutm *
************
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."flagoutm=") goto 122
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  122 continue
      read(23,*) flagoutm
      close(unit=23)


*******
* pcn *
*******
      open(unit=23,file='analysis_settings.dat',status='unknown')
      do i=1,10000
          read(23,1000) chars
          if (chars.eq."pcn=") goto 126
      enddo
      write(*,*) "Parameter reading failed!"
      stop
  126 continue
      read(23,*) pcn
      close(unit=23)


*************************
* main calculation call *
*************************
      call main(multi,numb
     &         ,numl,numl1,numl2,cycle,draggli,cn,cs,ca,lastloop
     &         ,div,divr,divt,inipos,inidirec,inivel,iniavel,direcd
     &         ,flagoutr,flagoutf,flagoutj,flagouta,numsp
     &         ,comsolv,conam
     &         ,vgxsolv,vgysolv,vgzsolv,ome1solv,ome2solv,ome3solv
     &         ,flagpene,flagoutm,pcn)

      stop
      end
