#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "s.h"
main (argc, argv)
     int argc;
     char *argv[];
{
  int i, n;
  double rx, ry;
  double rc, rconv, farg;
  char readres;
  char tempstring[stringl];
  double xspline[nspline], yspline[nspline], y2spline[nspline];
  FILE *channelsetupdata = NULL;
  channelsetupdata = fopen (argv[1], "r");

  if (channelsetupdata == NULL)
    {
      printf (" file \042%s\042 not found \n", argv[1]);
      exit (1);
    };
  n = 0;
  do
    {
      fscanf (channelsetupdata, "%lg%lg%*[^\n]", &rx, &ry);
      readres = getc (channelsetupdata);
      if (!(readres == EOF))
	{
	  n++;
	  xspline[n] = rx;
	  yspline[n] = ry;
	}
    }
  while (!(readres == EOF));
  spline (xspline, yspline, n, 1e30, 1e30, y2spline);

  if (argc == 3)
    {
      rc = atof (argv[argc - 1]);
      splint (xspline, yspline, y2spline, n, rc, &rconv);
      printf (" %12.3f \n", rconv);
    }
  else
    do
      {
	scanf ("%lg%*[^\n]", &rc);
	readres = getchar ();
	if (!(readres == EOF))
	  {
	    splint (xspline, yspline, y2spline, n, rc, &rconv);

	    printf (" %lg %12.3f \n", rc, rconv);
	  }
      }
    while (!(readres == EOF));

}
