C******************** START FILE IUFTRM.FOR ; GROUP UFILES ******************
C-----------------------------------------------------------
C  IUFTRM
C  INTEGER FUNCTION, RETURN LENGTH OF STRING NOT INCLUDING
C  TRAILING BLANKS.
C  GENERATE LABELED ERROR MESSAGES IF
C   (A) INPUT STRING IS NOT LEFT JUSTIFIED
C   (B) INPUT STRING HAS IMBEDDED BLANKS
C
C  STRING WITH NO NONBLANKS IS OK
C
      INTEGER FUNCTION IUFTRM(ZSTR,ZERMSG,IER)
C
      USE UFILES
C
      CHARACTER*(*) ZSTR
      CHARACTER*(*) ZERMSG
C
      IER=0
      ILEN0=LEN(ZSTR)
C
      DO 10 IC=ILEN0,1,-1
        IF(ZSTR(IC:IC).NE.' ') GO TO 20
 10   CONTINUE
C  BLANK STRING
      IUFTRM=0
      RETURN
C
 20   CONTINUE
      IUFTRM=IC
C
C  ERROR CHECKING
C
      DO 30 IL=1,IC
        IF(ZSTR(IL:IL).EQ.' ') GO TO 90
 30   CONTINUE
C  NO ERROR:
      RETURN
C  ERROR:
 90   CONTINUE
      IER=1
      WRITE(UFELUN,9001) ZERMSG,ZSTR(1:IC)
 9001 FORMAT(' %',A,' STRING: "',A,'" ERROR:'/
     >'   NOT LEFT JUSTIFIED OR CONTAINS IMBEDDED BLANKS')
      RETURN
      END
C******************** END FILE IUFTRM.FOR ; GROUP UFILES ******************
