ccccccc	Programa per a sumar matrius
	real*8 mat_sum,mat_i
	integer i,j,k
	integer n_arx,n_ubic,num_arxs,dmx,dmy
	character*10 lin
	character*80 arxs
	character*200 ubic0
	dimension mat_sum(300,300),mat_i(300,300),arxs(100)
	
	open(unit=1,file='inf_sumar_matrius.txt',status='old')
	read(1,10)lin
	read(1,10)lin	
	read(1,20),ubic0
	read(1,10)lin
	read(1,10)lin
	read(1,*)num_arxs
	read(1,10)lin
	read(1,10)lin
	do i=1,num_arxs
	read(1,80)arxs(i)
	enddo
	
   10	format(a10)
   20	format(a200)
   80	format(a80)	
	close(unit=1)
	dmx=161
	dmy=221

	do k=1,num_arxs-1
	call carregar_matriu_f2010(ubic0,arxs(k),dmx,dmy,mat_i)
	do i=1,dmx
	do j=1,dmy
	mat_sum(i,j)=mat_sum(i,j)+mat_i(i,j)
	enddo
	enddo
	
	n_ubic=0
	do i=1,200
	if ((ichar(ubic0(i:i))-48).ne.(-16)) n_ubic=n_ubic+1
	enddo
	
	enddo
	write(6,*)'Guardant suma a ...'//ubic0(1:n_ubic)//char(47)//
     &'Nimes_0209-TOT.plj'
	open(unit=7,file=ubic0(1:n_ubic)//char(47)//
     &'Nimes_0209-TOT.plj',status='unknown')
	do i=1,dmx
	write(7,40)(mat_sum(i,j),j=1,dmy)
   40	format(300(f20.10,1x))
	enddo
	
	close(unit=7)
	end
	
	
ccccccc	SUBROUTINA per a carregar una matriu en memoria
	subroutine carregar_matriu_f2010(ubic,ar,dx,dy,mat)
	real*8 mat
	integer i,j
	integer n_ar,n_ubic,dx,dy
	character*80 ar
	character*200 ubic
	dimension mat(300,300)
	
	n_ar=0
	do i=1,80
	if ((ichar(ar(i:i))-48).ne.(-16)) n_ar=n_ar+1
	enddo
	
	n_ubic=0
	do i=1,200
	if ((ichar(ubic(i:i))-48).ne.(-16)) n_ubic=n_ubic+1
	enddo
	
	write(6,*)'Carregant ....'//ubic(1:n_ubic)//char(47)//ar(1:n_ar)
	open(unit=8,file=ubic(1:n_ubic)//char(47)//ar(1:n_ar),
     &status='old')
	do i=1,dx
	read(8,10)(mat(i,j),j=1,dy)
   10	format(300(f20.10,1x))	
	enddo
	
	close(unit=8)
	
	end
