*
* $Id: uglast.F,v 3.3 2005/12/05 12:15:20 pam-ba Exp $
*
* $Log: uglast.F,v $
* Revision 3.3  2005/12/05 12:15:20  pam-ba
* new spectrometer geometry and internal magnetic field
*
* Revision 3.2  2005/06/21 02:41:56  cafagna
* Major modification to the geometry and to the random number chain
*
* Revision 3.1.1.1  2002/07/11 16:02:00  cafagna
* First GPAMELA release on CVS
*
*
*               14/04/2005  13:08     by  Marialuigia Ambriola
*CMZ :  3.00/00 30/03/2001  14.16.15  by  Marialuigia Ambriola
*CMZ :  2.01/00 05/04/2000  14.35.18  by  Marialuigia Ambriola
*CMZ :  2.00/00 03/03/2000  15.39.05  by  Francesco Cafagna
*CMZ :  1.00/02 12/03/96  16.29.41  by  Francesco Cafagna
*-- Author :    Francesco Cafagna   30/11/95
      SUBROUTINE UGLAST
************************************************************************
*                                                                      *
*            Termination routine to print histograms and statistics    *
*                                                                      *
* Called by: MAIN                                                      *
* Author: Francesco Cafagna, 30/11/95 16.32.17                         *
*                                                                      *
************************************************************************
#include "gpkey.inc"
#include "gpunit.inc"
C
#include "gcflag.inc"
#include "gpseed.inc"
C
C User action
C
      CALL GPULAS
C
      CALL GLAST
C
C             Save histograms
C
      IF (HBK) THEN
         CALL HROUT(0,ICYCLE,' ')
         CALL HREND('GPAMELA')
         CALL HPRINT(0)
      ENDIF
      CLOSE (LUHBK)
*.
#if defined(GPAMELA_HIGZ)
*
*             Close GKS display file
*
      CALL IGEND
#endif
C
C obsolete , now done in GPUINI
C
C Close magnetic field map
C
C      CLOSE (LUFMAP)
*
*ml 19/4/2004: (update and close the file that contains the seed of
*the random number generator.
      CLOSE(LUFSF)
      CALL GRNDMQ(NRNDM(1),NRNDM(2),0,'G')
c      print*,'glast:nrndm=',nrndm(1),nrndm(2)
      OUTSEED(3)=NRNDM(1)
      OUTSEED(4)=NRNDM(2)
C      WRITE(LULSF) NRNDM
      WRITE(LULSF) OUTSEED
c      PRINT*,'UGLAST: INSEED=',INSEED
c      PRINT*,'UGLAST: OUTSEED=',OUTSEED
      CLOSE(LULSF)
      END
