C Copyright(c) 1997, Space Science and Engineering Center, UW-Madison
C Refer to "McIDAS Software Acquisition and Distribution Policies"
C in the file  mcidas/data/license.txt

C *** $Id: pltxtn.f,v 1.12 1997/10/10 20:18:38 dglo Exp $ ***

C $ CALL PLTXTN(LA, ME, LS, LN, NCH, LVL)  (JMB)
C $ PLOT ANY WEATHER SYMBOL OR CHARACTER STRING WITH THE FIRST SYMBOL OR
C $   CHARACTER CENTERED ABOUT THE INPUT LINE ('LA') AND ELEMENT ('ME').
C $ LAI = (I) INPUT  TV LINE COORD OF UPPER LEFT CORNER OF FIRST CHAR
C $ MEI = (I) INPUT  TV ELEMENT COORD
C $ LWI = (I) INPUT  HEIGHT OF CHARACTERS
C $ LN = (I) INPUT  ARRAY CONTAINING SYMBOL OR STRING TO PLOT
C $ NCH = (I) INPUT  NUMBER OF CHARACTERS IN STRING
C $ LVL = (I) INPUT  PEN VALUE (COLOR).
C $$ PLTXTN = GRAPHICS

*$ Name:
*$      pltxtn  - Plots weather symbol and character strings.
*$
*$ Interface:
*$      subroutine
*$      pltxtn(integer la, integer me, integer lwi, integer ln,
*$            integer nch, integer lvl)
*$
*$ Input:
*$      la      - Starting line of first symbol in the string.
*$      me      - Starting element of first symbol in the string.
*$      lwi     - Height of the characters, in TV lines.
*$      ln      - Array containing text and symbols to plot.
*$      nch     - Number of symbols or characters to plot.
*$      lvl     - Color of the symbols or characters.
*$
*$ Input and Output:
*$      none
*$
*$ Output:
*$      none
*$
*$ Return values:
*$      none
*$
*$ Remarks:
*$      A dollar sign is used to designate that the next character in
*$      the string is a symbol.
*$
*$      No checking is done to see if nch is a reasonable number.
*$
*$      Weather symbol characters provided are:
*$        T,W,R,S,F,C,Q,B,O,D,H,Z
*$
*$ Categories:
*$      text
*$      display
*$      graphic

      SUBROUTINE PLTXTN(LAI,MEI,LSI,LN,NCH,LVL)
      DIMENSION NSYM(218),LSYM(21)
      INTEGER   LN(70),IDOLLA,IBLNK,LSYML(21)
      CHARACTER CSYM
      DATA LSYM/227001,230010,231024,217035,226045,198052,
     &195059,216089,194092,214097,196102,200114,233128,
     &240147,241156,242165,243174,244183,245192,246201,247210/
      DATA NSYM/8,2500,500,515,1505,2515,-2015,2515,2510,13,1000,3010,
     &1020,
     &1000,-209,211,413,613,811,809,607,407,209,10,1000,3010,1020,1000,
     &-507,513,-207,813,-213,807,9,513,517,820,1220,1517,1513,1210,810,
     &513,6,1505,1515,-1005,2015,-1015,2005,6,1000,1015,-1500,1515,
     &-2000,2015,29,508,512,716,918,1018,1119,1219,1320,1720,1819,1919,
     &2018,2217,2316,2512,2508,2304,2102,2002,1901,1801,1700,1300,1201,
     &1101,1002,902,704,508,2,510,2510,4,508,2508,-614,2512,4,510,2510,
     &-1500,1520,11,1008,1012,1315,2015,2510,2506,2011,2008,1705,1305,
     &1005,13,1305,1008,1010,2020,2022,1725,1325,1022,1020,2010,2008,
     &1705,1305,18,1705,1305,1008,1010,2020,2022,1725,1325,-1409,1508,
     &1609,1510,1409,-1421,1520,1621,1522,1421,
     & 8,515,1525,1520,2520,2510,1510,1505,515,
     & 8,822,2222,1818,2612,1804,1212,808,822,
     & 8,1525,2515,2015,2005,1005,1015,515,1525,
     & 8,2222,2208,1812,1204,0412,1218,822,2222,
     & 8,2515,1505,1510,510,520,1520,1525,2515,
     & 8,2208,808,1212,418,1226,1818,2222,2208,
     & 8,1505,515,1015,1025,2025,2015,2515,1505,
     & 8,808,822,1218,1826,2618,1812,2208,808/
