model_db_query (ul_model)

	status.i4.v = model_db_query(which_data.i4.v, filter.i4.v,
				     model_data.g.r, num_rows.i4.r,
				     error_message.i1p.r)

	This routine queries the model database for the desired data.
	The data is returned as a void pointer and should be cast to
	the appropriate struct. The user is also responsible for
	deallocating the returned data memory.  The memory was allocated
	using calloc.

	which_data	what data to get from the model server
			(MODEL_TWISS_DATA -> return Twiss parameters
					     (MODEL_TWISS_STRUCT structures),
			 MODEL_RING_DATA -> return overall ring parameters
					    (MODEL_RING_STRUCT structures)
					    (filter is ignored),
			 MODEL_ELEMENT_DATA -> return element data
					       (MODEL_EDIT_ELEMENT_STRUCT
						structures),
			 MODEL_TRANSFER_CONST -> return transfer constants
						 (MODEL_TRANSFER_CONST_STRUCT
						  structures)
						 (filter is ignored),
			 MODEL_TOTAL_PHASE_ADV -> return Twiss parameters at
						  the end of a beamline or ring
						  (MODEL_TWISS_STRUCT
						   structures)
						  (filter is ignored))
			(constants are in 'ul_model:model_config')
	filter		how the requested data should be filtered
			(MODEL_FILTER_ALL -> all elements,
			 MODEL_FILTER_DRIFT -> drift spaces,
			 MODEL_FILTER_QUAD -> quadrupoles,
			 MODEL_FILTER_SEXT -> sextupoles,
			 MODEL_FILTER_HCORR -> horizontal correctors,
			 MODEL_FILTER_VCORR -> vertical correctors,
			 MODEL_FILTER_HBPM -> horizontal BPMs,
			 MODEL_FILTER_VBPM -> vertical BPMs,
			 MODEL_FILTER_BEND -> horizontal bends,
			 MODEL_FILTER_MARKER -> markers,
			 MODEL_FILTER_OCTUPOLE -> octupoles,
			 MODEL_FILTER_COMBINED -> combined features,
			 MODEL_FILTER_RFCAVITY -> RF cavities,
			 MODEL_FILTER_FLYING_WIRE -> flying wires,
			 MODEL_FILTER_SYNC_LIGHT -> sync light monitors,
			 MODEL_FILTER_SEPTA -> septa,
			 MODEL_FILTER_LAMBERTSON -> lambertsons,
			 MODEL_FILTER_RASTER -> rasters,
			 MODEL_FILTER_TCL -> TCLs,
			 MODEL_FILTER_MWIRE -> multiwires,
			 MODEL_FILTER_MONITOR -> monitors,
			 MODEL_FILTER_SEPARATOR -> separators,
			 MODEL_FILTER_COLLIMATOR -> collimators)
			(constants are in 'ul_model:model_config')
	model_data	returned model data
			(structure of data depends on the "which_data" argument)
			(This memory should be freed by the caller.)
	num_rows	number of rows in the "returned_data" struct is
			stuffed into here
	error_message	returned error message string
			(THE CALLER SHOULD NOT FREE THIS MEMORY.)

	This function returns ACNET status values as follows:

	OK			success
	CBS_INVARG		invalid machine/lattice value
	otherwise		ACNET format error code

	This function requires the following include files:

	ul_model_h:model_config_h, acnet_errors_h

	Related functions:

	model_db_query_name, model_db_set_machine, model_db_set_machine_cpp

	C/C++ usage:

	char	*error_message;
	int	status;
	int	which_data = MODEL_TWISS_DATA;
	int	filter = MODEL_FILTER_HBPM;
	int	num_rows;
	MODEL_TWISS_STRUCT	*model_data;

	status = model_db_query(which_data,filter,&model_data,&num_rows,
				&error_message);
		.
		.
		.
	free(model_data);