)      SUBROUTINE MAGINI (X,TICLEN,PARMAP)3C_TITLE  MAGINI  Initiates the map grid parameters.C_ARGUMENTSC	REAL TICLEN 	  ![I] Tick length for mapgrid. (not yet implemented)2	REAL X(8)	  ![O] Parameter array for SET Routine.H	REAL PARMAP(8)    ![O] Parameter array containing arguments for MAPROJ.C_VARS'      INCLUDE 'RAD$INC:TAEBAS.INC/LIST'C					TAE linkage.%      INCLUDE 'RAD$INC:GRID.INC/LIST')C					Uses: RLON, LLON, YLATMIN, YLATMAX,C					DLON, DLAT, IOPT.-C					Modifies: RLON, LLON, YLATMIN, YLATMAX,C				        DLON, DLAT, IOPT.        $      INCLUDE 'RAD$INC:LAB.INC/LIST'C					Uses: none.(C					Modifies: LONSP, LATSP, IDX, IDY, C					CENT(1), CENT(2).CIC_DESCRIPTION  The subroutine MAGINI specifically initiates the map grid LC parameters using the TAE interface. In the process labeled common grid is GC initialized.  Parameters such as latitude and longitude limits, grid JC intervals for grid lines, the screen and world coordinates necesary for .C NCAR are calculated for later calls to NCAR.%C_CALLS  GETNR  MAPROJ  GETNI  COCOCM!C_BUGS  TICLEN not currently used'C_HISTORY  86Feb14  R.Gurule  FlagstaffC_ENDI!------MODGRID = LOGICAL FLAG TO DETERMINE WHETHER A MODULO GRID, THAT ISD!	         a grid whose ending and starting lats and longs end on an*!	         even multiple of dlon and dlat.,!	LATSP= THE SPACING OF THE LATITUDE LABELS.-!	LONSP= THE SPACING OF THE LONGITUDE LABELS.      LOGICAL PFLG      REAL*4 LEFT      INTEGER*4 ITEMP(2)      CHARACTER*1 ANS      DIMENSION TEMP(5)      DATA NDEC /0/,ERR/1.E9/      BORDER=.FALSE.      CENT(1) = PARMAP(6)      CLON = CENT(1)       B!-----Prompt for the limits for latitude and longitude in degrees.;!     Latitude and longitude need to be in the West system.      1      CALL XRREAL(BLOCK,'LONR',2,TEMP,ICNT,ISTAT)      LLON = TEMP(1)      RLON = TEMP(2)	!--Force into west longitude.      IF(LLON.LT.RLON)THEN
	TEMPR = RLON	RLON = LLON
	LLON = TEMPR      ENDIF1      CALL XRREAL(BLOCK,'LATR',2,TEMP,ICNT,ISTAT)      YLATMIN = TEMP(1)      YLATMAX = TEMP(2)G      IF(YLATMAX.LT.YLATMIN)TYPE*,'ERROR IN LATITUDE RANGE YMIN > YMAX'  !--Prompt for grid line spacing.3      CALL XRREAL(BLOCK,'DELTAL',2,TEMP,ICNT,ISTAT)      DLON =  TEMP(1)      DLAT =  TEMP(2)      IF( RLON.LT.LLON )THEN	DLON = - DLON
      ELSE	DLON = - DLON      ENDIF;!----Possible a special call to maproj for view projection.      /      CALL XRREAL(BLOCK,'SWIND',4,X,ICNT,ISTAT)@!-----Calculate the user plane coordinates.  (world coordinates)D!     take the largest dimension, and make that xmin,xmax,ymin,ymax.E!     See if llon < clon < rlon, Specific case when grid crosses 0.0.      LEFT = LLON5!  Determine where clon is relative to RLON and LLON.1      IF(CLON .LT. RLON .AND. CLON .LT. LLON)THEN       IRFLG = 0       RT = 0.0
      ELSE       RT = RLON       IRFLG= 1      ENDIF,!      Find the x and y extents of the plot.N!------Flags indicating when to start saving the xp, and yp value, especially L!      important for view projection when you don't know if the latitude or O!      longitude being calculated is behind the planet from your point of view.       IXSTRT = 0       IYSTRT = 05!-----Calculate the extents for the polar projection.L!     Swap ylatmin or ylatmax for the coordinate, this determines the extent!!     for the screen coordinates.       IF(KPROJ.EQ.3)THEN	 IF(YLATMIN.GT.0)THEN		   COORD=YLATMIN	 ELSE	   COORD=YLATMAX	 ENDIF!	 CALL MAPROJ(1,CLON,COORD,XP,YP)         COORD = ABS(YP)	 X(5)= - COORD  	 X(6)=   COORD         X(7)=  -COORD	 X(8)=   COORD	 TYPE*, (X(K),K=5,8)
       ELSE	   20   DO XL= LEFT, RT, DLON$       DO YL= YLATMIN, YLATMAX, DLAT'         CALL MAPROJ(1, XL, YL, XP, YP)#	 IF(IXSTRT.EQ.0.AND.YP.NE.ERR)THEN	   IXSTRT=1
	   X(5) = XP
	   X(6) = XP	 ENDIF#	 IF(IYSTRT.EQ.0.AND.YP.NE.ERR)THEN           IYSTRT=1	   X(7)  = YP           X(8)  = YP	 ENDIF !-- Find the limits of our grid.,	IF( XP .LT. X(5) .AND. YP.NE.ERR) X(5) = XP3        IF( XP .GT. X(6) .AND. YP.NE.ERR) X(6) = XP,	IF( YP .LT. X(7) .AND. YP.NE.ERR) X(7) = YP3        IF( YP .GT. X(8) .AND. YP.NE.ERR) X(8) = YP      END DO      END DO      ENDIF*       IF(IRFLG .EQ. 0.AND.KPROJ.NE.6)THEN        RT = RLON  	LEFT = 360.0        IRFLG = 1        GO TO 20       ENDIF      =!-----Determine which dimension is the largest, xmax or ymax.G!     Then, after we know which is the largest set the limit and add to*!     the other axis. Find the difference:      XDF= (X(6) - X(5))      YDF= (X(8) - X(7))L!     Determine offset and largest axis.  We add the difference to the small*!     axis so that the aspect ration = 1.0      SMAX = AMAX1(XDF,YDF)K      ASM = ABS(SMAX) * 0.025	     !Little bit on edges so room for labels.I      ADIF = ABS(XDF - YDF)/2.0      !DIFFERENCE BETWEEN X BOX AND Y BOX.      IF(XDF.GT.YDF)THEN	X(5) = X(5) - ASM        X(6) = X(6) + ASM"        X(7) = X(7) - (ADIF + ASM)"        X(8) = X(8) + (ADIF + ASM)
      ELSE"        X(5) = X(5) - (ADIF + ASM)"        X(6) = X(6) + (ADIF + ASM)	X(7) = X(7) - ASM        X(8) = X(8) + ASM      ENDIF(!-----prompt for label spacing, [0=none]2      CALL XRREAL(BLOCK,'DELAB',2,TEMP,ICNT,ISTAT)      LONSP = TEMP(1)       LATSP = TEMP(2)  4      CALL XRINTG(BLOCK,'LABSIZ',1,ISIZE,ICNT,ISTAT)3      CALL XRINTG(BLOCK,'XYOFF',2,ITEMP,ICNT,ISTAT)      IDX = -ITEMP(1)      IDY =  ITEMP(2)!-----Option for offset2      CALL XRINTG(BLOCK,'IOPT',1,IOPT,ICNT,ISTAT)       IF(KPROJ.EQ.6)THEN4        CALL COCOCM(PARMAP(6), DELAT, DELON, RADIUS)   	ALON = AMOD( DELON, DLON )"        ALAT = AMOD( DELAT, DLAT )        CENT(1) = DELON - ALON        CENT(2) = DELAT - ALAT5        IF(CENT(1) .LT. 0.0)CENT(1) = CENT(1) + 360.0      ENDIF      RETURN	      END