!=====================================================================
! NGGA: Gridal, A Package to Draw Backgrounds for X/Y Plots
!=====================================================================
!
! The package named GRIDAL allows one to draw backgrounds for X/Y
! plots. Included are routines for drawing grids, perimeters, and
! pairs of axes. Internal parameters of GRIDAL control such things
! as the color indices used to draw various parts of the background,
! the formats to be used for labels, the sizes of the characters to
! be used for labels, the amount by which labels are to be offset
! from the axes, and the routine to be called to draw the labels.
!
! ~~~~~~~~~~~~~~~~~~~~~~~~~~
! Parameter-Setting Routines
! ~~~~~~~~~~~~~~~~~~~~~~~~~~
!
! NG_GASETC set the value of a CHARACTER internal parameter
! NG_GASETI set the value of an INTEGER internal parameter
! NG_GASETR set the value of a REAL internal parameter
!
! NG_GAGETC get the value of a CHARACTER internal parameter
! NG_GAGETI get the value of an INTEGER internal parameter
! NG_GAGETR get the value of a REAL internal parameter
!
! NG_GARSET reset internal parameters to its default (added by CNCARG)
! NG_GASET1 set internal parameters (added by CNCARG)
! NG_GAGET1 get internal parameters (added by CNCARG)
!
! ~~~~~~~~~~~~~~~~~~~~
! Grid-Drawing Routine
! ~~~~~~~~~~~~~~~~~~~~
!
! NG_GRIDAL is called to draw any of the supported types of
!           backgrounds:unlabelled/labelled grid, perimeter,
!           and intersecting axes.
!
!---------------------------------------------------------------------
! Internal Parameters
!---------------------------------------------------------------------
!
! 'CAX' INTEGER
!       The polyline color index to be used for drawing the axes.
!
!       A negative value implies that no change is to be made in the
!       polyline color index before drawing the axes.
!
!       The default value  of 'CAX' is -1; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument ICAX).
!
! 'CLB' INTEGER
!       The polyline/text color indices to be used for drawing labels.
!
!       A negative value implies that no change is to be made in the
!       polyline and text color indices before drawing the labels.
!
!       The default value of 'CLB' is -1; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument ICLB).
!
! 'CMJ' INTEGER
!       The polyline color index to be used for major ticks and/or grid
!       lines.
!
!       A negative value implies that no change is to be made in the
!       polyline color index before drawing major ticks/grid lines.
!
!       The default value of 'CMJ' is -1; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument ICMJ).
!
! 'CMN' INTEGER,
!       The polyline color index to be used for minor ticks and/or grid
!       lines.
!
!       A negative value implies that no change is to be made in the
!       polyline color index before drawing minor ticks/grid lines.
!
!       The default value of 'CMN' is -1; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument ICMN).
!
!---------------------
!
! 'WAX' REAL
!       The line width to be used for drawing the axes.
!
!       A value less than or equal to zero implies that no change is to
!       be made in the line width scale factor before drawing the axes.
!
!       The default value of 'WAX' is 0; its value may be changed by
!       calling GASETI or GASETR, or GASET1 (argument RWAX).
!
! 'WLB' REAL
!
!       The line width to be used for drawing labels. (Labels drawn
!       using calls to the PLOTCHAR routine PLCHHQ are affected by this;
!       those drawn using calls to the SPPS routine WTSTR are not.)
!
!       A value less than or equal to zero implies that no change is to
!       be made in the line width scale factor before drawing the labels.
!
!       The default value of 'WLB' is 0; its value may be changed by
!       calling GASETI or GASETR, or GASET1 (argument RWLB).
!
! 'WMJ' REAL
!
!       The line width to be used for major ticks and/or grid lines.
!
!       A value less than or equal to zero implies that no change is to
!       be made in the line width scale factor before drawing.
!
!       The default value of 'WMJ' is 0; its value may be changed by
!       calling GASETI or GASETR, or GASET1 (argument RWMJ).
!
! 'WMN' REAL
!
!       The line width to be used for minor ticks and/or grid lines.
!
!       A value less than or equal to zero implies that no change is
!       to be made in the line width scale factor before drawing.
!
!       The default value of 'WMN' is 0; its value may be changed by
!       calling GASETI or GASETR, or GASET1 (argument RWMN).
!
!---------------------
!
! 'XMJ' REAL
!       The length of major ticks on the X axis.
!
!       ABS('XMJ') specifies the length of major ticks on the X axis;
!       values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. If 'XMJ' is positive, the ticks
!       point inward; if 'XMJ' is negative, the ticks point outward.
!
!       The default value of 'XMJ' is 0.012; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RXMJ).
!
! 'YMJ' REAL
!       The length of major ticks on theY axis.
!
!       ABS('YMJ') specifies the length of major ticks on theY axis;
!       values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. If 'YMJ' is positive, the ticks
!       point inward; if 'YMJ' is negative, the ticks point outward.
!
!       The default value of 'YMJ' is 0.012; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RYMJ).
!
! 'XMN' REAL
!       The length of minor ticks on the X axis.
!
!       ABS('XMN') specifies the length of minor ticks on the X axis;
!       values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. If 'XMN' is positive, the ticks
!       point inward; if 'XMN' is negative, the ticks point outward.
!
!       The default value of 'XMN' is 0.008; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RXMN).
!
! 'YMN' REAL
!       The length of minor ticks on the Y axis.
!
!       ABS('YMN') specifies the length of minor ticks on theY axis;
!       values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. If 'YMN' is positive, the ticks
!       point inward; if 'YMN' is negative, the ticks point outward.
!
!       The default value of 'YMN' is 0.008; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RYMN).
!
!---------------------
!
! 'XLF' CHARACTER
!       The format to be used for labels on the X axis.
!
!       The character string must begin with a left parenthesis and end
!       with a right parenthesis and it must not exceed ten characters
!       in length. Conversions of types E, F, G, and I are allowed.
!
!       The default value of 'XLF' is '(E10.3)'; its value may be
!       changed by calling GASETC or GASET1 (argument CXLF).
!
! 'YLF' CHARACTER
!       The format to be used for labels on the Y axis.
!
!       The character string must begin with a left parenthesis and end
!       with a right parenthesis and it must not exceed ten characters
!       in length. Conversions of types E, F, G, and I are allowed.
!
!       The default value of 'YLF' is '(E10.3)'; its value may be
!       changed by calling GASETC or GASET1 (argument CYLF).
!
! 'XLL' INTEGER
!       The length of each X-axis label.
!
!       If 'XLL' is given a non-zero value "n" and LBLX is a string
!       produced by the format 'XLF', then the label will be the
!       substring LBLX(1:n). If, on the other hand, 'XLL' = 0, then
!       the label will be the substring LBLX(m:n), where LBLX(m:m) is
!       the first non-blank character in LBLX and LBLX(n:n) is the
!       last non-blank character following LBLX(m:m). Using a non-zero
!       value for 'XLL' causes labels to be centered differently than
!       if a zero value is used.
!
!       The default value of 'XLL' is 0; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument IXLL).
!
! 'YLL' INTEGER
!       The length of each Y-axis label.
!
!       If 'YLL' is given a non-zero value "n" and LBLY is a string
!       produced by the format 'YLF', then the label will be the
!       substring LBLY(1:n). If, on the other hand, 'YLL' = 0, then
!       the label will be the substring LBLY(m:n), where LBLY(m:m) is
!       the first non-blank character in LBLY and LBLY(n:n) is the
!       last non-blank character following LBLY(m:m). Using a non-zero
!       value for 'YLL' causes labels to be centered differently than
!       if a zero value is used.
!
!       The default value of 'YLL'is 0; its value may be changed by
!       calling GASETI, GASETR, or GASET1 (argument IYLL).
!
!---------------------
!
! 'XLS' REAL
!       The size (width) of characters in X-axis labels.
!
!       Values between 0 and 1 are interpreted as fractions of the
!       width
!       of the grid window.
!
!       The default value of 'XLS' is 0.010; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RXLS).
!
! 'YLS' REAL
!       The size (width) of characters in Y-axis labels.
!
!       Values between 0 and 1 are interpreted as fractions of the
!       width of the grid window.
!
!       The default value of 'YLS' is 0.010; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RYLS).
!
! 'XLO' REAL
!       The (vertical) distance of an X-axis label from the X axis.
!
!       Values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. The value is interpreted as the
!       distance from the bottom edge of the viewport to the nearest
!       Y address of an X-axis label; negative values may be used to
!       put labels above the viewport.
!
!       The default value of 'XLO' is 0.020; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RXLO).
!
! 'YLO' REAL
!       The (horizontal) offset of a Y-axis label from the Y axis.
!
!       Values between 0 and 1 are interpreted as fractions of the
!       width of the grid window. The value is interpreted as the
!       distance from the left edge of the viewport to the nearest
!       X address of a Y-axis label; negative values may be used to
!       put labels to the right of the viewport.
!
!       The default value of 'YLO' is 0.020; its value may be changed
!       by calling GASETI, GASETR, or GASET1 (argument RYLO).
!
!---------------------
!
! 'XOR' INTEGER
!       The orientation of X-axis labels.
!
!       The value 0 implies the use of horizontal labels, while the
!       value 1 implies the use of vertical labels.
!
!       The default value is 0; its value may be changed by calling
!       GASETI, GASETR, or GASET1 (argument IXOR).
!
! 'LTY' INTEGER
!       The labelling type for numeric in scientific notation.
!
!       The value 0 implies that the PLCHMQ is to be called to draw
!       labels, the value 1 that the PLCHHQ is to be called, and the
!       value 2 that the PLCHHQ is to be called and, in addition, the
!       numeric-label strings are to be preprocessed to force the use
!       of superscript scientific notation in place of the FORTRAN
!       convention using "E".
!
!       The default value of 'LTY' is 0; its value may be changed by
!       calling GASETI or GASET1 (argument ILTY).
!
!---------------------------------------------------------------------
!
! SUBROUTINE NG_GARSET()
!
! Routine to reset all internal parameters to its default values.
!
!---------------------------------------------------------------------
!
! SUBROUTINE NG_GASET1( ICAX, ICLB, ICMJ, ICMN, &
!                       RWAX, RWLB, RWMJ, RWMN, &
!                       RXMJ, RYMJ, RXMN, RYMN, &
!                       CXLF, CYLF, IXLL, IYLL, &
!                       RXLS, RYLS, RXLO, RYLO, &
!                       IXOR, ILTY )
!
! Routine to set internal parameters.
!
! Variables:
!
! INTEGER,      INTENT(IN), OPTIONAL :: ICAX, ICLB, ICMJ, ICMN
! REAL,         INTENT(IN), OPTIONAL :: RWAX, RWLB, RWMJ, RWMN
! REAL,         INTENT(IN), OPTIONAL :: RXMJ, RYMJ, RXMN, RYMN
! CHARACTER(*), INTENT(IN), OPTIONAL :: CXLF, CYLF
! INTEGER,      INTENT(IN), OPTIONAL :: IXLL, IYLL
! REAL,         INTENT(IN), OPTIONAL :: RXLS, RYLS, RXLO, RYLO
! INTEGER,      INTENT(IN), OPTIONAL :: IXOR, ILTY
!
! ICAX - 'CAX' color index to be used for drawing the axes.
! ICLB - 'CLB' color index to be used for drawing labels.
! ICMJ - 'CMJ' color index to be used for major ticks and/or grid lines.
! ICMN - 'CMN' color index to be used for minor ticks and/or grid lines.
!
! RWAX - 'WAX' line widths for axes
! RWLB - 'WLB' line widths for labels
! RWMJ - 'WMJ' line widths for major grid lines/ticks
! RWMN - 'WMN' line widths for minor grid lines/ticks
!
! RXMJ - 'XMJ' Length of major ticks on the X axis.
! RYMJ - 'YMJ' Length of major ticks on theY axis.
! RXMN - 'XMN' Length of minor ticks on the X axis.
! RYMN - 'YMN' Length of minor ticks on the Y axis.
!
! CXLF - 'XLF' Format to be used for labels on the X axis.
! CYLF - 'YLF' Format to be used for labels on the Y axis.
! IXLL - 'XLL' Length of each X-axis label.
! IYLL - 'YLL' Length of each Y-axis label.
!
! RXLS - 'XLS' Size (width) of characters in X-axis labels.
! RYLS - 'YLS' Size (width) of characters in Y-axis labels.
! RXLO - 'XLO' Vertical distance of an X-axis label from the X axis.
! RYLO - 'YLO' Horizontal offset of a Y-axis label from the Y axis.
!
! IXOR - 'XOR' Orientation of X-axis labels.
! ILTY - 'LTY' Labelling type for numeric in scientific notation.
!
!---------------------------------------------------------------------
!
! SUBROUTINE NG_GAGET1( ICAX, ICLB, ICMJ, ICMN, &
!                       RWAX, RWLB, RWMJ, RWMN, &
!                       RXMJ, RYMJ, RXMN, RYMN, &
!                       CXLF, CYLF, IXLL, IYLL, &
!                       RXLS, RYLS, RXLO, RYLO, &
!                       IXOR, ILTY )
!
! Routine to get internal parameters.
!
! Variables:
!
! INTEGER,      INTENT(OUT), OPTIONAL :: ICAX, ICLB, ICMJ, ICMN
! REAL,         INTENT(OUT), OPTIONAL :: RWAX, RWLB, RWMJ, RWMN
! REAL,         INTENT(OUT), OPTIONAL :: RXMJ, RYMJ, RXMN, RYMN
! CHARACTER(*), INTENT(OUT), OPTIONAL :: CXLF, CYLF
! INTEGER,      INTENT(OUT), OPTIONAL :: IXLL, IYLL
! REAL,         INTENT(OUT), OPTIONAL :: RXLS, RYLS, RXLO, RYLO
! INTEGER,      INTENT(OUT), OPTIONAL :: IXOR, ILTY
!
!---------------------------------------------------------------------
!
! SUBROUTINE NG_GRIDAL( MJRX, MNRX, MJRY, MNRY, IXLB, IYLB, IGPH, &
!                       XINT, YINT )
!
! Routine to draw any of the supported types of backgrounds:
! unlabelled/labelled grid, perimeter, and intersecting axes.
!
! Varibeles:
!
! INTEGER, INTENT(IN) :: MJRX, MNRX, MJRY, MNRY, IXLB, IYLB, IGPH
! REAL,    INTENT(IN) :: XINT, YINT
!
! MJRX, MNRX, MJRY, and MNRY specify the major and minor divisions of
! the two axes, as described in the introduction.
!
! IXLB is defined as follows:
!      = -1 implies that no X axis is to be drawn.
!      =  0 implies that the X axis is to be drawn unlabelled.
!      =  1 implies that the X axis is to be drawn and labelled.
!
! IYLB is defined as follows:
!      = -1 implies that no Y axis is to be drawn.
!      =  0 implies that the Y axis is to be drawn unlabelled.
!      =  1 implies that the Y axis is to be drawn and labelled.
!
! IGPH specifies the background type, as follows:
!      =  0 implies X-Grid,      Y-Grid
!      =  1 implies X-Grid,      Y-Perimeter
!      =  2 implies X-Grid,      Y-HalfAxis
!      =  4 implies X-Perimeter, Y-Grid
!      =  5 implies X-Perimeter, Y-Perimeter
!      =  6 implies X-Perimeter, Y-HalfAxis
!      =  8 implies X-HalfAxis,  Y-Grid
!      =  9 implies X-HalfAxis,  Y-Perimeter
!      = 10 implies X-HalfAxis,  Y-HalfAxis
!
! XINT and YINT: if IGPH has the value 10, are the user coordinates of
! the point of intersection of the two axes. For other values of IGPH
! for which one of the axes is of type HalfAxis, XINT and/or YINT
! specify the position of that axis.
!
!---------------------------------------------------------------------
! Following Older Routines have been nullified
!---------------------------------------------------------------------
!
! GACOLR( KAXS, KLBL, KMJT, KMNT )
! LABMOD( FMTX, FMTY, NUMX, NUMY, ISZX, ISZY, IXDC, IYDC, IXOR )
! TICKS ( LMJR, LMNR)
! TICK4 ( LMJX, LMNX, LMJY, LMNY )
!
! -> change to the following
!
! GASET1( ICAX=KAXS, ICLB=KLBL, ICMJ=KMJT, ICMN=KMNT )
! GASET1( CXLF=FMTX, CYLF=FMTY, IXLL=NUMX, IYLL=NUMY, RXLS=REAL(ISZX), &
          RYLS=REAL(ISZY), RYLO=REAL(IXDC), RXLO=REAL(IYDC), IXOR=IXOR )
