      SUBROUTINE PUTPARM(IU,ASTRNG,NCPS,APARM,IVAL) 
C
C     * NOV 28/91 - M.LAZARE. REDUCE MAXIMUM NUMBER OF DIGITS OF "IVAL" TO  
c     *                       9 DIGITS FOR 32-BIT MACHINES.
C     * DEC 03/90 - F.MAJAESS 
C 
C     * ACCUMULATES PARMSUB PARAMETER NAMES/VALUES IN "ASTRNG" STRING AND 
C     * POSSIBLY WRITES THEM OUT TO TAPE UNIT "IU". 
C 
C     * IU     - TAPE UNIT NUMBER WHERE "ASTRNG" IS TO BE WRITTEN.
C     * ASTRNG - A STRING HOLDING/TO HOLD THE PARMSUB PARAMETER NAMES/VALUES
C     *          (UP TO 80 CHARACTERS)
C     * NCPS   - INTEGER CONTAINING THE NUMBER OF CHARACTERS IN "ASTRNG", 
C     *          "ASTRNG" IS WRITTEN OUT IF NCPS.LT.0, OR IF THERE IS NOT 
C     *          ENOUGH SPACE IN IT TO STORE "APARM" AND "IVAL".
C     * APARM  - 8 CHARACTERS STRING OF THE PARMSUB PARAMETER NAME, 
C     *          ONLY THE FIRST NON-BLANK SUBSTRING IS STORED IN "ASTRNG".
C     *          (LEADING/TRAILING BLANKS IGNORED). 
C     * IVAL   - UP TO 9 DIGITS PARMSUB PARAMETER POSITIVE INTEGER VALUE 
C     *          IT IS CONVERTED TO A POSITIVE INTEGER IF ENTERED AS A
C     *          NEGATIVE INTEGER. THIS SIZE IS CONSTRAINED BY THE SIZE
C     *          OF A 32-BIT INTEGER MACHINE, I.E. 2**31 (ONE BIT FOR SIGN). 
C     *          ONLY THE LOWEST ORDER DIGITS OF THE NUMBER ARE STORED IN 
C     *          "ASTRNG".
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      INTEGER IU,NCPS,IVAL,NUMBER 
      CHARACTER APARM*8,ASTRNG*80 
      CHARACTER AVAL*9,APPND*32
C 
C     * IF "NCPS".LT.0.AND."ASTRNG" NOT EMPTY, THEN WRITE OUT "ASTRNG"
C     * TO UNIT "IU"
C 
      IF((NCPS.LT.0).AND.(ABS(NCPS).GT.1)) WRITE(IU,6000) ASTRNG 
C 
C     * IF "NCPS".LE.0 THEN RESET "ASTRNG" TO BLANKS AND "NCPS" TO 1. 
C 
      IF(NCPS.LE.0) THEN
        NCPS=1
        DO 10 L=1,80
          ASTRNG(L:L)=' ' 
  10    CONTINUE
        RETURN
      ENDIF 
C 
C     * CHECK IF PARAMETER NAME "APARM" IS BLANK... 
C 
      IF(APARM.EQ.'        ') THEN
        WRITE(6,6010) 
        CALL                                        XIT('PUTPARM',-1) 
        RETURN
      ENDIF 
C 
C     * CHECK IF PARAMETER VALUE "IVAL" IS LONGER THAN 9 DIGITS... 
C 
      NUMBER=ABS(IVAL) 
      IF(NUMBER.GT.999999999) THEN 
        WRITE(6,6020) NUMBER, APARM 
        CALL                                        XIT('PUTPARM',-2) 
        RETURN
      ENDIF 
C 
C     * SET THE VARIABLES HOLDING THE MAXIMUM NUMBER OF CHARACTERS ALLOWED
C     * FOR PARAMETER NAME "NCPAR" AND PARAMETER VALUE "NCVAL". 
C 
      NCPAR=8 
      NCVAL=9
C 
C     * CONVERT PARAMETER VALUE "IVAL" TO A CHARACTER STRING IN "AVAL". 
C 
      AVAL='                ' 
      WRITE(AVAL,'(I9)') NUMBER
C 
C     * PROCESS "NUMBER" IN "AVAL" WITH ZEROS ON THE LEFT OF THE NUMBER 
C     * ELIMINATED. 
C 
      JF=0
      DO 20 J=1,NCVAL 
        IF((AVAL(J:J).NE.' ').AND.(AVAL(J:J).NE.'0'))THEN 
          JF=J
          GO TO 30
        ENDIF 
        AVAL(J:J)=' ' 
  20  CONTINUE
  30  IF(JF.EQ.0) THEN
        AVAL(NCVAL:NCVAL)='0' 
        JF=NCVAL
      ENDIF 
C 
C     * PROCESS PARMSUB NAME IGNORING LEADING/TRAILING BLANK(S).
C 
      KF=0
      DO 40 K=1,NCPAR 
        IF(APARM(K:K).EQ.' ')THEN 
          IF(KF.GT.0) THEN
            GO TO 50
          ELSE
            GO TO 40
          ENDIF 
        ENDIF 
        KF=KF+1 
        APPND(KF:KF)=APARM(K:K) 
  40  CONTINUE
C 
C     * STORE PARMSUB PARAMETER NAME AND VALUE STRINGS IN "APPND".
C 
  50  KF1=KF+1
      KF2=KF+2
      LAVAL=NCVAL-JF+1
      LAPPND=KF1+LAVAL+1
      APPND(KF1:KF1)='='
      APPND(KF2:KF1+LAVAL)=AVAL(JF:NCVAL) 
      APPND(LAPPND:LAPPND+1)=', ' 
      LAPPND=LAPPND+1 
C 
C     * WRITE OUT "ASTRNG" IF THERE IS NOT ENOUGH SPACE TO HOLD "APPND" STRING. 
C 
      IF(NCPS+LAPPND.GT.80) THEN
        WRITE(IU,6000) ASTRNG 
        NCPS=1
        DO 60 L=1,80
          ASTRNG(L:L)=' ' 
  60    CONTINUE
      ENDIF 
C 
C     * STORE "APPND" IN "ASTRNG" AND UPDATE THE NUMBER OF CHARACTERS "NCPS" IN 
C     * "ASTRNG". 
C 
      ASTRNG(NCPS+1:NCPS+LAPPND)=APPND(1:LAPPND)
      NCPS=NCPS+LAPPND
C 
      RETURN
C 
 6000 FORMAT(A80) 
 6010 FORMAT(' PUTPARM; BLANK PARMSUB NAME IS ILLEGAL !') 
 6020 FORMAT(' PUTPARM; VALUE= ',I20,' IS MORE THAN 9 DIGITS', 
     1       ' FOR ''',A8,''' PARAMETER.')
      END
