      parameter (MDT=2300,MFQ=17)

      implicit real*8(a-h,o-z) 
      dimension f1(MDT),m1(MDT),da(MDT),r(MDT),ref(1),rad(MDT),
     *              geo(MDT)
      real m1
      character INFILE1(MFQ)*100,INFILE2(MFQ)*100,INFILE3(MFQ)*100,
     &          INFILE4(MFQ)*100,INFILE5(MFQ)*100,
     &          OTFILE1(MFQ)*100,a*10
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      NLP=MFQ+10

      a='0123456789'

      open(17,file='16data1.inp')

      do 110 iLP=11,NLP

cccccccccccccccccccccccccccccccccccccc

         if (iLP.lt.10) then
            INFILE1(iLP-10)='fort.'//a(iLP+1:iLP+1)
            INFILE2(iLP-10)='fort.'//a(iLP+1:iLP+1)//'m1'
            INFILE3(iLP-10)='dis16.inp'
            INFILE4(iLP-10)='ref.inp'
            INFILE5(iLP-10)='rad16.inp'
            OTFILE1(iLP-10)=a(iLP+1:iLP+1)//'.inp1'
         else if (iLP.ge.10.and.iLP.lt.20) then
            INFILE1(iLP-10)='fort.1'//a(iLP-9:iLP-9)
            INFILE2(iLP-10)='fort.1'//a(iLP-9:iLP-9)//'m1'
            INFILE3(iLP-10)='dis16.inp'
            INFILE4(iLP-10)='ref.inp'
            INFILE5(iLP-10)='rad16.inp'
            OTFILE1(iLP-10)='1'//a(iLP-9:iLP-9)//'.inp1'
         else if (iLP.ge.20.and.iLP.lt.30) then
            INFILE1(iLP-10)='fort.2'//a(iLP-19:iLP-19)
            INFILE2(iLP-10)='fort.2'//a(iLP-19:iLP-19)//'m1'
            INFILE3(iLP-10)='dis16.inp'
            INFILE4(iLP-10)='ref.inp'
            INFILE5(iLP-10)='rad16.inp'
            OTFILE1(iLP-10)='2'//a(iLP-19:iLP-19)//'.inp1'
         endif

         call CountNumberOfChracters(INFILE1,iLP-10,1,iend1,MFQ)
         call CountNumberOfChracters(INFILE2,iLP-10,1,iend2,MFQ)
         call CountNumberOfChracters(INFILE3,iLP-10,1,iend3,MFQ)
         call CountNumberOfChracters(INFILE4,iLP-10,1,iend4,MFQ)
         call CountNumberOfChracters(INFILE5,iLP-10,1,iend5,MFQ)
         call CountNumberOfChracters(OTFILE1,iLP-10,1,iend6,MFQ)


         open(10,file=INFILE1(iLP-10)(1:iend1),status='old')
         open(11,file=INFILE2(iLP-10)(1:iend2),status='old')
         open(12,file=INFILE3(iLP-10)(1:iend3),status='old')
         open(13,file=INFILE4(iLP-10)(1:iend4),status='old')
         open(14,file=INFILE5(iLP-10)(1:iend5),status='old')
         open(15,file=OTFILE1(iLP-10)(1:iend6))


      i=1
1     read(10,*,end=2)f1(i)
      i=i+1
      goto 1
2     close(10)
      N=i-1

      read(11,*)(m1(l),l=1,N)
      close(11)
      read(12,*)(r(m),m=1,N)
      close(12)
      read(13,*)ref(1)
      close(13)
      read(14,*)(rad(i),i=1,N)
      close(14)
      do i=1,N
c          da(i)=dlog10((f1(i)*r(i))/2.d0)-m1(i)-dlog10(rad(1))
c          da(i)=dlog10((f1(i)*r(i))/2.d0)+m1(i)-dlog10(rad(1))
c          da(i)=dlog10((f1(i)*r(i)))+m1(i)-dlog10(rad(1))
          da(i)=dlog10((f1(i)*r(i)))+m1(i)
          enddo
c          write(6,*)f1(1),m1(1),f(1)

c          write(6,200)f1(1),r(1),da(1),m1(1)
          write(15,100)(da(k),k=1,N)
          write(17,100)(da(k),k=1,N)
 100      format(1f10.5)
 200      format(5f10.5)
          close(15)


110   continue

      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