C      DATA IDOLLA/ #24 /,IBLNK/ #20 /  #24=36 #20=32
      DATA IDOLLA/ 36/, IBLNK/ 32/
      DATA LSYML/84,87,88,82,83,70,67,81,66,79,68,
     &72,90,48,49,50,51,52,53,54,55/

      LA=LAI
      ME=MEI
      LS=LSI
      CALL QSCALE(ISCALE)
      IF (ISCALE.NE.0) THEN
         CALL SCLPNT(LA,ME,LA,ME)
         CALL SCLHGT(LS)
         CALL SCLOFF
      ENDIF
      LE=ME
      MS=30000/LS
      I=0
C *** IF LN(I) IS EQUAL TO A $ SIGN, PROGRAM CONTROL IS SWITCHED TO
C *** STATEMENT NUMBER 360 WHERE CODING ALLOWS FOR A PLOT OF A WEATHER
C *** SYMBOL OR ANY OF EIGHT DIRECTIONAL OPEN ARROWS.  IF LN(I) IS EQUAL
C *** ' ' (I.E. A SPACE) CONTROL IS SWITCHED TO STATEMENT 313 WHERE THE
C *** CURRENT ELEMENT LOCATION IS INCREMENTED BY AN AMOUNT BASED UPON
C *** THE CHARACTER HEIGHT.  FINALLY, IF LN(I) IS A CHARACTER, THEN
C *** THERE IS A CALL TO SUBROUTINE WRTEXT.
109   ICHAR=IC(LN,I)
      IF (ICHAR.EQ.IDOLLA) GO TO 360
      IF(ICHAR.EQ.IBLNK) GO TO 313
  110 CSYM=CHAR(ICHAR)
C      CALL DDEST( 'CHARACTER "'//CSYM//'" = ', ICHAR )
      CALL WRTEXT (LA,LE,LS,CSYM,1,LVL)
      GO TO 313
C *** BECAUSE ICHAR WAS A $, THE PROGRAM 'RECOGNIZES' THAT THE OPERA-
C *** TOR WOULD LIKE TO PLOT A WEATHER SYMBOL OR AN OPEN ARROW.
C *** THE INDEX IS INCREMENTED BY ONE AND THE PROGRAM WILL NOW BE
C *** 'LOOKING' AT THE NEXT CHARACTER.
 360  I=I+1
      ICHAR=IC(LN,I)
      IF (ICHAR.EQ.IDOLLA) GO TO 110
C *** THE NEXT TWO LINES OF CODE ARE THE CENTER LINE-ELEMENT OFFSETS.
C      NLA=LA-(1510/100)*1000/MS
C      MEL=LE-MOD(1510,100)*1000/MS
C *** WITHIN DO-LOOP 260 THE WEATHER SYMBOL CHARACTER OR ARROW CODE
C *** IS DETERMINED.
      DO 260 K = 1,21
      IF(ICHAR.NE.LSYML(K)) GO TO 260
      GO TO 361
  260 CONTINUE
      GO TO 313
C *** THE NEXT THREE LINES ARE NEEDED TO DETERMINE THE BEGINNING AND
C *** ENDING INDEX VALUES IN THE NSYM ARRAY WHERE THE CHAR COORDINATES
C *** ARE STORED.
 361  NNN=MOD(LSYM(K),1000)
      KL=NSYM(NNN)+NNN
      NNN=NNN+1
C *** THE LARGE PART OF THE REMAINING CODE DETERMINES THE LINE AND
C *** ELEMENT FOR SUBROUTINE PLOT BASED UPON THE COORDINATE VALUES
C *** FOUND IN NSYM.
      DO 261  N=NNN,KL
      MT=IABS(NSYM(N))
C      LIN=NLA+(MT/100)*1000/MS
C      NEL=MEL+(MOD(MT,100))*1000/MS
      LIN=LA+(MT/100)*1000/MS
      NEL=LE+(MOD(MT,100))*1000/MS
       IPN=LVL
      IF (N.EQ.NNN.OR.NSYM(N).LT.0) IPN=0
      CALL PLOT(LIN,NEL,IPN)
  261 CONTINUE
      IF (K.LT.8.OR.K.GT.10) GO TO 313
      K=7
      GO TO 361
 313  LE=LE+30000/MS
      I=I+1
      IF((I.LT.NCH)) GO TO 109
99    IF (ISCALE.NE.0) CALL SCLON
      RETURN
      END
