* XCONTEXT.CMN
* space/time/data_set/variable expression context information

* 1/3/89 - added regridding transformations
* V200:  5/17/89 - changed to 4D symmetry
*	12/18/89 - added cx_plot
* Unix/RISC port 1/91 - variables reordered to accomodate REAL*8 boundaries
* V420: added cx_impl_grid for implicit grid creation
* V450: added cx_calendar to enable time < 0
* V510: *sh* added cx_formatted to record user inputs like X=130E:80W
*	also moved cx_xtra_doc inside COMMON to Solaris avoid compiler ragging
* V530:  8/00 *sh* - added cx_type for better string support (and future ...)
* V550: *acm*10/02- Change cx_name to char*24
*        2/12 *kms* Add E and F dimensions (set to nferdims),
*                   added cx_lo_s5 & 6, cx_hi_s5 & 6
* V685+ 3/13 *sh* added auxiliary regridding variables
* V685+ 12/13 *acm* For 6D Ferret, cx_xtra_doc should have 2 more elements
* V690 12/13 *sh* added cx_implicit_aux, cx_aux_given, cx_g_eq_regrid,
*		 cx_aux_stat for automated curvilinear regridding
*	         max_context made a variable to allow frames above it
* V693+ added cx_vtree* vars for ticket #2195 - reporting regridding dependency
* V694 cx_calendar needs to be 6-D to handle F and T calendar time
* V73+  12/13 *acm* add cx_feature to store the feature mask
* V745  3/19 *acm* ticket 1916, special handling getting context for RETURN= outputs

* the declarations below represent a stack of depth max_context for saving
* the nested contexts.  The bottom few entries in the stack have special uses:
*	_last	- context left from the last command
*	_cmnd	- context of command after interpreting command qualifiers
* the non-positive subscripts are used for storing pre-defined (user defined)
* contexts

* contexts are nested; the context of the current command is built from
*	  i)	the default context ( usually left from the last command )
*	 ii)	the qualifiers included in the current command line
*	iii)	the qualifiers included with the variable names in expressions

* note:	lists of modifiers to command contexts are also stored temporarily
*	in the context stack

