      parameter(MOB=150,MEV=21,MFQ=17)

      implicit real*8 (a-h,o-z)
      dimension d(MOB),q(MOB,MFQ),f(MFQ),f1(MFQ),q1(MOB,MFQ)
      character a*10,INFILE1(MEV)*100,OTFILE1(MEV)*100,OTFILE2(MEV)*100,
     &          INFILE2*6,OTFILE3*7,OTFILE4*10,INFILE3(MEV)*100
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      NEV=MEV

      NDATA=2048

      DT=0.005d0

      DF=1.d0/(dfloat(NDATA)*DT)

      PI=dacos(-1.d0)

      a='0123456789'

      INFILE2='f1.txt'
      OTFILE3='q16.inp'
      OTFILE4='qout16.inp'
      open(12,file=INFILE2,status='old')
      open(16,file=OTFILE3)
      open(17,file=OTFILE4)

      read(12,*)(f1(k),k=1,MFQ)
      close(12)

      do 1 j=1,17
         f(j)=f1(j)*DF
1     continue


      do 100 iEV=1,NEV

cccc ループから外すもの（対象外） cccc
         if (iEV.eq.12) then
            goto 100
         else if (iEV.eq.13) then
            goto 100
         else if (iEV.eq.14) then
            goto 100
         else if (iEV.eq.15) then
            goto 100
         else if (iEV.eq.16) then
            goto 100
         endif
cccccccccccccccccccccccccccccccccccccc

         if (iEV.lt.10) then
            INFILE1(iEV)='d'//a(iEV+1:iEV+1)//'.inp'
            INFILE3(iEV)='rd'//a(iEV+1:iEV+1)//'.inp'
            OTFILE1(iEV)='q'//a(iEV+1:iEV+1)//'out'
            OTFILE2(iEV)='outq'//a(iEV+1:iEV+1)
         else if (iEV.ge.10.and.iEV.lt.20) then
            INFILE1(iEV)='d1'//a(iEV-9:iEV-9)//'.inp'
            INFILE3(iEV)='rd1'//a(iEV-9:iEV-9)//'.inp'
            OTFILE1(iEV)='q1'//a(iEV-9:iEV-9)//'out'
            OTFILE2(iEV)='outq1'//a(iEV-9:iEV-9)
         else if (iEV.ge.20.and.iEV.lt.30) then
            INFILE1(iEV)='d2'//a(iEV-19:iEV-19)//'.inp'
            INFILE3(iEV)='rd2'//a(iEV-19:iEV-19)//'.inp'
            OTFILE1(iEV)='q2'//a(iEV-19:iEV-19)//'out'
            OTFILE2(iEV)='outq2'//a(iEV-19:iEV-19)
         endif
         call CountNumberOfChracters(INFILE1,iEV,1,iend1,MEV)
         call CountNumberOfChracters(OTFILE1,iEV,1,iend2,MEV)
         call CountNumberOfChracters(OTFILE2,iEV,1,iend3,MEV)
         call CountNumberOfChracters(INFILE3,iEV,1,iend4,MEV)

         open(11,file=INFILE1(iEV)(1:iend1),status='old')
         open(13,file=INFILE3(iEV)(1:iend4),status='old')
         open(14,file=OTFILE1(iEV)(1:iend2))
         open(15,file=OTFILE2(iEV)(1:iend3))

c     read(11,*)(d(j),j=1,num)

      j=1
3     read(11,*,end=4)d(j)
         j=j+1
      goto 3
4     close(11)
      N=j-1


      read(13,*)rd
      close(13)


      do 11 k=1,MFQ
         do 12 l=1,N
            q(l,k)=(dlog10(dexp(1.d0)))*((PI*f(k)*d(l))/3.7d0)
            q1(l,k)=(dlog10(dexp(1.d0)))*((PI*f(k)*rd)/3.7d0)
12       continue
11    continue

      do 2 l=1,N
         write(14,1000)(q(l,m),m=1,MFQ)
         write(15,1010)(q1(l,m),m=1,MFQ)
         write(16,1000)(q(l,m),m=1,MFQ)
         write(17,1000)(q1(l,m),m=1,MFQ)
c         write(6,*)f(2)
2     continue
      close(14)
      close(15)
1000  format(17f10.5)
1010  format(17f10.5)


100   continue

      close(16)
      close(17)

      stop

      end




C***********************************************************************
      subroutine CountNumberOfChracters(a,n,istart,iend,MEV)
C***********************************************************************

      implicit real*8(a-h,o-z)

      character a(MEV)*100

      do 100 i=istart,100
         if (a(n)(i:i).eq.',') then
            go to 1
         else if (a(n)(i:i).eq.'') then
            go to 1
         end if
100   continue
1     iend=i-1

      return
      end








