*DECK NXTXYZ
      SUBROUTINE NXTXYZ(IPTRK ,IPRINT,NDIM  ,MAXMSH,NUCELL,
     >                  ABSC,DGMESH)
*
*-----------------------------------------------------------------------
*
*Purpose:
* Find global cell limits.
*
*Copyright:
* Copyright (C) 2005 Ecole Polytechnique de Montreal.
*
*Author(s):
*  G. Marleau, R.Roy
*
*Update(s):
* None.
*
*Reference:
*  G. Marleau,
*  \textsl{New Geometries Processing in DRAGON: The NXT: Module},
*  Report IGE-260, \'{E}cole Polytechnique de Montr\'{e}al,
*  Montr\'{e}al, 2005.
*  Extracted from the subroutine XELTI2 and XELTI3.
*
*Parameters: input
* IPTRK   pointer to the TRACKING data structure in
*         update or creation mode.
* IPRINT  print level.
* NDIM    number of dimensions for geometry.
* MAXMSH  maximum number of elements in mesh vector for
*         each directions.
* NUCELL  number of cell after unfolding in
*         $X$, $Y$ and $Z$ directions.
*
*Parameters: output
* ABSC    cell width and upper limit.
* DGMESH  meshing vector for global geometry.
*
*----------
*
      USE              GANLIB
      IMPLICIT         NONE
*----
*  Subroutine arguments
*----
      TYPE(C_PTR)      IPTRK
      INTEGER          IPRINT,NDIM,MAXMSH,NUCELL(3)
      DOUBLE PRECISION ABSC(3,2),DGMESH(-1:MAXMSH,4)
*----
*  Local parameters
*----
      INTEGER          IOUT
      CHARACTER        NAMSBR*6
      PARAMETER       (IOUT=6,NAMSBR='NXTXYZ')
      DOUBLE PRECISION DZERO,DONE
      PARAMETER       (DZERO=0.0D0,DONE=1.0D0)
*----
*  Local variables
*----
      INTEGER          IDIR
      CHARACTER        NAMREC*12
*----
*  Data
*----
      CHARACTER        CDIR(4)*1
      SAVE             CDIR
      DATA             CDIR /'X','Y','Z','R'/
*----
*  Processing starts:
*  print routine openning output header if required
*  and initialize various parameters.
*----
      IF(IPRINT .GE. 10) THEN
        WRITE(IOUT,6000) NAMSBR
      ENDIF
      CALL XDDSET(DGMESH,(MAXMSH+2)*4,DZERO)
      DO IDIR=1,NDIM
        NAMREC='G00000001SM'//CDIR(IDIR)
        CALL LCMGET(IPTRK,NAMREC,DGMESH(0,IDIR))
        ABSC(IDIR,1)=DGMESH(0,IDIR)
        ABSC(IDIR,2)=DGMESH(NUCELL(IDIR),IDIR)
        ABSC(IDIR,1)=ABSC(IDIR,2)-ABSC(IDIR,1)
        IF(IPRINT .GE. 10) THEN
          WRITE(IOUT,6010) CDIR(IDIR),ABSC(IDIR,1)
        ENDIF
      ENDDO
      DO IDIR=NDIM+1,3
        ABSC(IDIR,1)=DONE
        ABSC(IDIR,2)=DONE
      ENDDO
      IF(IPRINT .GE. 10) THEN
        WRITE(IOUT,6001) NAMSBR
      ENDIF
*----
*  Processing finished: return
*----
      RETURN
*----
*  Output formats
*----
 6000 FORMAT('(* Output from --',A6,'-- follows ')
 6001 FORMAT('   Output from --',A6,'-- completed *)')
 6010 FORMAT(' Geometry width in ',A1,' = ',F20.15)
      END
