
/*
 * Copyright (1987) Jeff Elman.  University of California, San Diego
 * This software may be redistributed without charge; this notice
 * should be preserved.
 */

#include <stdio.h>
#include <math.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/types.h>
#ifdef X
#include "X/box.h"
#endif
#include "defs.h"

main(argc, argv)
	int     argc;
	char  **argv;
{
	extern	char fileroot[];
	extern	int interactive;
	extern	int box;
	extern	int dispout;
	extern	int disphid;
	extern	int array;
	extern	int printhid;
	extern	int printout;
	extern	int errsig;
	extern	int nolearn;

	machdep_init(argc, argv);
	/*
	 * Major choice point.  Certain conditions allow us to run
	 * with minimal checking for special conditions (e.g., if we
	 * are non-interactive, doing no displaying, not saving
	 * error, etc.).  If this is the case we will execute run_fast.
	 * interactive mode implies run_cmd, and anything else is
	 * run_slow.
	 */
	if (interactive) {
		run_cmd();
		fflush(stdout);
	} else if (box || printhid || printout || errsig 
	    || dispout || disphid) {
		run_slow();
		fflush(stdout);
	} else {
		run_fast();
	}
	/*
	 * save weights in file with same name as datafile,
	 * plus .wts extension
	 */
	if ((array == 0) && (nolearn == 0))
		saveweights1(fileroot);
	else if ((array == 1) && (nolearn == 0))
		saveweights2(fileroot);
	exit(0);
}
