C******************** START FILE UF3DRE.FOR ; GROUP UFILES ******************
C--------------------------------------------------------------
C  UF3DRE
C
C  SIMPLIFIED READ ROUTINE FOR 3D DATA.  LABELS FOR DATA ARE
C  NOT RETURNED, ONLY THE DATA ITSELF.  THE DATA LABELS
C  ARE PRINTED ON UNIT LUNO
C
C  ACTUAL READ IS PERFORMED BY UF3DRD, WHICH MAY BE USED
C  DIRECTLY IF LABELS ARE DESIRED.  PURPOSE OF THIS ROUTINE
C  IS TO HAVE A 3D READ ROUTINE WITH AS SIMPLE A LIST OF CALLING
C  ARGUMENTS AS POSSIBLE.
C
        SUBROUTINE UF3DRE(ILUN,F,NF1,NF2,X,NX,Y,NY,Z,NZ,
     >     NXACT,NYACT,NZACT,IFLAG,IER,LUNO)
C
C  ILUN (INPUT) - FILE LOGICAL UNIT NUMBER
C    FILENAME WILL HAVE BEEN CONSTRUCTED (SRS. UFSETR,UFOPEN)
C  AND FILE OPENED (SR. UFOPRD) BEFORE THIS ROUTINE IS CALLED
C
C  X  ARRAY FOR 1ST INDEPENDENT VARIABLE (RETURNED FROM FILE)
C  Y  ARRAY FOR 2ND INDEPENDENT VARIABLE (RETURNED FROM FILE)
C  Z  ARRAY FOR 3RD INDEPENDENT VARIABLE (RETURNED FROM FILE)
C  F  ARRAY FOR DEPENDENT VARIABLE (RETURNED FROM FILE)
C  NF1,NX,NY (INPUT) SIZES OF X,Y,F ARRAYS - SEE DECLARATIONS
C     NF1 FOR 1ST DIM. OF F ARRAY (DOUBLY SUBSCRIPTED)
C     ERROR WILL OCCUR IF ARRAY SIZES ARE INSUFFICIENT TO
C     ACCOMODATE DATA IN FILE BEING READ.
C  NXACT,NYACT - THE ACTUAL SIZES OF THE X AND Y DATA ARRAYS
C     IN THE FILE.  THE F ARRAY WILL THEN CONTAIN NXACT*NYACT PTS.
C  IFLAG (INPUT) - IF IFLAG=1 THE DATA IS READ CONSECUTIVELY INTO
C     THE F ARRAY; IF IFLAG=0, THE DATA IS READ
C     VIA "READ (..) ((F(IJ,IK),IJ=1,NXACT),IK=NYACT)
C     WHICH MAY RESULT IN THE DATA NOT BEING CONTIGUOUSLY STORED.
C
C  IER   ERROR RETURN CODE 0= NORMAL SUCCESSFUL COMPLETION
C  LUNO  (INPUT) OPEN I/O CHANNEL FOR OUTPUT OF FILE
C        DATA LABELS (OUTPUT SUPPRESSED IF LUNO.LE.0)
C
C---
        USE UFILES
C
        REAL X(NX),F(NF1,NF2,NZ),Y(NY),Z(NZ),ZVAL(UFPASC)
        CHARACTER*10 ZSDATE
        CHARACTER*30 XLAB,FLAB,YLAB,ZLAB,ZSCLAB(UFPASC)
      CHARACTER*4 IDEV
C
C$r8real_output: f,x,y,z
C
C  READ THE DATA
C
      CALL UFINIT
      CALL UFLCHK(ILUN,'UF3DRE    ',ICHAN,IER)
        CALL UF2DRD(ILUN,IDEV,ZSDATE,F,NF1,NF2,X,NX,Y,NY,Z,NZ,IPROC,
     >     NXACT,NYACT,NZACT,IFLAG,
     >     FLAB,XLAB,YLAB,ZLAB,UFPASC,IVGOT,ZVAL,ZSCLAB,IER)
C
      IF(LUNO.LE.0) RETURN
C
C  ECHO LABEL; RESULTS INFO
        WRITE(LUNO,1001) IER
 1001   FORMAT(' =============================================='/
     >  ' DATA READ FROM FILE:  IER=',I3,' (0 IS NORMAL)'/)
c
        call ufsnmd(luno,' Ufile Name',ilun)
c
        WRITE(LUNO,1002) ILUN,IDEV,ZSDATE
 1002   FORMAT(' UFILES LOGICAL UNIT: ',I3,' TOKAMAK:  ',A4,
     >  ' SHOT DATE:  ',A10/)
        WRITE(LUNO,1003) NXACT,XLAB,NYACT,YLAB,NZACT,ZLAB,FLAB
 1003   FORMAT(1X,I4,' X PTS:  "',A30,'"'/1X,I4,' Y PTS:  "',A30,'"'/
     >         1X,I4,' Z PTS:  "',A30,'"'/'   DATA PTS:  "',A30,'"'/)
        IF((IPROC.EQ.1).OR.(IPROC.EQ.3)) WRITE(LUNO,1004)
        IF((IPROC.EQ.2).OR.(IPROC.EQ.3)) WRITE(LUNO,1005)
 1004   FORMAT(' DATA WAS AVERAGED')
 1005   FORMAT(' DATA WAS SMOOTHED')
C
      IF(IVGOT.EQ.0) GO TO 100
      DO 96 I=1,IVGOT
        WRITE(LUNO,1006) ZVAL(I),ZSCLAB(I)
 1006   FORMAT(' ASSOCIATED QUANTITY VALUE:  ',1PE12.5/
     >       '	  	       LABEL:  ',A30/)
 96   CONTINUE
C
 100  CONTINUE
        RETURN
                END
C******************** END FILE UF3DRE.FOR ; GROUP UFILES ******************
