c-------------------------------------------------------------------------------
c
c     SUBRUTINAS
c                   
c-------------------------------------------------------------------------------

c______________________________________________________________________LeeMatriz
      Subroutine LeeMatriz(logr,nf,nc,x)
      implicit real*8 (a-h,o-z)
      dimension x(nf,nc)

      do k=1,nf*nc
        read(logr,102) i,j,x(i,j)
      enddo
  102 format(2i5,d15.6)

      return
      end

c__________________________________________________________________EscribeMatriz
      Subroutine EscribeMatriz(logw,nf,nc,x)
      implicit real*8 (a-h,o-z)
      dimension x(nf,nc)

      do j=1,nc
        do i=1,nf
          write(logw,202) i,j,x(i,j)
        enddo
      enddo
  202 format(2i5,d15.6)

      return
      end

c_____________________________________________________________MultiplicaMatrices
      Subroutine MultiplicaMatrices(nfa,nca,a,nfb,ncb,b,nfc,ncc,c)
      implicit real*8 (a-h,o-z)
      dimension a(nfa,nca), b(nfb,ncb), c(nfc,ncc)

      if (nca.ne.nfb) call ErrorFatal('nca y nfb no coinciden')
      if (nfa.ne.nfc) call ErrorFatal('nfa y nfc no coinciden')
      if (ncb.ne.ncc) call ErrorFatal('ncb y ncc no coinciden')

      do j=1,ncc
        do i=1,nfc
          c(i,j)=0.d+00
          do k=1,nca
            c(i,j)=c(i,j)+a(i,k)*b(k,j)
          enddo
        enddo
      enddo

      return
      end

c_____________________________________________________________________ErrorFatal
      Subroutine ErrorFatal(mensaje)
      character*(*) mensaje

      write(6,100) mensaje
  100 format(' Error: ',a)

      stop
      end

