    !  Lear.f90
    !
    !  FUNCTIONS:
    !  Lear - Entry point of console application.
    !

    !****************************************************************************
    !
    !  PROGRAM: Lear
    !
    !  PURPOSE:  Entry point for the console application.
    !
    !****************************************************************************

    program Lear
    use Base
    use nystrom

    implicit none
    CHARACTER ZFILE1*60
    integer N, num,MType, NL, i
    character*60 title
    REAL (KIND=dp) h,XStart,t0,dt

    REAL(KIND=DP), allocatable :: XAlloc(:)
    REAL(KIND=DP), allocatable :: DXAlloc(:)


    

    ! Variables

    ! Body of Lear
    call  Menu(zfile1, num, MType, NL)

    read(si,100, err = 1200, end = 1010)title
100 Format((A))
    write(*,400)Title
400 Format('  Title for job :: ',(A))
    write(srB,400)Title
    read(si,*)N
    write(*,200)N
200 Format('  Number of equations :: ',I4)


    ALLOCATE (XAlloc(N), DXAlloc(N))

    read(si,*)h
    write(*,300)h
    write(srB,300)h
300 Format('  Tolerance on the analysis :: ',f10.6)
    
    read(si,*)XStart
    write(*,500)XStart
    write(srB,500)XStart
500 Format('  Starting X    :: ',f10.3)

    do 1300 i = 1,N
        read(si,*)XAlloc(i)
        write(*,600)i,XAlloc(i)
        write(srB,600)i,XAlloc(i)
600     Format('  Starting X(',i1,') :: ',f10.3)
1300 end do

     do 1400 i = 1,N
    read(si,*)DXAlloc(i)
    write(*,610)i,DXAlloc(i)
    write(srB,610)i, DXAlloc(i)
610 Format('  Starting DX(',i1,') :: ',f10.3)
1400 end do    
    
    read(si,*)num
    write(*,800)num
    write(srB,800)num
800 Format('  Number of loops :: ',I4)
    
    read(si,*)t0
    write(*,900)t0
    write(srB,900)t0
900 Format('  Start time in Seconds :: ',F10.3)
    
    read(si,*)dt
    write(*,1000)dt
    write(srB,1000)dt
1000 Format('  Time Step            :: ',F10.3)


    call RKN(N,h,XStart,XAlloc,num,t0,dt,DXAlloc)

    stop

1200 write(*,1100)
1100 Format('Error in reading title line in the data file!')
1010 write(*,1110)
1110 Format('Error in reading title line in the data file reached file end!')


    end program Lear



