C******************** START FILE UFNPAD.FOR ; GROUP UFILES ******************
C-----------------------------------------------------------
C  UFNPAD
C  INSERT STR1 IN STR2 WITH BLANK PADDING
C  GENERATE ERROR IF STR1 IS TOO LONG TO FIT
C
      SUBROUTINE UFNPAD(ZSTR1,ILSTR1,ZSTR2,ZERMSG,IER)
C
      USE UFILES
C
      CHARACTER*(*) ZSTR1,ZSTR2,ZERMSG
C
C ILSTR1 - LENGTH (NOT INCL. TRAILING BLANKS) OF ZSTR1
C
C ZERMSG - LABEL FOR ERROR MESSAGE
C
      ILEN=LEN(ZSTR2)
      IF(ILSTR1.GT.ILEN) THEN
C  LENGTH ERROR
        WRITE(UFELUN,9001) ZERMSG,ZSTR1(1:ILSTR1),ILEN
 9001 FORMAT(' %',A,' STRING: "',A,'" ERROR:'/
     >'   TOO LONG FOR UFILES COMMON ELEMENT (MAX=',I2,')')
        IER=1
        RETURN
      ENDIF
C
C  OK
C
      IF(ILSTR1.GT.0) ZSTR2(1:ILSTR1)=ZSTR1(1:ILSTR1)
C
      IPP=ILSTR1+1
      IF(IPP.LE.ILEN) THEN
        DO 30 IC=IPP,ILEN
          ZSTR2(IC:IC)=' '
 30     CONTINUE
      ENDIF
C
      IER=0
      RETURN
      END
C******************** END FILE UFNPAD.FOR ; GROUP UFILES ******************
