	/* some global variables */

#define PROGNAME         "listgen"

#define MAX_TARGETS      5000	/* max number of possible targets which can */
                   	      		/*   considered for a single night */
#define VERBOSE          1
#define TACITURN         0
#define NAMELEN          100	/* max length of character fields */
#define MAX_INIT_SHIFT   15.0	/* max number of degrees of LST a group */
                             	/*   may initially be shifted to accomodate */
                            	/*   expanding neighbors */
#define LOWEST_PRIORITY  10		/* indicates least important targets */
#define HIGHEST_PRIORITY -10	/* indicates most important targets */

	/* the following are hardware-dependent quantities */
#define MAX_HA_LIMIT    67.5	/* scope limit for HA (in decimal degrees) */
#define SETUP_TIME      30		/* for debugging; a constant amount for time */
                          		/*   needed between any two exposures, for */
                           		/*   readout, slewing, dome rotation, etc. */

	/* these are values for the "tonight_status" field */
#define INACTIVE         0		/* star should not be considered tonight */
#define ACTIVE           1		/* target should be considered for tonight */
#define DISCARDED        2		/* target has been considered, and rejected */
#define OBSERVED         4		/* target has already been observed tonight */

	/* various bits within the "exp_type" field have these meanings */
#define EXP_ZERO     1		/* this exposure is a "zero" - bias frame */
#define EXP_DARK     2		/* a dark-current frame */
#define EXP_FLAT     4		/* a flatfield frame */
#define EXP_STANDARD 8		/* a standard star or calibration source frame */
#define EXP_NOSHIFT  16		/* the UT time cannot be changed */

	/* the target structure */

struct target {
	int target_id;			/* unique target number, based on initial RA sort */
	char req_id[NAMELEN];	/* name of the request file for this target */

		/* target identification fields */
	double ra;					/* object RA */
	double dec;					/* object Dec */
	double epoch;				/* object epoch */
	char obj_name[NAMELEN];		/* object name */

		/* observation details */
	long exp_type;		/* each bit stands for ZERO, FLAT, OBJECT, and other */
	              		/*   things, like "can start UT be shifted?" */
	long filters;		/* each bit stands for a filter */
	long guide_star;	/* GSC ID number of star used for guiding - or */
	                	/*   perhaps some code for anonymous stars */

		/* fields from which the exposure length can be calculated */ 
	double exp_time;	/* desired length of exposure */
	double tot_time;	/* total length of all exposures in a set */
	double mag;			/* some indication of the target magnitude, or */
	           			/*   perhaps of how faint the exposure ought to go */

		/* used only to optimize the order and timing of observations */
	double delay_time;	/* time, in seconds, to wait before starting exposure */
	double setup_time;	/* time it takes for dome to move, scope to slew, etc. */

		/* these fields determine whether or not the target should be
		   observed TONIGHT */
	int tonight_status;	/* bit flags indicating whether this object has */
	                  	/*    already been observed, or discarded, etc. */
	int priority;		/* priority of target: SMALL number -> HIGH priority */
	long start_jd;		/* Julian Day for start of observations */
	long end_jd;		/* Julian Day for end of observations */
	double start_ut;	/* if > 0, the UT the observation MUST take place */
	int interval;		/* interval, in days, between observations */
	double probability;	/* probability that observation, if scheduled, */
	                   	/*    should be made (0.0 never, 1.0 always) */
	long last_jd;		/* if > 0, Julian Day of last observation */
	double start_lst;	/* the LST of scheduled start of observation tonight */
	double end_lst;		/* the LST of scheduled end of observation */
	double lst_min;		/* minimum value of LST at which object can be obs. */
	double lst_max;		/* maximum ditto */
	
		/* these fields are set ONLY once an observation has been made */
	double obs_ut;			/* UT of actual start of observation */
	double obs_ha;			/* Hour Angle ditto */
	double obs_airmass;		/* average airmass of observation */
	double obs_exp_time;	/* actual exposure time */

		/* used for bookkeeping, and also for sending mail back when
		   observation is made, if desired */
	char pers_name[NAMELEN];	/* name of person requesting observations */
	char mail_address[NAMELEN];	/* E-mail address of person */
	int send_reply;				/* if > 0, send mail after an observation */
	               				/*   is made, if it is possible */
};

struct target list[MAX_TARGETS];	/* the list of targets that the program */
                                	/*   tries its best to optimize */

struct group {
	int group_id;		/* ID number for group */
	int start;			/* position of first object of group in "list[]" */
	int end;			/* ditto last object */
	double start_lst;	/* LST of start of exposure for first object in group */
	double mid_lst;		/* average of start_lst and end_lst */
	double end_lst;		/* LST of end of exposure for last object in group */
	double start_bound;	/* minimum LST this group allowed to start */
	double end_bound;	/* maximum LST this group allowed to end */
	int pop_flag;		/* tells whether group is SPARSE, OVERFULL, etc. */
};

struct group groups[MAX_TARGETS];	/* a list of groups - can't have more */
                                 	/*    groups than targets */


	/* various function types */
double largest_ha();
double ut_to_lst();		/* returns the LST of some JD, UT at BAIT longitude */
