C******************** START FILE UPPASG.FOR ; GROUP USPARM ******************
C
C-----------------------------------------------------------
C& UPPASG  ASSIGN INLINE PASSED VALUE TO UREAD PARAMETER NAME
C
C  THIS ROUTINE ALLOWS USER PROGRAMS TO ASSIGN VALUES TO
C  STRING PARAMETERS WHICH MAY THEN BE REFERENCED BY THE
C  INTERACTIVE USER OR INDIRECT FILE AS IF THE PARAMETER HAD
C  BEEN DEFINED INTERACTIVELY BY THE USER OR IN HIS INDIRECT
C  INPUT FILE.
C
      SUBROUTINE UPPASG(ZNAM,ZVAL,IGLOBL)
C
C  ZNAM-- UP TO 16 CHAR INPUT NAME, NO IMBEDDED BLANKS, ALPHANUMERIC
C  ZVAL-- UP TO 96 CHAR VALUE
C
C  IGLOBL=1 TO MAKE ASSIGNMENT TO GLOBAL PARAMETERS LIST; LOCAL
C   OTHERWISE
C
      USE USERIO
C
      CHARACTER*1 ZLOCL(96)
      CHARACTER*16 ZNAM
      CHARACTER*96 ZVAL
C  INITIALIZE USER I/O COMMON IF NECESSARY
      CALL USICHK
C  CHECK LEGALITY OF NAME AND VALUE
      READ(1001,ZNAM) (ZLOCL(I),I=1,LPNAM)
 1001 FORMAT(96A1)
      I1=1
      I2=LPNAM
      IL=LPNAM
      CALL USPLNM(ZLOCL,IL,I1,I2,ZNAM,IER)
      IF(IER.NE.0) GO TO 9001
C
      READ(ZVAL,1001) (ZLOCL(I),I=1,LPVAL)
      I1=1
      I2=LPVAL
      IL=LPVAL
      CALL USPLVL(ZLOCL,IL,I1,I2,ZVAL,IER)
      IF(IER.NE.0) GO TO 9002
C  CHECK FOR REPLACEMENT OF ALREADY DEFINED PARAMETER
      CALL USPLOC(ZNAM,ITYPE,INUM)
      IF(ITYPE.EQ.0) GO TO 100
C  WARNING ON FIRST FEW OCCURANCES
      DATA IWARN/5/
      IWARN=IWARN-1
      IF(NLECHO) WRITE(LUNTRM,2001) ZNAM
 2001 FORMAT(' % UPPASG USER PROGRAM ASSIGNMENT REPLACES'/
     >  '   PRIOR DEFINITION OF PARAMETER  "',A16,'"')
      IF(ITYPE.EQ.1) CALL USPDLO(INUM)
      IF(ITYPE.EQ.2) CALL USPDGL(INUM)
C  STORE NEW PARAMETER DEFINITION
 100  CONTINUE
      IF(IGLOBL.EQ.1) CALL UPSADG(ZNAM,ZVAL)
      IF(IGLOBL.NE.1) CALL UPSADL(ZNAM,ZVAL)
      RETURN
C--------
C  ERRORS-- ALL FATAL
C
 9001 CONTINUE
      WRITE(LUNTRM,9901)
 9901 FORMAT(' ? UPPASG:  ILLEGAL NAME, USER PROGRAM ASSIGNMENT')
      GO TO 9005
 9002 CONTINUE
      WRITE(LUNTRM,9902)
 9902 FORMAT(' ? UPPASG:  ILLEGAL VALUE, USER PROGRAM ASSIGNMENT')
      GO TO 9005
 9005 CONTINUE
      WRITE(LUNTRM,9905) trim(ZNAM),trim(ZVAL),IGLOBL
 9905 FORMAT(/' ? ATTEMPT TO ASSIGN VALUE TO STRING PARAMETER'/
     >  '   VIA CALL TO SUBROUTINE "UPPASG" FAILED.  ARGUMENTS:'/
     >  '   ZNAM:  "',A,'"'/
     >  '   ZVAL:  "',A,'"'/
     >  ' IGLOBL:  ',I5/)
      CALL URDABO
      	END
C******************** END FILE UPPASG.FOR ; GROUP USPARM ******************
