      SUBROUTINE MINMAX(NFACE,XMED,YMED,ZMED)
C
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
C
      XMA = -BIG
      XMI =  BIG
      YMA = -BIG
      YMI =  BIG
      ZMA = -BIG
      ZMI =  BIG
      IF (NDS.EQ.3) THEN
        DO N=1,NFACE
          XMA = MAX(XMA,XF(1,N),XF(2,N),XF(3,N))
          XMI = MIN(XMI,XF(1,N),XF(2,N),XF(3,N))
          YMA = MAX(YMA,YF(1,N),YF(2,N),YF(3,N))
          YMI = MIN(YMI,YF(1,N),YF(2,N),YF(3,N))
          ZMA = MAX(ZMA,ZF(1,N),ZF(2,N),ZF(3,N))
          ZMI = MIN(ZMI,ZF(1,N),ZF(2,N),ZF(3,N))
        ENDDO
      ELSE
        DO N=1,NFACE
          XMA = MAX(XMA,XF(1,N),XF(2,N),XF(3,N),XF(4,N))
          XMI = MIN(XMI,XF(1,N),XF(2,N),XF(3,N),XF(4,N))
          YMA = MAX(YMA,YF(1,N),YF(2,N),YF(3,N),YF(4,N))
          YMI = MIN(YMI,YF(1,N),YF(2,N),YF(3,N),YF(4,N))
          ZMA = MAX(ZMA,ZF(1,N),ZF(2,N),ZF(3,N),ZF(4,N))
          ZMI = MIN(ZMI,ZF(1,N),ZF(2,N),ZF(3,N),ZF(4,N))
        ENDDO
      ENDIF
      XMED = .5*(XMA+XMI)
      YMED = .5*(YMA+YMI)
      ZMED = .5*(ZMA+ZMI)
ccc      print*,'minmax',XMI,XMA,yMI,yMA,zMI,zMA
      END
