	character*8 filin
	character*80 ligne
	real*8 alat,along,alat1,along1
	open(8,file='convert.in')
	i1=2
30	write (*,*) 'entrer nom de fichier (fin por finir)'
	read(*,'(a8)') filin
	if (filin.eq.'fin') goto 40
	write(*,*) filin
	open (9, file=filin,status='old')
	n=0
	alat1=0.
	along1=0.
	haut1=0.
20	read(9,'(29x,2I3,F10.2)',end=10) ilat,ilatmin,secla
	read(9,'(29x,2I3,F10.2)',end=10) ilong,ilongmin,seclon
	read (9,'(a80)') ligne
	read(9,'(29x,f9.2)',end=10) haut
	ilatmin=sign(ilatmin,ilat)
	secla=sign(secla,ilat)
	ilongmin=sign(ilongmin,ilong)
	seclon=sign(seclon,ilong)
	 write(*,*) ilat,ilatmin,secla,ilong,ilongmin,seclon,haut	
	alat=ilat+(ilatmin +secla*1/60)*1/60
	along=ilong+(ilongmin+seclon*1/60)*1/60
	alat1=alat1+alat
	along1=along1+along
	haut1=haut1+haut
	n=n+1
	go to 20
10	alat1=alat1/n
	along1=along1/n
	ilat1=int(alat1)
	ilatmin1=int((alat1-ilat1)*60)
	secla1=((alat1-ilat1)*60-ilatmin1)*60
	ilong1=int(along1)
	ilongmin1=int((along1-ilong1)*60)
	seclon1=((along1-ilong1)*60-ilongmin1)*60
	haut1=haut1/n
	write (*,*) 'position moyenne',ilat1,ilatmin1,secla1,ilong1,ilongmin1,seclon1,haut1
	write(8,'(i1)') i1
	write(8,'(i1)') i1
	write (8,'(2i4,f12.3)') ilat1,ilatmin1,secla1
	write (8,'(2i4,f12.3)') ilong1,ilongmin1,seclon1
	write(8,'(f10.3)') haut1	
	go to 30
40	stop	
	end	
