c.....................................................................
c
c       Junta dois ficheiros escritos em formato fixo com o mesmo
c       numero de linhas
c
c.....................................................................
c
        character linha1*100,linha2*100
        character*72 file_mag,file_igrf,file_out
c
        namelist /par/ file_mag,file_igrf,file_out,nc11,nc12,nc21,nc22
c....................................................................... 
        open(unit=10, file='mag02.in', status='old')
        read(10,par)
        close(10)
c
        open(9,file=file_mag,status='old')
        open(10,file=file_igrf,status='old')
        open(11,file=file_out,status='unknown')
c
        ipon=0
        do 1 i=1,1000000
          read(9,'(a)',err=1,end=2) linha1
          read(10,'(a)',err=1,end=2) linha2
          ipon=ipon+1
          write(11,'(a)') linha1(nc11:nc12)//linha2(nc21:nc22)
1       continue
2       npon=ipon
        write(*,*) npon,'points found'
        close(9)
        close(10)
c
999     stop
        end
