!
use msflib ! biblioteca que contem o comando systemqq
logical chamada
!
      parameter(npar=500)   
      dimension x(npar),y(npar),y2(npar)
      open (unit=1,file='inp1.txt')
!
!     input data
!
      open (9,file='inptab.dat')
!
!     output resulting curve data
!
      open (3,file='outcarro.dat') 
!
!
!****************************************
!
      read(1,*) n2,npontos
      write(*,*)'n2=',n2,'; npontos=',npontos
!
!******************************
!
!
!     read table of data
!
      do i=1,n2
         read(9,*) x(i),y(i)
      enddo
      y1=(y(2)-y(1))/(x(2)-x(1))
      yn=(y(n2)-y(n2-1))/(x(n2)-x(n2-1))
      call spline(x,y,n2,y1,yn,y2)
	dx=(x(n2)-x(1))/npontos
	xi=x(1)
	do i=1,npontos+1
		call splint(x,y,y2,n2,xi,yi)
		write(3,*)xi,yi
		xi=xi+dx
	enddo

! Avaliar a funcao em um ponto qualquer (xi,yi)

	xi=80.
	call splint(x,y,y2,n2,xi,yi)
		write(*,*)xi,yi
	yreal=7.6122 
		write(*,*)"T_sat= ",xi,"  yreal= ",yreal
	errop=abs(yi-yreal)/yreal
		write(*,*)"O erro percentual a Tsat = ",xi," eh errop = ",errop

!------------------------------------------------------------------------------

	xi=300.
	call splint(x,y,y2,n2,xi,yi)
		write(*,*)xi,yi
	yreal=5.7045  
		write(*,*)"T_sat= ",xi,"  yreal= ",yreal
	errop=abs(yi-yreal)/yreal
		write(*,*)"O erro percentual a Tsat = ",xi," eh errop = ",errop

!--------------------------------------------------------------------------------

close(3)

chamada = systemqq('notepad outcarro.dat')       ! listagem dos dados

 chamada = systemqq('wgnuplot dados.gnu')  ! gráfico
      stop
      end