*	cx_lo_ww	- lower bounds of space/time regions in world coords
*	cx_lo_ss	- lower bounds of space/time regions in grid subscripts
*	cx_hi_ww	- upper bounds of space/time regions in world coords
*	cx_hi_ss	- upper bounds of space/time regions in grid subscripts
*	cx_delta	- delta increment of space/time regions (in WORLD or
*		  	  SUBSC according to cx_by_ss )
*	cx_cal_id	- integer; which calendar used when computing cx_*ss 
*                         in world coords
*	cx_by_ss	- logical for how dimension was specified by user
*	cx_trans	- mathematical transform applied to dimension
*	cx_given	- logical for whether dimension was just changed
*	cx_dset_gvn	- logical for whether data set was just changed
*			( "is a context self-contained with respect to dset ? )
*
*	cx_unstand_grid	- (logical) - variable on its defining grid ?
*	cx_regrid_trans	- regridding transformation for each axis
*	cx_ovsiz	- flags whether data should be oversized
*	cx_xtra_doc	- documentation flags (as in XPLOT_SETUP)
*	cx_formatted	- flags if the latest input used formatted style
*
*       cx_naux         - number of auxiliary variables used in regridding
*       cx_aux_var,cat  - var and cat of auxiliary vars (in parent dset)
*	cx_valid_aux	- Boolean telling if aux var name was found
*	cx_aux_arg_start,end - EQUIV. to cx_aux_var,cat. name string pointers
*	cx_aux_given	- flags whether an aux var was specified
*	cx_aux_stat	- flags if aux axis has been regridded or remains free 

* The following variables exist only for the most recent "mods_cx"
*	cx_g_eq_regrid  - flags whether g or gz or delta requested a new axis
*	cx_grid_needs_dset - flags whether the specified target grid makes
*		             sense only if the context dset is available
*	cx_feature	- for DSG datasets, when plotting, the list of feature
*                         numbers associated with the iline context to b plotted

* allocate some protected contexts at the top of the context stack
	INTEGER		max_cx
	PARAMETER     ( max_cx = max_noframe_context + 2 )

	REAL*8	cx_lo_ww	 ( nferdims, min_context:max_cx ),
     .		cx_hi_ww	 ( nferdims, min_context:max_cx ),
     .		cx_delta	 ( nferdims, max_cx )
	INTEGER	max_context
	INTEGER	cx_lo_ss	 ( min_context:max_cx, nferdims ),
     .		cx_hi_ss	 ( min_context:max_cx, nferdims ),
     .		cx_trans	 ( nferdims, min_context:max_cx ),
     .		cx_regrid_trans  ( nferdims, max_cx )
	INTEGER	cx_stack_ptr,
     .		cx_vtree_var_or_start( nferdims ),
     .		cx_vtree_cat_or_end  ( nferdims ),
     .		cx_vtree_regrid_dset ( nferdims ),
     .		cx_vtree_regrid_ntarget,
     .		cx_data_set ( max_cx ),
     .		cx_category ( max_cx ),
     .		cx_variable ( max_cx ),
     .		cx_grid     ( max_cx ),
     .		cx_type     ( max_cx ),
     .		cx_ovsiz    ( max_cx ),
     .		cx_impl_grid( max_cx ),
     .		cx_cal_id   ( min_context:max_cx ),
     .		cx_naux     ( max_cx ),
     .		cx_aux_var  (nferdims, max_cx),
     .		cx_aux_cat  (nferdims, max_cx),
     .		cx_aux_stat (nferdims, max_cx ),
     .		cx_feature  ( max_cx )

	LOGICAL	cx_vtree_unknown_grid( nferdims ),
     .     	cx_unstand_grid	( max_cx ),
     .		cx_by_ss	( nferdims, min_context:max_cx ),
     .		cx_given	( nferdims, min_context:max_cx ),
     .		cx_dset_gvn	( max_cx ),
     .		cx_calendar	( nferdims, min_context:max_cx ),
     .		cx_grid_needs_dset,
     .		cx_aux_given    ( nferdims, max_cx ),
     .		cx_g_eq_regrid  ( nferdims),
     .		cx_xtra_doc	( 0:12 ),
     .		cx_has_impl_grid( max_cx ),
     .		cx_formatted	( nferdims ),
     .		cx_valid_aux 	(nferdims, max_cx ),
     .		cx_implicit_aux ( max_cx ),
     .     	cx_only

	REAL	cx_bad_data	( max_cx ),
     .		cx_trans_arg	( nferdims, min_context:max_cx )

	CHARACTER
     .		cx_name		( min_context:0 )*24

	COMMON / XCONTEXT /
     .		cx_lo_ww,
     .		cx_hi_ww,
     .		cx_delta,
     .		cx_bad_data,
     .		cx_trans_arg,
     .		cx_xtra_doc,
     .		cx_lo_ss,
     .		cx_hi_ss,
     .		cx_trans,
     .		cx_regrid_trans,
     .		cx_stack_ptr,
     .		cx_data_set,
     .		cx_category,
     .		cx_variable,
     .		cx_vtree_var_or_start,
     .		cx_vtree_cat_or_end,
     .		cx_vtree_regrid_dset,
     .		cx_vtree_regrid_ntarget,
     .		cx_vtree_unknown_grid,
     .		cx_naux,
     .		cx_aux_var,
     .		cx_aux_cat,
     .		cx_aux_stat,
     .		cx_feature,
     .		max_context,
     .		cx_valid_aux,
     .		cx_implicit_aux,
     .		cx_only,
     .		cx_grid,
     .		cx_type,
     .		cx_ovsiz,
     .		cx_impl_grid,
     .          cx_cal_id,
     .		cx_unstand_grid,
     .		cx_by_ss,
     .		cx_given,
     .		cx_dset_gvn,
     .		cx_calendar,
     .		cx_grid_needs_dset,
     .		cx_aux_given,
     .		cx_g_eq_regrid,
     .		cx_has_impl_grid,
     .		cx_formatted,
     .		cx_name

* equivalences to assist with declaration statements
	INTEGER cx_lo_s1( max_cx ),
     .		cx_lo_s2( max_cx ),
     .		cx_lo_s3( max_cx ),
     .		cx_lo_s4( max_cx ),
     .		cx_lo_s5( max_cx ),
     .		cx_lo_s6( max_cx ),
     .		cx_hi_s1( max_cx ),
     .		cx_hi_s2( max_cx ),
     .		cx_hi_s3( max_cx ),
     .		cx_hi_s4( max_cx ),
     .		cx_hi_s5( max_cx ),
     .		cx_hi_s6( max_cx )
	EQUIVALENCE
     .		( cx_lo_s1, cx_lo_ss(1,1) ),
     .		( cx_lo_s2, cx_lo_ss(1,2) ),
     .		( cx_lo_s3, cx_lo_ss(1,3) ),
     .		( cx_lo_s4, cx_lo_ss(1,4) ),
     .		( cx_lo_s5, cx_lo_ss(1,5) ),
     .		( cx_lo_s6, cx_lo_ss(1,6) ),
     .		( cx_hi_s1, cx_hi_ss(1,1) ),
     .		( cx_hi_s2, cx_hi_ss(1,2) ),
     .		( cx_hi_s3, cx_hi_ss(1,3) ),
     .		( cx_hi_s4, cx_hi_ss(1,4) ),
     .		( cx_hi_s5, cx_hi_ss(1,5) ),
     .		( cx_hi_s6, cx_hi_ss(1,6) )

* equivalences to assist with parsiong auxiliary variable names
	INTEGER cx_aux_arg_start (nferdims, max_cx),
     .		cx_aux_arg_end   (nferdims, max_cx)
	EQUIVALENCE
     .		( cx_aux_arg_start, cx_aux_var  ),
     .		( cx_aux_arg_end,   cx_aux_cat )