! GASET1( RXMJ=REAL(LMJR), RXMN=REAL(LMNR), RYMJ=REAL(LMJR), RYMN=REAL(LMNR) )
! GASET1( RXMJ=REAL(LMJX), RXMN=REAL(LMNX), RYMJ=REAL(LMJY), RYMN=REAL(LMNY) )
!
!-----------------------------
!
! GRID  ( MJRX, MNRX, MJRY, MNRY)
! GRIDL ( MJRX, MNRX, MJRY, MNRY)
! PERIM ( MJRX, MNRX, MJRY, MNRY)
! PERIML( MJRX, MNRX, MJRY, MNRY)
! HALFAX( MJRX, MNRX, MJRY, MNRY, XINT, YINT, IXLB, IYLB )
!
! -> change to the following
!
! GRIDAL( MJRX, MNRX, MJRY, MNRY,    0,    0,  0,  0.0,  0.0 )
! GRIDAL( MJRX, MNRX, MJRY, MNRY,    1,    1,  0,  0.0,  0.0 )
! GRIDAL( MJRX, MNRX, MJRY, MNRY,    0,    0,  5,  0.0,  0.0 )
! GRIDAL( MJRX, MNRX, MJRY, MNRY,    1,    1,  5,  0.0,  0.0 )
! GRIDAL( MJRX, MNRX, MJRY, MNRY, IXLB, IYLB, 10, XINT, YINT )
!
!=====================================================================
! Refer "NCAR menu" for interfacing GRIDAL in detail
!=====================================================================