c c $Id: llst.f,v 1.2 1999/08/03 21:21:32 aai Exp $. c c{ program llst c c Llst - Test lls() et. al. c c To use this program, compile and link with libfortex77.a then c execute and either type in (X,Y) pairs directly or redirect them c as standard input, one (X,Y) pair per line. c c Phillip A. Cheeseman, Purdue University Computing Center. c c MAXCAP is the maximum number of points we can keep in the data arrays. c integer MAXCAP parameter (MAXCAP=1000) c c Data arrays for (X,Y) pairs. c real x(MAXCAP) real y(MAXCAP) c c Least square line parameters. c real a real b real sigma c c Response code returned by lls() and counter for data points. c integer iresp integer n c c Messages we'll return if we get a negative response from lls(). c Data statements could be done several different ways. I've c chosen the one that'll work anywhere. c character*40 problems(3) c data problems(1) / 'No data points.' / data problems(2) / 'Calculation of std. dev. not possible.' / data problems(3) / 'Least squares line is vertical.' / c c Preset count of data points then read (X,Y) pairs until end of file c or limit of arrays. c n = 0 00011 read(*,*,end=21) x(n+1),y(n+1) n = n+1 if(n.lt.MAXCAP) go to 11 write(*,'(a,i5)') ' Llst: exceeded array capacity of ',MAXCAP,'.' c 00021 call lls(n, x, y, iresp, sigma, a, b) c c Here, we issue an error message if iresp is negative. c This could be more elegantly done by dropping the trailing blanks c but that's more code for messages we shouldn't see too often. c if(iresp.lt.0) then write(*,'(a,i2,a)') ' Llst: problem code is (',iresp,').' if((iresp.le.-1).and.(iresp.ge.-3)) then write(*,'(8x,a)') problems(-iresp) endif endif c c Write the results. c if((iresp.ge.0).or.(iresp.eq.-2)) then write(*,*) ' Llst: A=',a write(*,*) ' B=',b if(iresp.ne.-2) then write(*,*) ' S=',sigma endif endif c stop c end c}