!      program blasius
use msflib !  systemqq

logical calling
	parameter (nelmax=100)
	dimension tp(nelmax)
	external fcn,rkqc
      common /const/ ht2 
      open(1,file='inpclass.txt')
	open(2,file='f1.txt')
	open(3,file='f2.txt')
	open(4,file='f3.txt')

!	Solution of a Boundary Value Problem - BVP
!
!	data input
!
	read(1,*)n
	write(*,*)'n=',n
	read(1,*)eta0
	write(*,*)'eta0=',eta0
	read(1,*)etaend
	write(*,*)'etaend=',etaend
	read(1,*)deta
	write(*,*)'deta=',deta
	read(1,*)f10
	write(*,*)'f10=',f10
	read(1,*)f20
	write(*,*)'f20=',f20
	read(1,*)f30
	write(*,*)'f30=',f30
!
!	initial values
!
	eta=eta0
	tp(1)=f10
	tp(2)=f20
	tp(3)=f30
!
	k=0 
	write(2,*)eta,tp(1)
	write(3,*)eta,tp(2)
	write(4,*)eta,tp(3)
!
	ht2=deta/10
	nd=nelmax
!
!	beginning of time loop
!
 50	k=k+1 
	tendi=eta+deta
      	write(*,*)'-------------eta=',tendi
!
!     call odeint(tp,n,time,tendi,1.e-6,ht2,1.e-20,id1,id2,nelmax,fcn,rkqc)
	call  rk4ord(tp,n,eta,deta,fcn,nd)
!    call fore(n,fcn,time,tp,tendi,nelmax)
	write(*,*)k,tendi,(tp(l),l=1,n)
	write(2,*)tendi,tp(1)
	write(3,*)tendi,tp(2)
	write(4,*)tendi,tp(3)
!
     	if (tendi.lt.etaend) then
			eta=tendi
			goto 50 
		endif
	close(2)
	close(3)
	close(4)

calling = systemqq('edit f1.txt')       ! list of data

calling = systemqq('edit f2.txt')       ! list of data
calling = systemqq('edit f3.txt')       ! list of data

chamada = systemqq('wgnuplot data.gnu')  ! gráfico
	stop
	end
!**************************************
	subroutine fcn(n,t,fi,f,nelmax)
	dimension fi(nelmax),f(nelmax)
!
	f(1)=fi(2)
	f(2)=fi(3)
	f(3)=-fi(1)*fi(3)
!
	return
	end
!***************************************
!234567890123456789012345678901234567890123456789012345678901234567890 
      subroutine fore(n,fcn,time,fi,tend,nelmax) 
! 
!      implicit real *8 (a-h,o-z)
      parameter (nd1=100) 
      dimension fi(nelmax),f(nd1)
      common /const/ ht2 
      external fcn 
      k=0 
 50   k=k+1 
      time=min(time+ht2,tend) 
      call fcn(n,time,fi,f,nelmax) 
      do 100 i=1,n 
         fi(i)=fi(i)+ht2*f(i) 
 100  continue 
      if (time.lt.tend) goto 50 
      return 
      end 
!------------------------------------------------------------------ 





