C******************** START FILE UFSTEP.FOR ; GROUP UFCMPR *************
C-----------------------------------------------------------------------
C  UFSTEP
C
C  OUTPUT DEPENDENT VARIABLE AS START AND STEP SIZE IF POSSIBLE
C
      SUBROUTINE UFSTEP(ILUN,ARRAY,ANAME,NAR,IERR)
C
C  ILUN-- LOGICAL UNIT NUMBER ON WHICH TO WRITE
C  ARRAY-- 1D ARRAY CONTAINING DATA TO BE COMPRESSED AND WRITTEN
C  ANAME-- TEXT IDENTIFYING ARRAY (X,Y,F)
C  NAR--   NUMBER OF VALUES IN ARRAY
C  IERR--  RETURNED ERROR CODE; 0 IF OK
C
      REAL*4 ARRAY(*)
      CHARACTER*1 ANAME
C
C  DUMMY FLAG (FOR POSSIBLE FUTURE USE IN FILE)
C
      DATA IDUMF/0/
C
      IF(NAR.LE.1) GO TO 110
C
      ZSTART = ARRAY(1)
      ZDELT = (ARRAY(NAR) - ZSTART)/(NAR-1)
      IF(ABS(ZDELT).LT.1.E-34) GO TO 110
C
      DO II=2,NAR
        ATEST = ABS(1.0 - (ARRAY(II)-ARRAY(II-1))/ZDELT)
        IF(ATEST .GT. 1.5E-3) GO TO 110
      ENDDO
C
CX	WRITE(ILUN,3012) ZSTART,ZDELT,ANAME
CX 3012	FORMAT(1X,2(E14.7),T32,';-START, DELTA FOR ',A)
      WRITE(ILUN) ZSTART,ZDELT,IDUMF
C
      ICOMP = 0
      IWRDS = 2
CX	WRITE(ILUN,3014) ICOMP, IWRDS,IDUMF
CX 3014	FORMAT(1X,2I10,T32,';-FLAG INDICATING VALUES ARE START AND DELTA')
      WRITE(ILUN) ICOMP,IWRDS,IDUMF
C
      IERR = 0
      RETURN
C
 110  IERR = 1
      RETURN
      END
C******************** END FILE UFSTEP.FOR ; GROUP UFCMPR ***************
