program vettori implicit none real,allocatable,dimension(:)::x,y,c,d,e,c95,d95,e95 integer::i,n interface subroutine readdatiterm (x,y,n) integer,intent(out):: n real,allocatable ,dimension(:)::x,y end subroutine readdatiterm end interface call readdatiterm (x,y,n) allocate(c(n),d(n),e(n)) allocate(c95(n),d95(n),e95(n)) do i=1,n c(i)=x(i)+y(i) d(i)=x(i)*y(i) e(i)=sqrt(x(i)**2+y(i)**2) enddo c95=0 c95(1:3)=x(1:3)+y(1:3) d95=x*y e95=sqrt(x**2+y**2) write(6,"('----------------------------------------------------------------------------------')") write(6,"(' X Y C C95 D D95 E E95')") write(6,"('----------------------------------------------------------------------------------')") do i=1,n write(6,200)x(i),y(i),c(i),c95(i),d(i),d95(i),e(i),e95(i) 200 format(2f8.3,6e11.3) enddo end subroutine readdatiterm (x,y,n) implicit none integer,intent(out):: n real,allocatable ,dimension(:)::x,y real:: xx,yy character (len=30)::nomefile integer::i,ierr 23 write(6,*)'Nome file' read(5,'(a)')nomefile open(unit=50,file=nomefile,status='old',err=23) i=1 read(50,*,iostat=ierr) xx,yy do while(ierr == 0) i=i+1 read(50,*,iostat=ierr) xx,yy enddo if (ierr > 0) then write(6,*)'Errore numero:', ierr stop endif n=i-1 rewind(50) write(6,*) 'primo giro :n =',n allocate (x(n),y(n)) do i=1,n read(50,*) x(i),y(i) enddo close(50) end subroutine readdatiterm